22.05.2013, 16:09
How can I remove all unoccupied vehicles?
CMD:despawnvehicles(playerid, params[])
{
new
Iterator:UnoccupiedVehicles<MAX_VEHICLES>;
foreach(new i : Player) Iter_Add(UnoccupiedVehicles, GetPlayerVehicleID(i));
for(new v = 0; v < MAX_VEHICLES; v++)
{
if(!Iter_Contains(UnoccupiedVehicles, v))
{
DestroyVehicle(v);
}
}
return 1;
}
if(strcmp(cmd, "/vehdespawn", true) == 0 || strcmp(cmd, "/rav", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pAdmin] < 1)
{
SendClientMessage(playerid, COLOR_GRAD1, " you are not authorized to use that command!");
return 1;
}
new bool:unwanted[CAR_AMOUNT];
for(new player=0; player<MAX_PLAYERS; player++)
{
if(IsPlayerInAnyVehicle(player)) { unwanted[GetPlayerVehicleID(player)]=true; }
}
for(new car = 1; car <= 268; car++)
{
if(!unwanted[car]) SetVehicleToRespawn(car);
}
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "Server action: "COL_RED"All unused vehicles were respawned by Administrator %s.", RemoveUnderScore(playerid));
SendClientMessageToAll(COLOR_RED,string);
}
return 1;
}
CMD:respawnunused(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "You need to be RCON admin to use this command! ");
else
{
new bool:vad[MAX_VEHICLES] = false;
for(new x=0; x < MAX_VEHICLES; x++)
{
for(new p = 0; p < MAX_PLAYERS; p++)
{
if(GetPlayerVehicleID(p) == x) vad[x] = true;
if(vad[x] == false) SetVehicleToRespawn(x);
}
}
}
return 1;
}
|
Oh yeah, let's keep giving pieces of code even though I already gave him a working one. Nice post count raising, guys! Keep it up.
|
|
Nice attitude, thumbs up for that, the code you gave him contains shit he won't even need.
What if he doesn't use Y_ITERATE? If he actually knew how to read/use that kind of code, why would he ask a question such as this one? Oh yeah, let's keep giving bullshit pieces of code even though he's a newbie scripter. Nice attitude, guys! Keep it up. |
|
YOU are an absolute fucking moron. Why don't you take your attitude and shove it right up your ass?
y_iterate is FOREACH, but it's the newest version. I use y_iterate because regular for loops are INEFFICIENT AS HELL. If he's a new scripter, he should be learning the NEW stuff, not the inefficient bullshit you and everyone else in this topic posted. Go get a little experience under your belt before you go off on me and make a complete fool out of yourself you moron. EDIT: Whoever the hell -repped me with the reason "that's not even correct" you need to go learn a bit. |
|
Remove all unused... 23/05/2013 12:42 AM no u. |
|
Originally Posted by NicholasA
Код:
CMD:respawnunused(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "You need to be RCON admin to use this command! ");
else
{
new bool:vad[MAX_VEHICLES] = false;
for(new x=0; x < MAX_VEHICLES; x++)
{
for(new p = 0; p < MAX_PLAYERS; p++)
{
if(GetPlayerVehicleID(p) == x) vad[x] = true;
if(vad[x] == false) SetVehicleToRespawn(x);
}
}
}
return 1;
}
=) |