22.08.2012, 14:24
Boas! Tipo eu tenho este comando
eu defeni max vehicles no topo bla bla bla,mas quando uso este comando ele reseta todos os carros,e depois cria os carros a minha frente em fileira. Mas eu queria que desse reset em todos os carros,e que depois o destrui-se,reset em todos e depois destruir todos os carros. Os carros são guardados nestes 2 ficheiros
e tambem da para "apagar" os carros dos ficheiros de la? Alguem me ajuda POR FAVOR? Dou REP até me doer a mão se for preciso
pawn Код:
if(strcmp(cmd, "/resetallvehicles", true) == 0)
{
if(PlayerInfo[playerid][mstrvbcAdmin] < 1338)
return SendClientMessage(playerid, COLOR_WHITE, "Não és Administrador.");
new i,
Float:distance = 6.0,
Float:metres = distance;
for(; i < sizeof(DynamicCars); i++, metres += distance)
{
GetPlayerPos(playerid, DynamicCars[i][CarX], DynamicCars[i][CarY], DynamicCars[i][CarZ]);
new Float:a;
GetPlayerFacingAngle(playerid, a);
DynamicCars[i][CarColor1] = -1;
DynamicCars[i][CarColor2] = -1;
DynamicCars[i][FactionCar] = 255;
DynamicCars[i][CarType] = 0;
DynamicCars[i][CarAngle] = a;
DynamicCars[i][CarModel] = 510; //Bicicleta
DynamicCars[i][CarX] += (metres * floatsin(-a, degrees));
DynamicCars[i][CarY] += (metres * floatcos(-a, degrees));
DynamicCars[i][Neon] = 0;
DestroyVehicle(i);
CreateVehicle(DynamicCars[i][CarModel],DynamicCars[i][CarX],DynamicCars[i][CarY],DynamicCars[i][CarZ],DynamicCars[i][CarAngle],DynamicCars[i][CarColor1],DynamicCars[i][CarColor2], -1);
Fuel[i] = GasMax;
EngineStatus[i] = 0;
VehicleLocked[i] = 0;
CarWindowStatus[i] = 1; //1 = up, 0 = down.
}
SaveDynamicCars();
return 1;
}
pawn Код:
//=====================================================[DYNAMIC CAR SYSTEM]=====================================================
public OnVehicleSpawn(vehicleid)
{
LoadComponents(vehicleid);
return 1;
}
public LoadDynamicCars()
{
new arrCoords[10][64];
new strFromFile2[256];
new string[128];
new File: file = fopen("CRP_Scriptfiles/Cars/carspawns.cfg", io_read);
if (file)
{
new idx;
while (idx < sizeof(DynamicCars))
{
fread(file, strFromFile2);
split(strFromFile2, arrCoords, '|');
DynamicCars[idx][CarModel] = strval(arrCoords[0]);
DynamicCars[idx][CarX] = floatstr(arrCoords[1]);
DynamicCars[idx][CarY] = floatstr(arrCoords[2]);
DynamicCars[idx][CarZ] = floatstr(arrCoords[3]);
DynamicCars[idx][CarAngle] = floatstr(arrCoords[4]);
DynamicCars[idx][CarColor1] = strval(arrCoords[5]);
DynamicCars[idx][CarColor2] = strval(arrCoords[6]);
DynamicCars[idx][FactionCar] = strval(arrCoords[7]);
DynamicCars[idx][CarType] = strval(arrCoords[8]);
DynamicCars[idx][Neon] = strval(arrCoords[9]);
new vehicleid = CreateVehicle(DynamicCars[idx][CarModel],DynamicCars[idx][CarX],DynamicCars[idx][CarY],DynamicCars[idx][CarZ],DynamicCars[idx][CarAngle],DynamicCars[idx][CarColor1],DynamicCars[idx][CarColor2], -1);
if(vehicleid <= 10)
{
format(string, sizeof(string), "0%d-%s-%d", vehicleid, MatriculasNames[vehicleid], vehicleid+15);
SetVehicleNumberPlate(vehicleid,string);
}
else if(vehicleid <= 100 && vehicleid >= 10)
{
format(string, sizeof(string), "%d-%s-%d", vehicleid, MatriculasNames[vehicleid], vehicleid+15);
SetVehicleNumberPlate(vehicleid,string);
}
else
{
format(string, sizeof(string), "%d-%s-%d", vehicleid-100, MatriculasNames[vehicleid], vehicleid-85);
SetVehicleNumberPlate(vehicleid,string);
}
idx++;
}
fclose(file);
}
return 1;
}
public SaveDynamicCars()
{
new idx;
new File: file2;
while (idx < sizeof(DynamicCars))
{
new coordsstring[512];
format(coordsstring, sizeof(coordsstring), "%d|%f|%f|%f|%f|%d|%d|%d|%d|%d\n",
DynamicCars[idx][CarModel],
DynamicCars[idx][CarX],
DynamicCars[idx][CarY],
DynamicCars[idx][CarZ],
DynamicCars[idx][CarAngle],
DynamicCars[idx][CarColor1],
DynamicCars[idx][CarColor2],
DynamicCars[idx][FactionCar],
DynamicCars[idx][CarType],
DynamicCars[idx][Neon]);
if(idx == 0)
{
file2 = fopen("CRP_Scriptfiles/Cars/carspawns.cfg", io_write);
}
else
{
file2 = fopen("CRP_Scriptfiles/Cars/carspawns.cfg", io_append);
}
fwrite(file2, coordsstring);
idx++;
fclose(file2);
}
return 1;
}
public LoadCars()
{
new arrCoords[26][64];
new strFromFile2[256];
new File: file = fopen("CRP_Scriptfiles/Cars/carstand.cfg", io_read);
if (file)
{
new idx= 0;
while (idx < sizeof(Car))
{
fread(file, strFromFile2);
split(strFromFile2, arrCoords, '|');
strmid(Car[idx][Owner], arrCoords[0], 0, strlen(arrCoords[0]), 255);
Car[idx][CarModel] = strval(arrCoords[1]);
Car[idx][CarID] = strval(arrCoords[2]);
Car[idx][ParkX] = floatstr(arrCoords[3]);
Car[idx][ParkY] = floatstr(arrCoords[4]);
Car[idx][ParkZ] = floatstr(arrCoords[5]);
Car[idx][ParkAngle] = floatstr(arrCoords[6]);
Car[idx][CarColor1] = strval(arrCoords[7]);
Car[idx][CarColor2] = strval(arrCoords[8]);
Car[idx][Owned] = strval(arrCoords[9]);
Car[idx][Materials] = strval(arrCoords[10]);
Car[idx][cCocaina] = strval(arrCoords[11]);
Car[idx][cHeroina] = strval(arrCoords[12]);
Car[idx][cExtasy] = strval(arrCoords[13]);
Car[idx][cErva] = strval(arrCoords[14]);
Car[idx][cPolen] = strval(arrCoords[15]);
Car[idx][Locked] = strval(arrCoords[16]);
Car[idx][Sell] = strval(arrCoords[17]);
strmid(Car[idx][Matricula], arrCoords[18], 0, strlen(arrCoords[18]), 255);
Car[idx][Matriculed] = strval(arrCoords[19]);
strmid(Car[idx][GuardaArmas1], arrCoords[20], 0, strlen(arrCoords[20]), 255);
strmid(Car[idx][GuardaArmas2], arrCoords[21], 0, strlen(arrCoords[21]), 255);
strmid(Car[idx][GuardaArmas3], arrCoords[22], 0, strlen(arrCoords[22]), 255);
strmid(Car[idx][GuardaArmas4], arrCoords[23], 0, strlen(arrCoords[23]), 255);
strmid(Car[idx][GuardaArmas5], arrCoords[24], 0, strlen(arrCoords[24]), 255);
Car[idx][Neon] = strval(arrCoords[25]);
CreateVehicle(Car[idx][CarModel],Car[idx][ParkX],Car[idx][ParkY],Car[idx][ParkZ],Car[idx][ParkAngle],Car[idx][CarColor1],Car[idx][CarColor2], -1);
if(Car[idx][Owned]== 1)
{
printf("[CARS:] CarID:%d Dono:%s Matricula:%s",idx,Car[idx][Owner], Car[idx][Matricula]);
}
if(Car[idx][Matriculed]== 1)
{
new string[128];
format(string, sizeof(string), "%s", Car[idx][Matricula]);
SetVehicleNumberPlate(idx,string);
}
idx++;
}
fclose(file);
}
return 1;
}
public SaveCars()
{
new idx;
new File: file2;
while (idx < sizeof(Car))
{
new coordsstring[256];
format(coordsstring, sizeof(coordsstring), "%s|%d|%d|%f|%f|%f|%f|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%s|%d|%s|%s|%s|%s|%s|%d\n",
Car[idx][Owner],
Car[idx][CarModel],
Car[idx][CarID],
Car[idx][ParkX],
Car[idx][ParkY],
Car[idx][ParkZ],
Car[idx][ParkAngle],
Car[idx][CarColor1],
Car[idx][CarColor2],
Car[idx][Owned],
Car[idx][Materials],
Car[idx][cCocaina],
Car[idx][cHeroina],
Car[idx][cExtasy],
Car[idx][cErva],
Car[idx][cPolen],
Car[idx][Locked],
Car[idx][Sell],
Car[idx][Matricula],
Car[idx][Matriculed],
Car[idx][GuardaArmas1],
Car[idx][GuardaArmas2],
Car[idx][GuardaArmas3],
Car[idx][GuardaArmas4],
Car[idx][GuardaArmas5],
Car[idx][Neon]);
if(idx == 0)
{
file2 = fopen("CRP_Scriptfiles/Cars/carstand.cfg", io_write);
}
else
{
file2 = fopen("CRP_Scriptfiles/Cars/carstand.cfg", io_append);
}
fwrite(file2, coordsstring);
idx++;
fclose(file2);
}
return 1;
}