Author Topic: Problems  (Read 1051 times)

0 Members and 1 Guest are viewing this topic.

Offline dominikkk26

  • Camper
  • ***
  • Posts: 404
    • PMGsite
Problems
« on: February 11, 2010, 03:24:27 pm »
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

Code: (pascal) [Select]
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;

Offline Hacktank

  • Camper
  • ***
  • Posts: 462
  • Soldat Scripter
    • HTZRPG
Re: Problems
« Reply #1 on: February 11, 2010, 04:29:40 pm »
I cant understand what your saying the problem is.

Is it not saving correctly, not loading correctly? Compile error?

Quote
bothered me more in the middle miejscu.A me is all right
?

Is it that if you do a moveplayer command and move them more than about 70 pixels it drops their gun on reentry? That is a serverside problem due to you being teleported to the middle and then the destination for some strange reason.


Offline Furai

  • Administrator
  • Veteran
  • *****
  • Posts: 1908
    • TransHuman Design
Re: Problems
« Reply #2 on: February 11, 2010, 05:16:19 pm »
I just can't stand his English. Dominick, tell us your problem in Polish, I'll do my best to translate it. You can even pm me whenever you want to post anywhere anything new. I'll help you. Feel free to do it.
"My senses are so powerful that I can hear the blood pumping through your veins."

Offline dominikkk26

  • Camper
  • ***
  • Posts: 404
    • PMGsite
Re: Problems
« Reply #3 on: February 12, 2010, 06:53:55 am »
Otóż chodzi o to ze skrypt u mnie dobrze działa /save i /load ale u kolegi na serwerze wyrzuca na gdzieś niewiejącej na środek. Czemu tak jest ?? U mnie jest w porze dobrze teleportuje ale u kolegi wyrzuca na niewiejącej środek.

Offline tk

  • Soldier
  • **
  • Posts: 235
Re: Problems
« Reply #4 on: February 12, 2010, 07:10:38 am »
Quote
ale u kolegi na serwerze wyrzuca na gdzieś niewiejącej na środek
What?
You can't even speak polish

edit:
Quote
   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); 

And this is not your script.
http://forums.soldat.pl/index.php?topic=18900.0
« Last Edit: February 12, 2010, 07:19:32 am by tk »

Offline freestyler

  • Soldat Beta Team
  • Camper
  • ******
  • Posts: 326
Re: Problems
« Reply #5 on: February 12, 2010, 07:38:38 am »
From what he described (teleporting to the center of map instead of specified place), I guess the problem lies within version of SoldatServer you and your friend are using. Previous versions had a problem with MovePlayer, so I'd suggest telling your friend to update his SoldatServer.

Powiedz kumplowi, żeby zainstalował nową wersję serwera, bo poprzednie miały problem z przesuwaniem graczy - działo się dokładnie to, o czym piszesz, czyli przesuwało na środek mapy zamiast w odpowiednie miejsce.

Offline dominikkk26

  • Camper
  • ***
  • Posts: 404
    • PMGsite
Re: Problems
« Reply #6 on: February 12, 2010, 01:07:38 pm »
Many thanks to my new information collection.