I'm getting an error on the file.Exist function (sh_fixes.lua line 100, at the #files point)
This is the code I'm trying to run:
Code:
local Clockwork = Clockwork;
local COMMAND = Clockwork.command:New("PlyGiveFlags");
COMMAND.tip = "Give flags to a player.";
COMMAND.text = "<string Name> <string Flag(s)>";
COMMAND.access = "s";
COMMAND.arguments = 2;
function COMMAND:OnRun(player, arguments)
local target = Clockwork.player:FindByID(arguments[1])
if (target) then
if (string.find(arguments[2], "a") or string.find(arguments[2], "s")
or string.find(arguments[2], "o")) then
Clockwork.player:Notify(player, "You cannot give 'o', 'a' or 's' flags!");
else
SaveFlags(target, arguments[2])
Clockwork.player:GiveFlags(target, arguments[2]);
Clockwork.player:NotifyAll(player:Name().." gave "..target:Name().." '"..arguments[2].."' global flags.")
end;
else
Clockwork.player:Notify(player, arguments[1].." is not a valid character!");
end;
end;
COMMAND:Register();
These are the functions, in sv_plugin.lua
Code:
function LoadFlags(player)
plyflags = Clockwork.kernel:RestoreSchemaData("plugins/playerflags/"..player:SteamID());
return plyflags
end
function SaveFlags(player, flags)
local curflags = LoadFlags(player)
local plyflags = flags
if(curflags != nil and curflags != "") then
for x = 0, string.len(plyflags) do
if !string.find(curflags, string.sub(plyflags, x, x)) then
curflags = curflags..string.sub(plyflags, x, x)
end
end
end
Clockwork.player:GiveFlags(player, curflags);
Clockwork.kernel:SaveSchemaData("plugins/playerflags/"..player:SteamID(), curflags);
end