1. This forum is ARCHIVED! Visit the new Cloud Sixteen forums, codename Eden, at https://eden.cloudsixteen.com. These forums will remain archived for a few months before being closed down, so try to encourage plugin developers to begin moving their content across to the new forums.
Dismiss Notice
Hi Guest, you need a Steam account to register and post on these forums. Login with Steam at the top of the forums to get started!
Dismiss Notice
Hi Guest, do you want to buy HL2RP or another Clockwork schema? Visit the Cloud Sixteen Store to get started!

HL2RP Not allowing units to target other units with /viewdata

Discussion in 'Development' started by Phillipinc, Jan 30, 2017.

  1. Phillipinc

    Phillipinc Clockwork Customer

    Hello, I was wondering if I could have some help, I am trying to make it so that units of a higher rank can view the data of lower ranked units while lower ranked units cant, but all units can view the data of citizens and I am having issues. Here is the code.
    Code:
    local PLUGIN = PLUGIN;
    local Clockwork = Clockwork;
    
    local COMMAND = Clockwork.command:New("ViewData");
    COMMAND.tip = "View data about a given character.";
    COMMAND.text = "<string Name>";
    COMMAND.flags = CMD_DEFAULT;
    COMMAND.arguments = 1;
    
    -- Called when the command has been run.
    function COMMAND:OnRun(player, arguments)
        local target = Clockwork.player:FindByID( arguments[1] );
        if (Schema:PlayerIsCombine(player)) then
            if (Schema:PlayerIsCombine(target)) then
                if (Schema:IsPlayerCombineRank( player, {ranks["squadleader"], nranks["sectorial"], nranks["commander"], nranks["officer"]} ) or player:GetFaction() == FACTION_OTA) then
                    if (target) then
                        if (player != target or player:IsAdmin()) then
                    local data = target:GetCharacterData( "combinedata" );
       
                    if (data == nil or (type(data) == "string" and string.len(data) == 0)) then
                          target:SetCharacterData("combinedata", PLUGIN.defaultCharData);
                      end;
       
                        Clockwork.datastream:Start( player, "EditData", { target, target:GetCharacterData("combinedata") or "", target:GetCharacterData("combinepoints") or {}, target:GetCharacterData("citizenid") or "" } );
       
                        player.editDataAuthorised = target;
                    else
                        Clockwork.player:Notify(player, "You cannot view or edit your own data!");
                    end;
                    else
                        Clockwork.player:Notify(player, arguments[1].." is not a valid character!");
                    end;
                else
                    Clockwork.player:Notify(player, "You are not ranked high enough to use this command!");
                end;
            end;
        else
            Clockwork.player:Notify(player, "You are not the Combine!");
        end;
    end;
    
    COMMAND:Register();
     
    • Funny Funny x 1
    Last edited: Jan 31, 2017
  2. This issue keeps coming up on my server.. wtf?
     
    • Funny Funny x 1
  3. Phillipinc

    Phillipinc Clockwork Customer

    @Trudeau I was wondering if you knew anything?
     
  4. What's the nranks table from?
     
  5. Phillipinc

    Phillipinc Clockwork Customer

    It is from the metro police customization plugin that viomi made.
     
  6. Are you sure it isn't a local variable? Are there errors when the command is run?
     
  7. Phillipinc

    Phillipinc Clockwork Customer

    It is not a local variable and there are no errors, the higher ranked units can view lower ranked units data but they cant view citizens for some reason.
     
  8. Because you're doing
    Code:
    if (Schema:PlayerIsCombine(target)) then
     
  9. Phillipinc

    Phillipinc Clockwork Customer

    Is there a way to make it so units of a higher rank can view the data of lower ranked units while lower ranked units cant, but all units can view the data of citizens?
     

Previous Readers (Total: 0)