Save all cars
#1

Hey guys,

I tried to do a system, which save your Carposition, if u leave your Car.
I want to let save it into a File with Dini (All cars in a config-file).

But i don't know how I can do this. Can you help me?
Reply
#2

GetPlayerState
GetVehiclePos
GetVehicleZAngle
dini_FloatSet
Reply
#3

public OnPlayerExitVehicle(playerid, vehicleid)
{
SendClientMessage(playerid, COLOR_GREEN, "the position of the car has been saved.");
new string[128];
new Float, Float:y, Float:z, Float:a;
new vModel;
vModel=GetVehicleModel(vehicleid);
GetVehiclePos(vehicleid, x, y, z);
GetVehicleZAngle(vehicleid, a);
new File:file = fopen("/DayZ/Cars/Carfile.ini",io_append);
format(string,sizeof(string), "%d %f %f %f %f \r\n",vModel, x,y,z,a);
fwrite(file,string);
fclose(file);
return 1;
}


-----------------------
stock LoadVehicleFile(const filename[])
{
new File:file_ptr;
new line[256];
new vehicletype;
new Float:SpawnCarX,Float:SpawnCarY,Float:SpawnCarZ,Fl oat:SpawnRot;
new Color1, Color2;
new vehicles_loaded;

file_ptr = fopen(filename,filemode:io_read);
if(!file_ptr){ printf("%s Not Found!",filename);return 0;}
vehicles_loaded = 0;

while(fread(file_ptr,line,256) > 0)
{
if(!sscanf(line, "iffffii{S}", vehicletype, SpawnCarX,SpawnCarY,SpawnCarZ,SpawnRot,Color1,Colo r2))
{
AddStaticVehicleEx(vehicletype,SpawnCarX,SpawnCarY ,SpawnCarZ,SpawnRot,Color1,Color2,(15*60)); // respawn 15 minutes
vehicles_loaded++;
}
}
fclose(file_ptr);
printf("Loaded %d vehicles from: %s",vehicles_loaded,filename);
return vehicles_loaded;
}
---------------------------
public OnGameModeInit()
{
AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
LoadVehicleFile("/DayZ/Cars/Carfile.ini");
return 1;
}



But the cars didnt load.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)