Save all cars
#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


Messages In This Thread
Save all cars - by wuppiboy9 - 17.05.2013, 18:10
AW: Save all cars - by HurtLocker - 17.05.2013, 18:39
AW: Save all cars - by wuppiboy9 - 17.05.2013, 18:49

Forum Jump:


Users browsing this thread: 1 Guest(s)