Official Soldat Forums

Server Talk => Scripting Releases => Topic started by: DorkeyDear on August 16, 2007, 01:09:31 pm

Title: Position Saver
Post by: DorkeyDear on August 16, 2007, 01:09:31 pm
Script Name: Position Saver
Script Description: When a player does /save, his / her position is saved. When (s)he does /load then she is teleported to that last saved location. There is a limitation of the total number of times a player may load his / her position that may be set in one of the constants at the top of the script. Also, there is a required amount of time between save (changeable through a constant), and you must be a at least a certain distance away from the flags and your previously saved position (changeable through constants). Also note that the script does include a limitation of a player's speed when loading, although because GetPlayerStat always returns 0 with the speed variables, it is commented out. It should still work when it is uncommented out in the next version of Soldat Dedicated Server if what is returned is fixed.
Original Author: Curt (Probably based off of EnEsCe's script on his FUN server)
Core Version: 2.6.3
In request from Iq-Unlimited
Title: Re: Position Saver
Post by: Iq Unlimited on August 16, 2007, 01:13:34 pm
Teh download since Curt was too lazy to add it himself.


Title: Re: Position Saver
Post by: DorkeyDear on August 16, 2007, 01:16:15 pm
No! Not true! It was really on my desktop ready to be uploaded, I just forgot! Lol, its now there.
(Hehehe, mine is a smaller size)
Title: Re: Position Saver
Post by: Freedom on August 16, 2007, 01:28:04 pm
Cool xD
I'll save position just right by enemy flag XD
Title: Re: Position Saver
Post by: Iq Unlimited on August 16, 2007, 01:50:06 pm
lol, it was meant for climbs, and also you cant save by a  flag.
Title: Re: Position Saver
Post by: Ttil_Np.csWoW on August 16, 2007, 02:41:08 pm
this is really anoying on some climb maps ( i know from enesces sever) on other maps its good.
i say that normal climbing is better than /save and /load
can you save porsitsion then change team then load?
Title: Re: Position Saver
Post by: DorkeyDear on August 16, 2007, 02:59:29 pm
can you save porsitsion then change team then load?
yeah.. script is generally meant for a 1-team climb server. It would go well along with a script that auto sets a player team to alpha if they try to change teams.
Title: Re: Position Saver
Post by: Ttil_Np.csWoW on August 16, 2007, 11:14:10 pm
could you reset the players save onjointeam? (just wornding not asking)
Title: Re: Position Saver
Post by: DorkeyDear on August 17, 2007, 11:16:33 am
could you reset the players save onjointeam? (just wornding not asking)
Yeah, just replace "procedure OnJoinGame(ID, Team: byte);" with "procedure OnJoinTeam(ID, Team: byte);", and the script will reset a person's save when they changes teams too.
Title: Re: Position Saver
Post by: Snipufin on August 20, 2007, 09:11:35 am
You steel meh script!
Title: Re: Position Saver
Post by: EnEsCe on August 20, 2007, 10:12:44 am
You steel meh script!
I had it first lawl!!! its mien!
Title: Re: Position Saver
Post by: Iq Unlimited on August 20, 2007, 10:32:58 am
You steel meh script!
I had it first lawl!!! its mien!
I take the blame for the suggestion that Curt should go ahead and make it ^^.
Title: Re: Position Saver
Post by: Ride on August 20, 2007, 05:21:53 pm
lol, it was meant for climbs, and also you cant save by a  flag.
you can edit it so it can be able to work next to flags >:D
Title: Re: Position Saver
Post by: miketh2005 on August 21, 2007, 11:44:29 am
lol, it was meant for climbs, and also you cant save by a  flag.
you can edit it so it can be able to work next to flags >:D
how? I need 1 please, I need a script that has no limitation inf saves inf loads and you can save anytime anywhere, and next to flags. please make me 1, thanx
Title: Re: Position Saver
Post by: DorkeyDear on August 21, 2007, 01:58:05 pm
Quote from: DorkeyDear
Code: [Select]
const
  Color = $FF52DD52;
  MaxLoads = 3;
  SaveTime = 30;
  SaveDist = 400;
  FlagDist = 500;
You can change FlagDist and SaveDist and SaveTime to 0 for the only limitation being the max number of loads. I might modify it so if you put -1 as the MaxLoads, then there will be no limit, but thats not in there yet.
Title: Re: Position Saver
Post by: miketh2005 on August 21, 2007, 03:12:32 pm
could I put like 100? or whats the max i can put?
Title: Re: Position Saver
Post by: DorkeyDear on August 21, 2007, 03:59:31 pm
I'm not sure what datatype it is, sense its a constant... I would assume an integer, so 32767 (No, I did not memorize that number) would be the highest it can be.
Title: Re: Position Saver
Post by: miketh2005 on August 29, 2007, 06:58:10 pm
ok thanx, i think thats enough lol

Date Posted: August 22, 2007, 11:52:21 AM
there is a bug when on ice, you cant save

Date Posted: August 29, 2007, 07:56:16 PM
can u also make it so if a person types /s or /l because it's a hassle to keep typing it out especially if its a hard jump or something.
Title: Re: Position Saver
Post by: DorkeyDear on August 30, 2007, 02:39:10 pm
Theres no way to fix the ice thing that I know of.
Doesn't when a person do a 1 letter / command or 2 letter, it actually acts like the person said "s" or "l" or whatever letter is there? I just tested it, when in a server, i did /t and /te and it was as if I typed "t" and "te" but then I did "/tes" and nothing happened.
I'll see if the single or double letter commands actually calls the OnPlayerCommand function, and if it does, then I'll modify the script.
Title: Re: Position Saver
Post by: EnEsCe on August 30, 2007, 10:12:10 pm
If the command is less than 3 chars, it wont work.
Title: Re: Position Saver
Post by: DorkeyDear 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
Title: Re: Position Saver
Post by: chutem 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
Title: Re: Position Saver
Post by: BombSki 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
Title: Re: Position Saver
Post by: DorkeyDear on November 04, 2007, 01:34:03 pm
Update:
 
Title: Re: Position Saver
Post by: Ippo 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.


Title: Re: Position Saver
Post by: BombSki on January 31, 2008, 01:28:29 pm
read the stickies.
http://forums.soldat.pl/index.php?topic=21468.0
Title: Re: Position Saver
Post by: Bonecrusher on March 03, 2008, 02:27:36 am
is it possible to turn off this script using command?
Title: Re: Position Saver
Post by: DorkeyDear 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.
Title: Re: Position Saver
Post by: macho 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;



Title: Re: Position Saver
Post by: DorkeyDear on March 28, 2008, 06:35:07 pm
You should put it in [.code]...[./code]s to get rid of the
Title: Re: Position Saver
Post by: RunMan 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:

I will be very thankful when someone help me :)
Title: Re: Position Saver
Post by: DorkeyDear 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)....
 
