02.02.2014, 21:42
pawn Код:
COMMAND:rc(playerid, params[])
{
SendAdminText(playerid, "/respawncarros", params);
if (APlayerData[playerid][PlayerLevel] < 3) return 0;
ResetarVeiculos();
new Msg[300], Name[24];
GetPlayerName(playerid, Name, sizeof(Name));
format(Msg, 300, "{FFFF00}O Adminstrador {FFFFFF}%s {FFFF00}resetou todos os veiculos desocupados.",Name);
SendClientMessageToAll(0xFF99AADD, Msg);
return true;
}
stock ResetarVeiculos()
{
static bool:TrailerEmUso[MAX_VEHICLES];
new Ciclo = 1;
for(new x = 1; x <= MAX_VEHICLES; x++)
{
switch(Ciclo)
{
case 1:
{
if(IsTrailerAttachedToVehicle(x))
{
TrailerEmUso[GetVehicleTrailer(x) - 1] = true;
}
}
case 2:
{
new bool:Ocupado;
for(new y = 0, z = GetMaxPlayers(); y != z; y++)
{
if(IsPlayerInVehicle(y, x))
{
Ocupado = true;
}
}
if(!Ocupado && !TrailerEmUso[x - 1])
{
SetVehicleToRespawn(x);
}
}
case 3:
{
TrailerEmUso[x - 1] = false;
}
}
if(x == MAX_VEHICLES && Ciclo < 3)
{
x = 0;
Ciclo++;
}
}
return true;
}