17.01.2015, 13:59
Код:
public SaveDynamicCars()
{
new idx = 1;
while ( idx < sizeof(DynamicCars))
{
new SaveCars[256];
format(SaveCars,sizeof(SaveCars),"Sistema/Cars/All/%d.ini",idx);
new File: hFile = fopen(SaveCars, io_write);
if (hFile)
{
new var[32];
format(var, 32, "CarModel=%d\r\n", DynamicCars[idx][CarModel]);fwrite(hFile, var);
format(var, 32, "CarX=%f\r\n",DynamicCars[idx][CarX]);fwrite(hFile, var);
format(var, 32, "CarY=%f\r\n", DynamicCars[idx][CarY]);fwrite(hFile, var);
format(var, 32, "CarZ=%f\r\n",DynamicCars[idx][CarZ]);fwrite(hFile, var);
format(var, 32, "CarAngle=%f\r\n", DynamicCars[idx][CarAngle]);fwrite(hFile, var);
format(var, 32, "CarColor1=%d\r\n",DynamicCars[idx][CarColor1]);fwrite(hFile, var);
format(var, 32, "CarColor2=%d\r\n", DynamicCars[idx][CarColor2]);fwrite(hFile, var);
fclose(hFile);
}
}
return 1;
}
por exmplo tenho em "Sistema/Cars/All/1.ini" tenho a informзao do veiculo 1 etc..
o problema e quando o sistema grava faz 250 ficheiros ou seja 250 veiculos.
Mas eu quero que apenas grave os veiculos que eu criar com o seguinte comando
Код:
if(strcmp(cmd, "/spawncar", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if (PlayerInfo[playerid][pAdmin] < 10)
{
SendClientMessage(playerid, COLOR_GREY, "[Erro:] Nгo estб autorizado a usar este comando!");
return 1;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "[Usa:] /spawncar [carid] [color1] [color2]");
return 1;
}
new car;
car = strval(tmp);
if(car < 400 || car > 611) { SendClientMessage(playerid, COLOR_GREY, "[Erro:] O ID do veнculo nгo pode ser abaixo de 400 ou acima de 611"); return 1; }
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "[Usa:] /spawncar [carid] [color1] [color2]");
return 1;
}
new color1;
color1 = strval(tmp);
if(color1 < 0 || color1 > 126) { SendClientMessage(playerid, COLOR_GREY, "[Erro:] O ID da cor nгo pode ser inferior a 0 ou acima de 126"); return 1; }
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "[Usa:] /spawncar [carid] [color1] [color2]");
return 1;
}
new color2;
color2 = strval(tmp);
if(color2 < 0 || color2 > 126) { SendClientMessage(playerid, COLOR_GREY, "[Erro:] O ID da cor nгo pode ser inferior a 0 ou acima de 126"); return 1; }
new Float:scX,Float:scY,Float:scZ;
GetPlayerPos(playerid, scX,scY,scZ);
new carid = CreateVehicle(car, scX,scY,scZ, 0.0, color1, color2, 60000);
CreatedCars[CreatedCar] = carid;
CreatedCar ++;
format(string, sizeof(string), "[Info:] Vehicle %d spawned", carid);
SendClientMessage(playerid, COLOR_ADMINCMD, string);
}
return 1;
}

