Author Topic: Position Saver  (Read 23246 times)

0 Members and 3 Guests are viewing this topic.

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Position Saver
« Reply #20 on: November 01, 2007, 05:04:34 pm »
If the command is less than 3 chars, it wont work.
Do you know if MM has a reason for that? (or you, don't know if its client or server-side)

Date Posted: August 31, 2007, 04:10:38 pm
Update
  • Replaced the constants with a settings.ini file
  • Added a /loadsettings command
  • Script now accepts limitations of player's speed
  • Player looses saves when he captures the flag

    Date Posted: October 15, 2007, 06:02:55 pm
    Update:
  • Setting maximum loads to 0 means there is no limit
  • Fixed the speed detection being a bit inaccurate

    Date Posted: November 01, 2007, 04:17:32 pm
    Update:
  • Auto loading after respawn is supported (/autoload on/off; server setting in settings.ini sets default state)
  • /reset command added to reset loads and saves

Offline chutem

  • Veteran
  • *****
  • Posts: 1119
Re: Position Saver
« Reply #21 on: November 03, 2007, 04:33:01 pm »
With that reset youve taken away the 'Can't save to close to last save point' because there is no longer any save point :P
1NK3FbdNtH6jNH4dc1fzuvd4ruVdMQABvs

Offline BombSki

  • Flagrunner
  • ****
  • Posts: 927
    • Climbing-soldiers.net
Re: Position Saver
« Reply #22 on: November 04, 2007, 08:51:44 am »
heh, good thinking.
i requested a /reset, because if u save it at some dead way, or a deadly polygon, u dont need to disable autoload to spawn at the actual spawn. its indeed abusable, but i dont know why you would want to disallow saving close to the last save point :P
an easy fix for this would be /kill on /reset :P

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Position Saver
« Reply #23 on: November 04, 2007, 01:34:03 pm »
Update:
 
  • Resetting kills you
  • Resetting now has a message :)

Offline Ippo

  • Major(1)
  • Posts: 5
    • My clan Mr's homepage
Re: Position Saver
« Reply #24 on: January 31, 2008, 12:56:15 pm »
Where to put this script?? I have a dedicated server.
I just wanna know this thing. Answer as soon as possible.



Offline BombSki

  • Flagrunner
  • ****
  • Posts: 927
    • Climbing-soldiers.net
Re: Position Saver
« Reply #25 on: January 31, 2008, 01:28:29 pm »

Offline Bonecrusher

  • Global Moderator
  • Veteran
  • *****
  • Posts: 1397
  • High above
    • Zabijaka.pl
Re: Position Saver
« Reply #26 on: March 03, 2008, 02:27:36 am »
is it possible to turn off this script using command?

Im chill like that

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Position Saver
« Reply #27 on: March 03, 2008, 06:24:38 am »
is it possible to turn off this script using command?
Sorry, but no. The most you can disable is autoloading your save point so that people who don't know about the script don't auto get teleported.

Offline macho

  • Major(1)
  • Posts: 2
Re: Position Saver
« Reply #28 on: March 28, 2008, 05:08:20 pm »
if some people need save in the middle on the air and whit speed and load in the middle on the air here is the code this position save is unlimited only need settings to load and incluides txt ..

Example:

Remember in a document .ini XD

[Settings]
AutoLoad=true
MaxLoads=0
SaveTime=0
SaveDist=0
FlagDist=0
MaxSpeed=100
Color=$000074E8


And in a document Pas the code XD
enjoy

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 > 0 then Time := Time - 1;
    if AfterRespawn then begin
      AfterRespawn := false;
      if Save then MovePlayer(i,SaveX,SaveY);
    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,'Alive') = 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,'Alive') = 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]);
              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 := false;
    SaveX := 0;
    SaveY := 0;
    Time := SaveTime;
    Loads := 0;
  end;
end;

procedure OnJoinGame(ID, Team: byte);
begin
  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
  DrawText(ID,'Thi Position Saver has been edited By Macho' + chr(13) + chr(10) +
              'Use commands /save and /load' + chr(13) + chr(10) +
              '          Have Fun!!!',400,RGB(255,0,0),0.103,60,300);
end;




Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Position Saver
« Reply #29 on: March 28, 2008, 06:35:07 pm »
You should put it in [.code]...[./code]s to get rid of the
  • s.

Offline RunMan

  • Major(1)
  • Posts: 27
Re: Position Saver
« Reply #30 on: April 03, 2008, 01:24:10 am »
Hello I have just started learning Pascal, so I can't change this script by myself. I want to:
  • remove all commands expcept save and load
  • I want to start the function when player sais "!save" or "!load", not when he writes in a cmd line
  • put saving limit 2 times per map

