26.07.2015, 10:19
pawn Код:
#define MAX_POSITION_SAVES 5
new Float:PlayerPos[MAX_PLAYERS][MAX_POSITION_SAVES][4],
bool:PlayerPosUsed[MAX_PLAYERS][MAX_POSITION_SAVES];
CMD:s(playerid, params[], help)
{
new id;
if(sscanf(params,"i",id)) return SendClientMessage(playerid,COLOR_RED,"Usage: /s [Number]");
new Float:x,Float:y,Float:z,Float:angle;
if(IsPlayerInAnyVehicle(playerid))
{
GetVehiclePos(GetPlayerVehicleID(playerid),x,y,z);
GetVehicleZAngle(GetPlayerVehicleID(playerid),angle);
}
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".
}
PlayerPos[playerid][id][0] = x;
PlayerPos[playerid][id][1] = y;
PlayerPos[playerid][id][2] = z;
PlayerPos[playerid][id][3] = angle;
PlayerPosUsed[playerid][id] = true;
SendClientMessage(playerid,0x22B998AA,"Position saved! Type /l to load!");
return 1;
}
CMD:l(playerid, params[], help)
{
new id;
if(sscanf(params,"i",id)) return SendClientMessage(playerid,COLOR_RED,"Usage: /l [Number]");
if(!PlayerPosUsed[playerid][id]) 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),PlayerPos[playerid][id][0],PlayerPos[playerid][id][1],PlayerPos[playerid][id][2]);//Setting the vehicle's position with the stored one.
SetVehicleZAngle(GetPlayerVehicleID(playerid),PlayerPos[playerid][id][3]);//Setting the vehicle's Z angle with the stored one.
}
else
{
SetPlayerPos(playerid,PlayerPos[playerid][id][0],PlayerPos[playerid][id][1],PlayerPos[playerid][id][2]);//Setting the player's position with the stored one.
SetPlayerFacingAngle(playerid,PlayerPos[playerid][id][3]);//Setting the player's facing angle with the stored one.
}
SendClientMessage(playerid,0x22B998AA,"Position loaded!");
return 1;
}

