PDA

View Full Version : Need help with vehicle save and load


Puntukk
17/03/2012, 08:57 AM
Hello, i need help with vehicle's saving and loading. Here's my code:
public LoadVehicleData(playerid)
{
new file[128];
new name[MAX_PLAYER_NAME],filee[128];
GetPlayerName(playerid,name,sizeof(name));
format(filee,sizeof(filee),"saves/user/%s.ini",name);
format(file,sizeof(file),"saves/car/%i",dini_Int(filee,"ID"));
if(!fexist(file)) return;
new TempVeh;
TempVeh = Vehicle(dini_Int(file,"ID"),dini_Float(file,"pos_X"),dini_Float(file,"pos_Y"),dini_Float(file,"pos_Z"),dini_Float(file,"pos_A"),dini_Int(file,"Spalva"),dini_Int(file,"Spalva"));
vehicleDB[TempVeh][gas]=dini_Int(file,"Gas");
SetVehicleHealth(TempVeh,dini_Float(file,"Health"));
//if(!strcmp(dini_Get(file,"Owner"), name, true )) return;
vehicleDB[TempVeh][owner_name] = !strcmp(dini_Get(file,"Owner"), name, true);
vehicleDB[TempVeh][locked] = true;
playerDB[playerid][pcar]=TempVeh;
}
public SaveVehicleData(playerid,bool:simple)
{
new vehicleid = GetPlayerVehicleID(playerid);
new vehid = GetVehicleModel(vehicleid);
new Float:coo[4];
new file[128];
new name[MAX_PLAYER_NAME],filee[128];
GetPlayerName(playerid,name,sizeof(name));
format(filee,sizeof(filee),"saves/user/%s.ini",name);
format(file,sizeof(file),"saves/car/%i",vehid);
new string3[45],var[128];
if(!fexist(file)) dini_Create(file);
dini_Set(file,"Owner",name);
dini_IntSet(file,"ID",vehid);
GetVehiclePos(vehicleid,coo[0],coo[1],coo[2]);
dini_FloatSet(file,"pos_X",coo[0]);
dini_FloatSet(file,"pos_Y",coo[1]);
dini_FloatSet(file,"pos_Z",coo[2]);
GetVehicleZAngle(vehicleid,coo[3]);
dini_FloatSet(file,"pos_A",coo[3]);
dini_IntSet(file,"Gas",vehicleDB[vehicleid][gas]);
new Float:health;
GetVehicleHealth(vehicleid, health);
dini_FloatSet(file,"Health",health);
}
i tried to make that when you exit vehicle,it save's and than after server restart it loads.It save all cars in folder but i don't know how to make all folder vehicle's load..

i hope you understand me

GNGification
17/03/2012, 09:05 AM
Save them on ''OnPlayerExitVehicle'' checking if the player was the driver?

Puntukk
17/03/2012, 09:08 AM
Hmm, it's already here. I need to make all folder files load to server, becouse when you exit vehicle it save's but wont load to server after restart

Puntukk
18/03/2012, 06:39 AM
BUMP

Puntukk
30/03/2012, 10:14 AM
BUMP