22.01.2015, 15:31
Well, I want to save a vehicles health when the player despawns it.
Here is my code, but it just sets the vehicle health to 0.
If I'm trying to save the vehicles health completely wrong, could you show me how I might do it correctly?
Here is my code, but it just sets the vehicle health to 0.
pawn Код:
CMD:despawn(playerid, params[])
{
new string[128];
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
{
new veh = PlayerInfo[playerid][pVeh]; //This is their personal vehicles, vehicle ID
new Float:health;
GetVehicleHealth(veh, health);
if(vspawned[playerid] == 0) return SendClientMessage(playerid, COLOR_GREY, "You don't have a spawned car.");
if(health == 400) return SendClientMessage(playerid, COLOR_RED, "This vehicle is too damaged.");
PlayerInfo[playerid][pVehHealth] = 0; //This stores the vehicles health, so I set it to 0 here and below..
PlayerInfo[playerid][pVehHealth] += health; //I added on the whatever the current vehicle health was..
if(PlayerInfo[playerid][vModel] == 0) return SendClientMessage(playerid, COLOR_GREY, "You dont have vehicle in this slot.");
{
if(PlayerInfo[playerid][vModel])
{
DestroyVehicle(PlayerInfo[playerid][pVeh]);
}
}
v1spawned[playerid] = 0;
vspawned[playerid] = 0;
format(string, sizeof(string), "You have despawned your %s.", RVN(PlayerInfo[playerid][vModel]));
SendClientMessage(playerid, COLOR_YELLOW, string);
}
return 1;
}