15.12.2014, 01:21
Sempre que eu uso o comando '/RespawnVeiculos' causa um lag no servidor causado pelo loop na
public OnVehicleSpawn alguйm pode me ajudar a resolver esse problema? Thank you
public OnVehicleSpawn alguйm pode me ajudar a resolver esse problema? Thank you
Код:
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; }