SA-MP Forums Archive
Tips - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Tips (/showthread.php?tid=369843)



Tips - [rG]Cold - 18.08.2012

Hello.
Guys i am trying to script somekind of race.
Actually what i want to do is....when a player telepports to a certain parkour ,after few seconds a checkpoint appears and when the player enters it a race starts. I mean it is counting in how many seconds the player will finish the parkour and saves it in a file.

Help me out a bit please.


Re: Tips - [rG]Cold - 19.08.2012

Bump? :S


Re: Tips - Shetch - 20.08.2012

You can make the teleport using SetPlayerPos. (obviously herp-derp)
Create a new variable which will get the player's completion of the race.
new RaceStatuss[MAX_PLAYERS];
Once the player teleports there, show him the race CP with SetPlayerRaceCheckpoint and set the RaceStatuss[playerid] to 1.

Under OnPlayerEnterRaceCheckpoint(playerid) check if the RaceStatuss[playerid] is equal to 1. If it is, show him the next CP.


Re: Tips - [rG]Cold - 20.08.2012

Quote:
Originally Posted by Shetch
Посмотреть сообщение
You can make the teleport using SetPlayerPos. (obviously herp-derp)
-.- lol

and thanks for the rest...hmm


Re: Tips - RanSEE - 20.08.2012

https://sampwiki.blast.hk/wiki/YSI:Races
It has got everything you want. or else This


Re: Tips - [ABK]Antonio - 20.08.2012

Quote:
Originally Posted by Shetch
Посмотреть сообщение
You can make the teleport using SetPlayerPos. (obviously herp-derp)
Create a new variable which will get the player's completion of the race.
new RaceStatuss[MAX_PLAYERS];
Once the player teleports there, show him the race CP with SetPlayerRaceCheckpoint and set the RaceStatuss[playerid] to 1.

Under OnPlayerEnterRaceCheckpoint(playerid) check if the RaceStatuss[playerid] is equal to 1. If it is, show him the next CP.
HERP-DERP you forgot the time...

Inside of your player enum I would add (assuming you have a player enum, if not I would make one)...

pawn Код:
enum PlayerInfo
{
    bool:Finished, //true or false variable (like using 0 or 1 in a regular variable)
    StartTime, //We'll store the start time here (since we'll be using gettickcount() to get it)
    EndTime //Then we'll store the end time here
}
new Info[MAX_PLAYERS][PlayerInfo]; //just our array
Now when the race starts (well, starts for the player or whatever)

pawn Код:
Info[playerid][StartTime] = gettickcount();

//When the race ends (or when they cross the finish line)...

Info[playerid][Finished] = true;
Info[playerid][EndTime] = gettickcount();

//If you want to display it some where...

(Info[playerid][EndTime]-Info[playerid][StartTime])/1000 //will return in seconds how long it took, then you could divide by 60 to get minutes.



Re: Tips - [rG]Cold - 20.08.2012

Ok antonio,thanks for explaning that i will give it a shoot as soon as i get home.

Oh and actually i would like to save it in a FILE,the time i mean. And make like a Best 3 times

P.So you know Ph0eNiX? Just curious cuz ive seen a penix with the [ABK] tag :P