Hm.. :o - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Hm.. :o (
/showthread.php?tid=105655)
Hm.. :o -
JosipBerozTito - 30.10.2009
I'm making a fs system.. and I wanna do if he types /go then he gets to the pos ( like a teleport ) and when he types /back he goes back to the pos where he teleported ( /go )
Any idea?
Re: Hm.. :o -
Nero_3D - 30.10.2009
thats not hard, you need to use an 2d array (if you want more saveable positions then you need an 3d array)
also first or all you create the array (for all players) global
then you save the position of the player if he types the command ("/go")
at least you set his positions back if he types ("/back")
Re: Hm.. :o -
JosipBerozTito - 30.10.2009
Thanks for explaning it but can you write it please.. I'm only a beginner
Re: Hm.. :o -
Tigerbeast11 - 30.10.2009
Not sure about this, but couldnt you take the pos of the player before he teleports and then when he types /back you could set it to the pos
Re: Hm.. :o -
JosipBerozTito - 30.10.2009
That's how I was thinking too.. but how to get his pos
Float: Y;
Float: X;
Float: Z;
GetPlayerPos(Y,X,Z);
And when types /back than SetPlayerPos(playerid,Y,X,Z);
Something like this or Idk
Re: Hm.. :o -
JosipBerozTito - 30.10.2009
Any idea?
Re: Hm.. :o -
dice7 - 30.10.2009
You gave yourself the solution. And use an array for all players
Re: Hm.. :o -
Nero_3D - 30.10.2009
yes, here would be your solution in working pawn code
pawn Код:
new Float:Saved_Positions[MAX_PLAYERS][3]; //MAX_PLAYERS (so we get one cell for each player) and 3 for X, Y and Z
pawn Код:
//In OnPlayerCommandText
if(strcmp("/go", cmdtext, true) == 0)
{
GetPlayerPos(playerid, //get his position before we set it, else it would get the setted position
Saved_Positions[playerid][0],
Saved_Positions[playerid][1],
Saved_Positions[playerid][2]);
SetPlayerPos(playerid, 0.0, 0.0, 0.0); //change the position to what you want, this would teleport you to the middle of the map
return true;
}
pawn Код:
if(strcmp("/back", cmdtext, true) == 0 && Saved_Positions[playerid][2] != 0.0) //if no position is saved, the command wont work
{
SetPlayerPos(playerid, //Sets his position back
Saved_Positions[playerid][0],
Saved_Positions[playerid][1],
Saved_Positions[playerid][2]);
Saved_Positions[playerid][2] = 0.0;
return true;
}