Hm.. :o
#1

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?
Reply
#2

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")
Reply
#3

Thanks for explaning it but can you write it please.. I'm only a beginner
Reply
#4

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
Reply
#5

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
Reply
#6

Any idea?
Reply
#7

You gave yourself the solution. And use an array for all players
Reply
#8

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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)