PDA

View Full Version : Saving X,Y,Z.


Darnell
29/08/2011, 09:21 AM
I have this command :

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 ?

Wesley221
29/08/2011, 09:25 AM
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.

Darnell
29/08/2011, 09:27 AM
Can you give me an example ?
I have defined the XYZ in a global variable

new exitjourney_x[MAX_PLAYERS];
new exitjourney_y[MAX_PLAYERS];
new exitjourney_z[MAX_PLAYERS];

How can I save them ? >.>
[ I'm a newbie. ]

Jack_Wilson
29/08/2011, 09:29 AM
Add these some where.

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.

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

Darnell
29/08/2011, 09:30 AM
Thanks.