youll need to use the sscanf2 include for this.
pawn Код:
CMD:savecar(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 5)
{
if (isnull(params))
{
SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/savecar [description]\"");
}
else
{
new string[128];
new Float:x, Float:y, Float:z, Float:a;
new vID,vModel;
vID = GetPlayerVehicleID(playerid);
vModel=GetVehicleModel(vID);
GetVehiclePos(vID, x, y, z);
GetVehicleZAngle(vID, a);
new File:file = fopen("carpositions.txt",io_append);
format(string,sizeof(string), "%d %f %f %f %f -1 -1 //%s \r\n",vModel, x,y,z,a,params);
fwrite(file,string);
fclose(file);
SendClientMessage(playerid,0xFFFFFFFF,"Car Position Saved");
}
}
return 1;
}
that saves it then add this stock in your gamemode and call in on gm_init
pawn Код:
stock LoadVehicleFile(const filename[])
{
new File:file_ptr;
new line[256];
new vehicletype;
new Float:SpawnX,Float:SpawnY,Float:SpawnZ,Float: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, SpawnX,SpawnY,SpawnZ,SpawnRot,Color1,Color2))
{
AddStaticVehicleEx(vehicletype,SpawnX,SpawnY,SpawnZ,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;
}
now call it in gamemode
pawn Код:
public OnGameModeInit()
{
SetGameModeText("Custom-Code GTA Server");
LoadVehicleFile("carpositions.txt");
}
i converted this from my ycmd hopfuly it works