CMD:respawnall(playerid,params[]) { new string[128]; if(APlayerData[playerid][PlayerLevel] < 4) return SendClientMessage(playerid, 0xFF0000FF, "Nu ai level neceasr!"); for(new car = 1; car <= 1999; car++) { if(IsVehicleEmpty(car)) SetVehicleToRespawn(car); } //GetPlayerName(playerid, sendername, sizeof(sendername)); format(string, sizeof(string), "Adminul %s a respawnat toate masinile.", pName(playerid)); SendClientMessageToAll(COLOR_ROYALBLUE,string); return 1; } stock IsVehicleEmpty(vehicleid) { for(new i=0; i<MAX_PLAYERS; i++) { if(IsPlayerInVehicle(i, vehicleid)) return 0; } return 1; }
CMD:respawnall(playerid,params[])
{
new string[145];
if(APlayerData[playerid][PlayerLevel] < 4)return SendClientMessage(playerid, 0xFF0000FF, "Nu ai level neceasr!");
for(new car=1;car<=1999;car++)
{
if(GetVehicleTrailer(car) > 0)continue;
if(IsVehicleEmpty(car)) SetVehicleToRespawn(car);
}
//GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "Adminul %s a respawnat toate masinile.", pName(playerid));
SendClientMessageToAll(COLOR_ROYALBLUE,string);
return 1;
}
CMD:respawnall(playerid,params[]) { new string[128], vmod; if(APlayerData[playerid][PlayerLevel] < 4) return SendClientMessage(playerid, 0xFF0000FF, "Nu ai level neceasr!"); for(new car = 0; car <= GetVehiclePoolSize(); car++) { vmod = GetVehicleModel(car); if(vmod == 435 || vmod == 450 || vmod == 584) // Check if it's a trailer { if(!IsTrailerAttached(car)) SetVehicleToRespawn(car) } else if(IsVehicleEmpty(car)) SetVehicleToRespawn(car); } //GetPlayerName(playerid, sendername, sizeof(sendername)); format(string, sizeof(string), "Adminul %s a respawnat toate masinile.", pName(playerid)); SendClientMessageToAll(COLOR_ROYALBLUE,string); return 1; } stock IsVehicleEmpty(vehicleid) { for(new i=0; i<MAX_PLAYERS; i++) { if(IsPlayerInVehicle(i, vehicleid)) return 0; } return 1; } stock IsTrailerAttached(trailerid) { for(new i = 0; i <= GetVehiclePoolSize(); i++) { if(GetVehicleTrailer(i) == trailerid) // Check if this trailer attached to another vehicle { return true; } } return false; }
That function just check if a vehicle has a trailer attached.
You need to loop through every vehicle to see if the trailer is attached. |
Well, he was saying that every vehicle (including attached trailers) were being respawned. So using that to check if it's attached to a vehicle won't make the trailer respawn.
|