Need help with vehicle save and load
#1

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

Save them on ''OnPlayerExitVehicle'' checking if the player was the driver?
Reply
#3

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
Reply
#4

BUMP
Reply
#5

BUMP
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)