30.10.2009, 16:38
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?
Any idea?
new Float:Saved_Positions[MAX_PLAYERS][3]; //MAX_PLAYERS (so we get one cell for each player) and 3 for X, Y and Z
//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;
}
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;
}