Saving X,Y,Z.
#1

I have this command :
pawn Код:
if(strcmp(cmd,"/enterjourney",true)==0)
    {
        if(!IsPlayerInAnyVehicle(playerid))
        { //checks the player if he/she is in the vehicle.
            new Float:x, Float:y, Float:z, vehicle; //these Float gets the player position that where the player is present
            GetPlayerPos(playerid, x, y, z );//gets player position
            GetVehicleWithinDistance(playerid, x, y, z, 8.0, vehicle);//gets the player distance from the vehicle

            if(IsVehicleJourney(vehicle)){ //it checks the player vehicle is RC or not .
              DOO_SetPlayerPos(playerid, 2513.2939,-1729.1245,778.6371);
            }
        }
    }
But I can't understand for example, how to do /exitjourney, what function to use to save his position before he entered the journey ?
Reply
#2

I think you have to save the XYZ in a global variable (defined at the top), and dont use it for anything else. Then when you do /exitjourney, you use the XYZ you saved in the global variable to set his position back where he started.
Reply
#3

Can you give me an example ?
I have defined the XYZ in a global variable
pawn Код:
new exitjourney_x[MAX_PLAYERS];
new exitjourney_y[MAX_PLAYERS];
new exitjourney_z[MAX_PLAYERS];
How can I save them ? >.>
[ I'm a newbie. ]
Reply
#4

Add these some where.
pawn Код:
new Float:playerpos_x[MAX_PLAYERS];
new Float:playerpos_y[MAX_PLAYERS];
new Float:playerpos_z[MAX_PLAYERS];
new bool:isInJourney[MAX_PLAYERS];
Then add these commands, should work.
pawn Код:
if(strcmp(cmd,"/enterjourney",true)==0)
{
    if(isInJourney[playerid] == true) return SendClientMessage(playerid, 0x000000, "You are already inside the journey!");
    if(!IsPlayerInAnyVehicle(playerid))
    { //checks the player if he/she is in the vehicle.
        GetPlayerPos(playerid, playerpos_x[playerid], playerpos_y[playerid], playerpos_z[playerid]);//gets player position
        isInJourney[playerid] = true;
        GetVehicleWithinDistance(playerid, x, y, z, 8.0, vehicle);//gets the player distance from the vehicle

        if(IsVehicleJourney(vehicle)){ //it checks the player vehicle is RC or not .
            return DOO_SetPlayerPos(playerid, 2513.2939,-1729.1245,778.6371);
        }
        return 1;
    }
}

if(strcmp(cmd,"/exitjourney",true)==0)
{
    SetPlayerPos(playerid, playerpos_x[playerid], playerpos_y[playerid], playerpos_z[playerid]);
    isInJourney[playerid] = false;
    return 1;
}
Reply
#5

Thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)