Saving X,Y,Z. - 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)
+--- Thread: Saving X,Y,Z. (
/showthread.php?tid=279819)
Saving X,Y,Z. -
Darnell - 29.08.2011
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 ?
Re: Saving X,Y,Z. -
Wesley221 - 29.08.2011
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.
Re: Saving X,Y,Z. -
Darnell - 29.08.2011
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. ]
Re: Saving X,Y,Z. -
Jack_Wilson - 29.08.2011
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;
}
Re: Saving X,Y,Z. -
Darnell - 29.08.2011
Thanks.