Title: Re: Position Saver
Post by: danmer 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
Title: Re: Position Saver
Post by: Miszkol_ 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
Title: Re: Position Saver
Post by: DorkeyDear 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.
Title: Re: Position Saver
Post by: Miszkol_ 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.
Title: Re: Position Saver
Post by: DorkeyDear on April 24, 2008, 08:25:21 pm
Try this...
Title: Re: Position Saver
Post by: Miszkol_ 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...
Title: Re: Position Saver
Post by: DorkeyDear 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.
Title: Re: Position Saver
Post by: Miszkol_ 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??
Title: Re: Position Saver
Post by: DorkeyDear on May 01, 2008, 02:31:52 pm
It's working! IT'S WORKING!!! ^^
Thank you very much.

@BUG...
May you do timer start if any1 join the game??
every1 has their own timer, resets when they respawn
Title: Re: Position Saver
Post by: Miszkol_ on May 02, 2008, 03:48:16 am
Quote
timer, resets when they respawn

May you do timer DON'T resets when they respawn??
Title: Re: Position Saver
Post by: DorkeyDear on May 02, 2008, 03:13:58 pm
Theres a constant up top...
Title: Re: Position Saver
Post by: Miszkol_ on May 03, 2008, 09:11:15 am
This still don't work(timer started - join game)...

