help with 'format'
#1

Hi, i made admin function, which spawn and save vehicle:

Код:
else if(!strcmp(cmd, "/veh", true))
{
cmd=strtok(cmdtext,idx);
if(!strlen(cmd)) return SendClientMessage(playerid,0xAA3333AA,"UŻYCIE: /veh [nazwa] [id] [kolor 1] [kolor 2]");
new nazwa=strval(cmd);
cmd=strtok(cmdtext,idx);
if(!strlen(cmd)) return SendClientMessage(playerid,0xAA3333AA,"UŻYCIE: /veh [nazwa] [id] [kolor 1] [kolor 2]");
new car=strval(cmd);
cmd=strtok(cmdtext,idx);
if(!strlen(cmd)) return SendClientMessage(playerid,0xAA3333AA,"UŻYCIE: /veh [nazwa] [id] [kolor 1] [kolor 2]");
new color1=strval(cmd);
cmd=strtok(cmdtext,idx);
if(!strlen(cmd)) return SendClientMessage(playerid,0xAA3333AA,"UŻYCIE: /veh [nazwa] [id] [kolor 1] [kolor 2]]");
new color2=strval(cmd);

GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, Angle);
CreateVehicle(car, X, Y, Z , Angle, color1, color2, 300);
		
new File:pos=fopen("cars.txt", io_append);
new zapisz[256];
format(zapisz, 256, "%s = CreateVehicle(%d, %f, %f, %f, %f, %d, %d, 300);\r\n", nazwa, car, X, Y, Z, Angle, color1, color2);
fwrite(pos, zapisz);
fclose(pos);

return 1;
}
, but (red) part
<format(zapisz, 256, "%s = CreateVehicle(%d, %f, %f, %f, %f, %d, %d, 300);\r\n", nazwa, car, X, Y, Z, Angle, color1, color2);>
is not working. Vehicles spawn, but file cars.txt is ex:

Код:
 = CreateVehicle(500, 0.000000, 0.000000, 0.000000, 0.000000, 3, 5, 300);
 = CreateVehicle(500, 0.000000, 0.000000, 0.000000, 0.000000, 3, 5, 300);
 = CreateVehicle(500, 0.000000, 0.000000, 0.000000, 0.000000, 3, 5, 300);
nazwa doesn't save, what's wrong with it?
Reply
#2

nazwa cant be a integer so u cant save as strval
Reply
#3

oh, thanks, it works
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)