I will be very thankful when someone help me :)

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Position Saver
« Reply #31 on: April 03, 2008, 05:31:45 am »
Hello I have just started learning Pascal, so I can't change this script by myself. I want to:
  • remove all commands expcept save and load
  • I want to start the function when player sais "!save" or "!load", not when he writes in a cmd line
  • put saving limit 2 times per map

I will be very thankful when someone help me :)

After installing the script into the server (in working order)....
 
  • For admins theres /loadsettings, and for the public, /save, /load, /reset, and /autoload; I can understand autoload, but sense no admin really knows the load settings command, and reset can be used commonly... Why?
  • I'll slightly modify the script after school, but for now, its only /save /load commands.
  • to limit to 2 times / map, modify in settings.ini "MaxLoads=2"

Offline danmer

  • Camper
  • ***
  • Posts: 466
  • crabhead
Re: Position Saver
« Reply #32 on: April 03, 2008, 06:22:15 am »
what about an /autosave option? It would automatically save the position if your coordinates dont change much since say previous second and you have ground under you

Offline Miszkol_

  • Major(1)
  • Posts: 30
  • The Piccolo Power xD
Re: Position Saver
« Reply #33 on: April 23, 2008, 04:07:36 am »
@DorkeyDear

Can you do fusion this script with "capture logger" from climbing-soldiers.net??

Formula:
<Nick player> has capture the flag on <map name> in <time per capture in seconds [IMPORTAND: Time Start - Join game, not every dead]> with <How many saves> and <How many dies> deads.

Example:
XxX  has capture the flag on biaclimb1 in 10 sec. with 5 saves and 2 deads.

Reply me.
BB
English is hard language, please forget my bad :P

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Position Saver
« Reply #34 on: April 23, 2008, 03:24:03 pm »
@DorkeyDear

Can you do fusion this script with "capture logger" from climbing-soldiers.net??

Formula:
<Nick player> has capture the flag on <map name> in <time per capture in seconds [IMPORTAND: Time Start - Join game, not every dead]> with <How many saves> and <How many dies> deads.

Example:
XxX  has capture the flag on biaclimb1 in 10 sec. with 5 saves and 2 deads.

Reply me.
BB
I just threw both scripts together, and slightly modified it, so tell me if there are any bugs.
The file is attached.
Note that the log files still follow the old format, nothing changed with them, just the message that is said to everybody when the player scores the flag.
« Last Edit: April 23, 2008, 03:27:02 pm by DorkeyDear »

Offline Miszkol_

  • Major(1)
  • Posts: 30
  • The Piccolo Power xD
Re: Position Saver
« Reply #35 on: April 24, 2008, 02:44:35 pm »
It's almost excellent!
But...

1. You do "...with 0 loads...". It's good, but may you do "...with 0 loads AND # SAVES..."??
2. May you do this massage "to divide in two" to 2 massages?? See you:
Code: [Select]
Now:

________________________________
|[*]xXx.........................and dea|
________________________________

I need:
_________________________________
|[*]xXx............................          |
|[*]..............and # deads           |
_________________________________

[*]  <--- server massage

You understand me??

Reply fast.
BB.
« Last Edit: April 24, 2008, 02:51:05 pm by Miszkol_ »
English is hard language, please forget my bad :P

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Position Saver
« Reply #36 on: April 24, 2008, 08:25:21 pm »
Try this...

Offline Miszkol_

  • Major(1)
  • Posts: 30
  • The Piccolo Power xD
Re: Position Saver
« Reply #37 on: April 25, 2008, 02:14:46 am »
I search bug...Almost All is good working, but :
I 2 saves on map and when i cap the flag server write: 0 saves...
English is hard language, please forget my bad :P

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Position Saver
« Reply #38 on: April 27, 2008, 11:25:46 am »
I search bug...Almost All is good working, but :
I 2 saves on map and when i cap the flag server write: 0 saves...

most climb servers usually have next map start, or player auto-killed/respawned when they cap, so i had it reset all stats for the player when they capped. Here you go (its an option up top in the constants), try this.

Offline Miszkol_

  • Major(1)
  • Posts: 30
  • The Piccolo Power xD
Re: Position Saver
« Reply #39 on: April 27, 2008, 12:43:12 pm »
It's working! IT'S WORKING!!! ^^
Thank you very much.

@BUG...
May you do timer start if any1 join the game??
« Last Edit: May 01, 2008, 07:01:52 am by Miszkol_ »
English is hard language, please forget my bad :P