public OnVehicleSpawn(vehicleid) { new string[128]; for(new carror = 0; carror < MAX_CASAS; carror++) { format(string, sizeof(string), CASAS, carror); if(DOF2_FileExists(string)) { if(DOF2_GetInt(string, "Modelo") > 0) { if(DOF2_GetInt(string, "Id") == vehicleid) { AddVehicleComponent(vehicleid, DOF2_GetInt(string, "spoil")); AddVehicleComponent(vehicleid, DOF2_GetInt(string, "hood")); AddVehicleComponent(vehicleid, DOF2_GetInt(string, "roof")); AddVehicleComponent(vehicleid, DOF2_GetInt(string, "skirt")); AddVehicleComponent(vehicleid, DOF2_GetInt(string, "lamps")); AddVehicleComponent(vehicleid, DOF2_GetInt(string, "nitro")); AddVehicleComponent(vehicleid, DOF2_GetInt(string, "exaust")); AddVehicleComponent(vehicleid, DOF2_GetInt(string, "whells")); AddVehicleComponent(vehicleid, DOF2_GetInt(string, "stereo")); AddVehicleComponent(vehicleid, DOF2_GetInt(string, "hydraulic")); AddVehicleComponent(vehicleid, DOF2_GetInt(string, "FBUMPER")); AddVehicleComponent(vehicleid, DOF2_GetInt(string, "REAR_BUMPER")); AddVehicleComponent(vehicleid, DOF2_GetInt(string, "VENT_RIGHT")); AddVehicleComponent(vehicleid, DOF2_GetInt(string, "VENT_L")); AddVehicleComponent(vehicleid, DOF2_GetInt(string, "Bullbars")); if(DOF2_GetInt(string, "Tpjb") == 1) { ChangeVehiclePaintjob(vehicleid, DOF2_GetInt(string, "pjb")); } } } } }
if(!strcmp(cmdtext, "/respawnveiculos", true)) { if(!(IsPlayerAdmin(playerid))) return SendClientMessage(playerid, COR_VERMELHO, "(ERRO) Vocк nгo tem permissгo!"); for(new car = 1; car <= 268; car++) { if(IsVehicleEmpty(car)) SetVehicleToRespawn(car); } new Nome[MAX_PLAYER_NAME]; GetPlayerName(playerid, Nome, sizeof(Nome)); format(string, sizeof(string), "* O Administrador %s respawnou todos os veiculos sem uso.", Nome); SendClientMessageToAll(-1,string); return 1; }
stock IsVehicleEmpty(vehicleid) { for(new i=0; i<MAX_PLAYERS; i++) { if(IsPlayerInVehicle(i, vehicleid)) return 0; } return 1; }
enum VEICULOS{
MODELO,
COR,
ID
// BLA BLA
};
new E_VEICULOS[ MAX_VEHICLES ];
// Quando carregar:
E_VEHICULOS[id][ID] = CreateVehicle( ... );
E_VEHICULOS[id][ID] = COR_DO_VEICULO;
// Quando for usar para resetar:
for(new i, e = sizeof(E_VEICULOS); i ^e; ++i){
ChangeVehiclePaintjob(E_VEICULOS[i][ID], (E_VEICULOS[i][COR]);
}
#if defined MAX_VEHICLES
#undef MAX_VEHICLES
#define MAX_VEHICLES (100)
#endif
enum CarrosInfo
{
carID,
modelID,
cor_1,
cor_2
};
new Veiculos[MAX_VEHICLES][CarrosInfo];
public OnGameModeInit()
{
CarregarVeiculos();
for(new i; i < MAX_VEHICLES; i++)
{
Veiculos[i][carID] = CreateVehicle(Veiculos[i][modelID], 0.0, 0.0, 0.0, 180, Veiculos[i][cor_1], Veiculos[i][cor_2], -1);
}
return 1;
}
public OnGameModeExit()
{
SalvarVeiculos();
return 1;
}
stock CarregarVeiculos()
{
new destino[15];
for(new i; i < MAX_VEHICLES; i++)
{
format(destino, sizeof(destino), "/Carros/%d.ini", i);
if(!DOF2_Exists(destino)) return 1;
Veiculos[i][modelID] = DOF2_GetInt(destino, "Modelo");
Veiculos[i][cor_1] = DOF2_GetInt(destino, "Cor_1");
Veiculos[i][cor_1] = DOF2_GetInt(destino, "Cor_2");
}
return 1;
}
stock SalvarVeiculos()
{
new destino[15];
for(new i; i < MAX_VEHICLES; i++)
{
format(destino, sizeof(destino), "/Carros/%d.ini", i);
if(!DOF2_Exists(destino)) return 1;
DOF2_SetInt(destino, "Modelo", Veiculos[i][modelID]);
DOF2_SetInt(destino, "Cor_1", Veiculos[i][cor_1]);
DOF2_SetInt(destino, "Cor_2", Veiculos[i][cor_1]);
}
return 1;
}
Foi exatamente oque eu falei, porйm seu cуdigo irб carregar apenas 100 veнculos e, se tiver outro sistema que use a diretiva "MAX_VEHICLES" irб bugar.
Aconselho seguir a minha dica, utilizando "sizeof" para verificar se a matriz estб NULA/VAZIA. |