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();