My friend has a problem with the script say save and load what you type load the server throws his players bothered me more in the middle miejscu.A me is all right
var
AutoLoadDefault: boolean;
MaxLoads,SaveTime: byte;
Color: longint;
SaveDist,FlagDist,MaxSpeed: single;
Save,AutoLoad,AfterRespawn: array[1..32] of boolean;
Time,Loads: array[1..32] of integer;
SaveX,SaveY: array[1..32] of single;
procedure AppOnIdle(Ticks: integer);
var
i: byte;
begin
for i := 1 to 32 do begin
if Time[i] > 0 then Time[i] := Time[i] - 1;
if AfterRespawn[i] then begin
AfterRespawn[i] := false;
if Save[i] and AutoLoad[i] then MovePlayer(i,SaveX[i],SaveY[i]);
end;
end;
end;
function LoadSettings(File: string): boolean;
begin
try
if ReadINI(File,'Settings','AutoLoad','false') = 'true' then AutoLoadDefault := true else AutoLoadDefault := false;
MaxLoads := StrtoInt(ReadINI(File,'Settings','MaxLoads',' '));
SaveTime := StrtoInt(ReadINI(File,'Settings','SaveTime',' '));
SaveDist := StrtoFloat(ReadINI(File,'Settings','SaveDist',' '));
FlagDist := StrtoFloat(ReadINI(File,'Settings','FlagDist',' '));
MaxSpeed := StrtoFloat(ReadINI(File,'Settings','MaxSpeed',' '));
Color := StrtoInt(ReadINI(File,'Settings','Color',' '));
except
Result := true;
Exit;
end;
end;
procedure ActivateServer();
begin
if LoadSettings('scripts/' + ScriptName + '/settings.ini') then WriteLn(' [*] ' + ScriptName + ' -> Error while loading settings') else WriteLn(' [*] ' + ScriptName + ' -> Settings loaded successfully');
end;
function OnPlayerCommand(ID: Byte; Text: string): boolean;
var
FlagAX,FlagAY,FlagBX,FlagBY: single;
begin
Result := false;
Case GetPiece(LowerCase(Text),' ',0) of
'/save': begin
if Copy(Text,7,Length(Text)) <> '' then Exit;
if (Loads[ID] < MaxLoads) or (MaxLoads = 0) then begin
if GetPlayerStat(ID,'Alive') = true then begin
if Time[ID] = 0 then begin
if (Save[ID] = false) or (Distance(GetPlayerStat(ID,'X'),GetPlayerStat(ID,'Y'),SaveX[ID],SaveY[ID]) >= SaveDist) then begin
GetFlagsXY(FlagAX,FlagAY,FlagBX,FlagBY);
if (Distance(GetPlayerStat(ID,'X'),GetPlayerStat(ID,'Y'),FlagAX,FlagAY) >= FlagDist) and (Distance(GetPlayerStat(ID,'X'),GetPlayerStat(ID,'Y'),FlagBX,FlagBY) >= FlagDist) then begin
if GetPlayerStat(ID,'Ground') = true then begin
Time[ID] := SaveTime;
WriteConsole(ID,'Your position has been saved.',Color);
SaveX[ID] := GetPlayerStat(ID,'X');
SaveY[ID] := GetPlayerStat(ID,'Y');
Save[ID] := true;
end else WriteConsole(ID,'You must be standing on the ground to save.',Color);
end else WriteConsole(ID,'You are too close to at least one of the flags.',Color);
end else WriteConsole(ID,'You are too close to your previously saved location to save again.',Color);
end else WriteConsole(ID,'You still have ' + InttoStr(Time[ID]) + ' seconds remaining until you may save again.',Color);
end else WriteConsole(ID,'You must be alive to save your location.',Color);
end else WriteConsole(ID,'It is pointless to save when you can not load.',Color);
end;
'/load': begin
if Copy(Text,7,Length(Text)) <> '' then Exit;
if GetPlayerStat(ID,'Alive') = true then begin
if (Loads[ID] < MaxLoads) or (MaxLoads = 0) then begin
if Distance(0,0,GetPlayerStat(ID,'VelX'),GetPlayerStat(ID,'VelY')) <= MaxSpeed then begin
if GetPlayerStat(ID,'Ground') = true then begin
if Save[ID] then begin
Loads[ID] := Loads[ID] + 1;
MovePlayer(ID,SaveX[ID],SaveY[ID]);
if AfterRespawn[ID] then AfterRespawn[ID] := false;
MovePlayer(ID,SaveX[ID],SaveY[ID]);
WriteConsole(ID,'You have loaded your previously saved position.' + iif(MaxLoads = 0,'','(' + InttoStr(Loads[ID]) + ' / ' + InttoStr(MaxLoads) + ')'),Color);
end else WriteConsole(ID,'No save data to load.',Color);
end else WriteConsole(ID,'You must be standing on the ground to load.',Color);
end else WriteConsole(ID,'You are moving too fast to load.',Color);
end else WriteConsole(ID,'You have maxed out on number of loads you are allowed to use. (' + InttoStr(MaxLoads) + ')',Color);
end else WriteConsole(ID,'You must be alive to load your previously saved location.',Color);
end;
'/reset': begin
if Copy(Text,8,Length(Text)) <> '' then Exit;
if Save[ID] then begin
DoDamage(ID,4000);
Save[ID] := false;
SaveX[ID] := 0;
SaveY[ID] := 0;
Loads[ID] := 0;
WriteConsole(ID,'Save data reset.',Color);
end else WriteConsole(ID,'No save data to reset.',Color);
end;
'/autoload': begin
Case LowerCase(GetPiece(Text,' ',1)) of
'on','enable','enabled': begin
if AutoLoad[ID] then WriteConsole(ID,'Auto loading is already enabled.',Color) else begin
AutoLoad[ID] := true;
WriteConsole(ID,'Auto loading has been enabled.',Color);
end;
end;
'off','disable','disabled': begin
if AutoLoad[ID] then begin
AutoLoad[ID] := false;
WriteConsole(ID,'Auto loading has been disabled.',Color);
end else WriteConsole(ID,'Auto loading is already disabled.',Color);
end;
'': if AutoLoad[ID] then WriteConsole(ID,'Auto loading is enabled.',Color) else WriteConsole(ID,'Auto loading is disabled',Color);
else WriteConsole(ID,'Invalid input.',Color);
end;
end;
end;
end;
function OnCommand(ID: Byte; Text: string): boolean;
begin
if Text = '/loadsettings' then if LoadSettings('scripts/' + ScriptName + '/settings.ini') then begin
WriteLn(' [*] ' + ScriptName + ' -> Error while loading settings');
WriteConsole(ID,'Error while loading settings',Color);
end else begin
WriteLn(' [*] ' + ScriptName + ' -> Settings loaded successfully');
WriteConsole(ID,'Settings loaded successfully',Color);
end;
end;
procedure OnMapChange(NewMap: string);
var
i: byte;
begin
for i := 1 to 32 do begin
Save[i] := false;
SaveX[i] := 0;
SaveY[i] := 0;
Time[i] := SaveTime;
Loads[i] := 0;
end;
end;
procedure OnJoinGame(ID, Team: byte);
begin
DrawText(ID,' Save and load the script ' + chr(13) + chr(10) +
' has been created ' + chr(13) + chr(10) +
' by Dominik',400,RGB(0,0,0),0.103,60,300);
Save[ID] := false;
SaveX[ID] := 0;
SaveY[ID] := 0;
Time[ID] := SaveTime;
Loads[ID] := 0;
AutoLoad[ID] := AutoLoadDefault;
end;
procedure OnFlagScore(ID, TeamFlag: byte);
begin
Save[ID] := false;
SaveX[ID] := 0;
SaveY[ID] := 0;
Time[ID] := SaveTime;
Loads[ID] := 0;
end;
procedure OnPlayerRespawn(ID: byte);
begin
AfterRespawn[ID] := true;
end;
procedure OnJoinTeam(ID, Team: byte);
begin
WriteConsole(ID,' Sponsors and produces scripts for the server Dominik ',$EE81FAA1);
end;