16.01.2011, 11:46
Ive been trying for hours to get a /save /load postion script working. It loads the players postion fine but if your in a car, it only teles the player and not the car. Please help!
new Float:pSavedPos[MAX_PLAYERS][4];
new bool:HasPlayerSavedPos[MAX_PLAYERS];
if(strcmp(cmdtext, "/save", true, 5) == 0)
{
new Float:X, Float:Y, Float:Z, Float:Ang;
if(IsPlayerInAnyVehicle(playerid))
{
new VehID = GetPlayerVehicleID(playerid);
GetVehiclePos(VehID, X, Y, Z);
GetVehicleZAngle(VehID, Ang);
}
else
{
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, Ang);
}
pSavedPos[playerid][0] = X;
pSavedPos[playerid][1] = Y;
pSavedPos[playerid][2] = Z;
pSavedPos[playerid][3] = Ang;
HasPlayerSavedPos[playerid] = true;
SendClientMessage(playerid, 0xdf0f00ff, "* Your position has been successfully saved!");
return 1;
}
if(strcmp(cmdtext, "/load", true, 5) == 0)
{
if(!HasPlayerSavedPos[playerid])
return SendClientMessage(playerid, 0xdf0f00ff, "* You didn't save any position yet!");
if(IsPlayerInAnyVehicle(playerid))
{
new VehID = GetPlayerVehicleID(playerid);
SetVehiclePos(VehID, pSavedPos[playerid][0], pSavedPos[playerid][1], pSavedPos[playerid][2]);
SetVehicleZAngle(VehID, pSavedPos[playerid][3]);
PutPlayerInVehicle(playerid, VehID, 0);
SendClientMessage(playerid, 0xdf0f00ff, "* You and your vehicle have been successfully teleported to the saved position!");
}
else
{
SetPlayerPos(playerid, pSavedPos[playerid][0], pSavedPos[playerid][1], pSavedPos[playerid][2]);
SetPlayerFacingAngle(playerid, pSavedPos[playerid][3]);
SendClientMessage(playerid, 0xdf0f00ff, "* You've been successfully teleported to the saved position!");
}
return 1;
}
I save the position and when i load it it says i never saved a positon
|