02.01.2012, 14:12
How do I delete all of the unused vehicles on a RP server? I'll give a +1 reputation.
if(strcmp(cmd, "/respawncars", true) == 0) { if(IsPlayerConnected(playerid)) { new vehcount = 0; for(new i = 0; i < sizeof(Cars); i++) { if(CreatedCars[i] != INVALID_VEHICLE_ID) { vehcount++; gDestroyVehicles[Cars[i]] = 1; SetVehiclesToRespawn(Cars[i]); Cars[i] = INVALID_VEHICLE_ID; } } return 1; } return 1; }
CMD:rac(playerid, params[]) { if(!IsAdmin(playerid, 1)) return SendClientMessage(playerid, COLOR_RED, "You are not admin!"); new bool:vehicleused[MAX_VEHICLES]; for(new i=0; i < MAX_PLAYERS; i++) { if(IsPlayerConnected(i) && IsPlayerInAnyVehicle(i)) { vehicleused[GetPlayerVehicleID(i)] = true; } } for(new i=1; i < MAX_VEHICLES; i++) { if(!vehicleused[i]) { SetVehicleToRespawn(i); } } new msg[128]; format(msg, sizeof(msg), "Admin %s (%d) has respawned all unused vehicles", PlayerName(playerid), playerid); SendClientMessageToAll(COLOR_YELLOW, msg); return 1; }