#include <a_samp>
enum PlayerPosition
{
Float:XPos,//Creating the x array. In a float, because it's the x position.
Float:YPos,//Creating the y array. In a float, because it's the z position.
Float:ZPos,//Creating the z array. In a float, because it's the z position.
Float:PAngle,//Creating the PAngle array. In a float, because it's the angle.
SavedPosition//It's just a simply int array. So we can check if the player has already /s, so he won't go to 0,0,0
}
new PPosition[MAX_PLAYERS][PlayerPosition];//Instead of creating indevidualy all the vars, lets just create them all in 1. Thats why we created that enum.
PPosition[playerid][SavedPosition] = 0;
if(strcmp(cmdtext,"/s") == 0) //Comparing the command string to /s and checking if they match
{
new Float:x,Float:y,Float:z,Float:angle;//Creating the vars, so we can store our info.
if(IsPlayerInAnyVehicle(playerid))//Checking if the player is in any vehicle, so we can retrieve the vehicle's position
{
GetVehiclePos(GetPlayerVehicleID(playerid),x,y,z);//Storing the vehicle's position into x,y,z;
GetVehicleZAngle(GetPlayerVehicleID(playerid),angl e);//Storing the vehicle's angle to "angle".
PPosition[playerid][XPos] = x;//Storing the x value to XPos array, where we previously created.
PPosition[playerid][YPos] = y;//Storing the y value to YPos array, where we previously created.
PPosition[playerid][ZPos] = z;//Storing the z value to ZPos array, where we previously created.
PPosition[playerid][PAngle] = angle;//Storing the angle value to PAngle array, where we previously created.
SendClientMessage(playerid,-1,"Position saved! Type /l to load!");
}
else
{
GetPlayerPos(playerid,x,y,z);//Storing the player's position into x,y,z;
GetPlayerFacingAngle(playerid,angle);//Storing the player's angle to "angle".
PPosition[playerid][XPos] = x;//Storing the x value to XPos array, where we previously created.
PPosition[playerid][YPos] = y;//Storing the y value to YPos array, where we previously created.
PPosition[playerid][ZPos] = z;//Storing the z value to ZPos array, where we previously created.
PPosition[playerid][PAngle] = angle;//Storing the angle value to PAngle array, where we previously created.
SendClientMessage(playerid,-1,"Position saved! Type /l to load!");
}
PPosition[playerid][SavedPosition] = 1;
return 1;
}
if(strcmp(cmdtext,"/l") == 0)
{
if(PPosition[playerid][SavedPosition] == 0) return SendClientMessage(playerid,-1,"You don't have any position saved! (/s)");
if(IsPlayerInAnyVehicle(playerid))//Checking if the player is in any vehicle, so we can retrieve the vehicle's position
{
SetVehiclePos(GetPlayerVehicleID(playerid),PPositi on[playerid][XPos],PPosition[playerid][YPos],PPosition[playerid][ZPos]);//Setting the vehicle's position with the stored one.
SetVehicleZAngle(GetPlayerVehicleID(playerid),PPos ition[playerid][PAngle]);//Setting the vehicle's Z angle with the stored one.
SendClientMessage(playerid,-1,"Position loaded!");
}
else
{
SetPlayerPos(playerid,PPosition[playerid][XPos],PPosition[playerid][YPos],PPosition[playerid][ZPos]);//Setting the player's position with the stored one.
SetPlayerFacingAngle(playerid,PPosition[playerid][PAngle]);//Setting the player's facing angle with the stored one.
SendClientMessage(playerid,-1,"Position loaded!");
}
return 1;
}
Simple, but hard;
P.S.: I just found out that you're a fucking krawd; Would you stop lying to me?!?! |