How to saving vehicle condition
#1

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 ?
Reply
#2

I't would be something like
PHP код:
new engine[MAX_VEHICLES], lights[MAX_VEHICLES], alarm[MAX_VEHICLES], doors[MAX_VEHICLES], bonnet[MAX_VEHICLES], boot[MAX_VEHICLES], objective[MAX_VEHICLES]; 
PHP код:
public OnVehicleSpawn(vehicleid)
{
    
SetVehicleParamsEx(vehicleidengine[vehicleid], lights[vehicleid], alarm[vehicleid], doors[vehiceid], bonnet[vehicleid], boot[vehicleid], objective[vehicleid]);

Reply
#3

Quote:
Originally Posted by Shinja
Посмотреть сообщение
I't would be something like
PHP код:
new engine[MAX_VEHICLES], lights[MAX_VEHICLES], alarm[MAX_VEHICLES], doors[MAX_VEHICLES], bonnet[MAX_VEHICLES], boot[MAX_VEHICLES], objective[MAX_VEHICLES]; 
PHP код:
public OnVehicleSpawn(vehicleid)
{
    
SetVehicleParamsEx(vehicleidengine[vehicleid], lights[vehicleid], alarm[vehicleid], doors[vehiceid], bonnet[vehicleid], boot[vehicleid], objective[vehicleid]);

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 Код:
// SAVE
new panels, doors, lights, tires;
GetVehicleDamageStatus(vehicleid, panels, doors, lights, tires);
// Save "panels, doors, lights, tires"
pawn Код:
// LOAD
// Retrieve "panels, doors, lights, tires"
UpdateVehicleDamageStatus(vehicleid, panels, doors, lights, tires);
That's just some example code, guide yourself with that.
Reply
#4

Quote:
Originally Posted by Marricio
Посмотреть сообщение
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 Код:
// SAVE
new panels, doors, lights, tires;
GetVehicleDamageStatus(vehicleid, panels, doors, lights, tires);
// Save "panels, doors, lights, tires"
pawn Код:
// LOAD
// Retrieve "panels, doors, lights, tires"
UpdateVehicleDamageStatus(vehicleid, panels, doors, lights, tires);
That's just some example code, guide yourself with that.
My code, in public OnPlayerDisconnect(playerid, reason)
Код:
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);
				}
			}
		}
When player disconnect, The vehicle won't saving anything about health, damage status. So I have try this code and it doesn't work. Anything wrong here?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)