26.08.2016, 13:39
I have an server, but when I spawn the vehicle, It's not saving vehicle Condition, It'll new all.
I want to saving this. How to do it ?
I want to saving this. How to do it ?
new engine[MAX_VEHICLES], lights[MAX_VEHICLES], alarm[MAX_VEHICLES], doors[MAX_VEHICLES], bonnet[MAX_VEHICLES], boot[MAX_VEHICLES], objective[MAX_VEHICLES];
public OnVehicleSpawn(vehicleid)
{
SetVehicleParamsEx(vehicleid, engine[vehicleid], lights[vehicleid], alarm[vehicleid], doors[vehiceid], bonnet[vehicleid], boot[vehicleid], objective[vehicleid]);
}
|
I't would be something like
PHP код:
PHP код:
|
// SAVE
new panels, doors, lights, tires;
GetVehicleDamageStatus(vehicleid, panels, doors, lights, tires);
// Save "panels, doors, lights, tires"
// LOAD
// Retrieve "panels, doors, lights, tires"
UpdateVehicleDamageStatus(vehicleid, panels, doors, lights, tires);
|
That's not very practical and you're not saving the damaged status, only the vehicle params. You don't need to keep the damage status stored in a variable since the vehicle damaged status is prone to change in any moment, we simply do the following:
Save up all these cells by saving the params values directly to the file/database. pawn Код:
pawn Код:
|
for(new i = 0; i < MAX_PLAYERVEHICLES; ++i)
{
if(PlayerVehicleInfo[playerid][i][pvSpawned] == 1)
{
if(PlayerVehicleInfo[playerid][i][pvId] != INVALID_PLAYER_VEHICLE_ID && IsVehicleInTow(PlayerVehicleInfo[playerid][i][pvId]))
{
new
iVehicleID = PlayerVehicleInfo[playerid][i][pvId];
new panels, doors, lights, tires, Float: health;
GetVehicleHealth(iVehicleID, health);
PlayerVehicleInfo[playerid][i][pvHealth] = health;
GetVehicleDamageStatus(iVehicleID, panels, doors, lights, tires);
PlayerVehicleInfo[playerid][i][pvPanels] = panels;
PlayerVehicleInfo[playerid][i][pvDoors] = doors;
PlayerVehicleInfo[playerid][i][pvLights] = lights;
PlayerVehicleInfo[playerid][i][pvTires] = tires;
DetachTrailerFromVehicle(GetPlayerVehicleID(playerid));
PlayerVehicleInfo[playerid][i][pvImpounded] = 1;
PlayerVehicleInfo[playerid][i][pvSpawned] = 0;
SetVehiclePos(PlayerVehicleInfo[playerid][i][pvId], 0, 0, 0); // Attempted desync fix
DestroyVehicle(PlayerVehicleInfo[playerid][i][pvId]);
PlayerVehicleInfo[playerid][i][pvId] = INVALID_PLAYER_VEHICLE_ID;
g_mysql_SaveVehicle(playerid, i);
}
}
}