New idea!
You may do "other" timer - ... # minutes and # seconds ...??
Title: Re: Position Saver
Post by: DorkeyDear on May 03, 2008, 10:02:21 am
This still don't work(timer started - join game)...
Are you saying you want a timer from the start of the map?
Title: Re: Position Saver
Post by: Miszkol_ on May 03, 2008, 10:50:32 am
This still don't work(timer started - join game)...
Are you saying you want a timer from the start of the map?

Yes... and may you do "other timer" ??

@edit

Do you this???
Title: Re: Position Saver
Post by: DorkeyDear on May 05, 2008, 03:00:07 pm
.
Title: Re: Position Saver
Post by: Bellamy on May 06, 2008, 06:36:16 pm
Hi. For some reason, I can't turn off the auto save option. I typed off, 0, and no but none of them turn it off. Then I went into the server, saved, killed myself and it did it. So I typed /autosave off and it said "the auto save option is already off" or whatever. Help please.
Title: Re: Position Saver
Post by: DorkeyDear on May 06, 2008, 08:05:33 pm
Hi. For some reason, I can't turn off the auto save option. I typed off, 0, and no but none of them turn it off. Then I went into the server, saved, killed myself and it did it. So I typed /autosave off and it said "the auto save option is already off" or whatever. Help please.
I think you mean autoload :P
Forgot a bit of code ^^ updated...
Title: Re: Position Saver
Post by: Iq Unlimited on May 06, 2008, 09:12:16 pm
HI BELL

//ontopic @bell

I have an ancient positionsaver code if you're trying it in my server. The old is good for it.

Title: Re: Position Saver
Post by: Miszkol_ on May 07, 2008, 11:36:09 am
@DonkeyDear

Repair you anything??
Title: Re: Position Saver
Post by: DorkeyDear on May 07, 2008, 05:57:02 pm
@DonkeyDear

Repair you anything??
http://forums.soldat.pl/index.php?topic=18900.msg317434#msg317434
Title: Re: Position Saver
Post by: Miszkol_ on May 08, 2008, 01:28:21 am
I download this and i don't see changes...
Title: Re: Position Saver
Post by: DorkeyDear on May 08, 2008, 03:04:50 pm
I download this and i don't see changes...
Would have helped if you told me something was wrong...
Its attached.
Title: Re: Position Saver
Post by: Miszkol_ on May 09, 2008, 07:29:41 am
GJ DorkeyDead

May you do timer show minutes and seconds?? "...in x minutes and X seconds..."
Title: Re: Position Saver
Post by: DorkeyDear on May 09, 2008, 03:01:20 pm
'tis attached
Title: Re: Position Saver
Post by: Miszkol_ on May 10, 2008, 08:23:54 am
Bugs:

- Timer show time started of respawn again...
- Text: ...secs seconds...
Title: Re: Position Saver
Post by: DorkeyDear on May 10, 2008, 08:41:41 am
- Timer show time started of respawn again...
Not when I test it. ^^
Title: Re: Position Saver
Post by: black jack on August 28, 2008, 06:16:59 am
where do i put this script???
Title: Re: Position Saver
Post by: Norbo on August 28, 2008, 06:36:36 am
where do i put this script???

try searching the forums with "I need help in installing scripts!" there are pictures and suppport for n00bs unexpirenced people like you
Title: Re: Position Saver
Post by: MetsuriTossavainen on September 21, 2008, 03:00:34 am
I downloaded the script but autoload doesn't work. :| What's wrong, what should I do?

[Settings]
AutoLoad=true
MaxLoads=0
SaveTime=0
SaveDist=0
FlagDist=0
MaxSpeed=255
Color=$FF52DD52

EDIT: Nvm, I got it working :)
Title: Re: Position Saver
Post by: MetsuriTossavainen on May 03, 2009, 11:58:39 pm
I tried to get this working on 2.6.4 and it worked well until autoload teleports me in the middle of the map. I tried to save my position to several other places but the result was same. Is the scriptcore messed up or is this just normal compability problems? 
Title: Re: Position Saver
Post by: danmer on May 04, 2009, 01:16:57 am
http://forums.soldat.pl/index.php?topic=33812.0