Remove all unused vehicles.
#1

How can I remove all unoccupied vehicles?
Reply
#2

pawn Код:
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;
}
A little searching is all you had to do. You'll need y_iterate (part of the YSI library) to use this.
Reply
#3

Код:
  	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;
	}
Change;

if(PlayerInfo[playerid][pAdmin] < 1)

To;

if(PlayerInfo[playerid][pAdmin] < 0)

To make the command used by anyone, a higher number requires a higher admin level to use it
Reply
#4

pawn Код:
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;
}
Reply
#5

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.
Reply
#6

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
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.
Reply
#7

Quote:
Originally Posted by CreativityLacker
Посмотреть сообщение
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.
Reply
#8

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
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.
Quote:

Remove all unused... 23/05/2013 12:42 AM no u.

It's not inefficient bullshit, but only a scripter would know that. Not gonna argue anymore, reported your post.

Quote:
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;
}
Thanks! The other dude was putting in stuff i didnt understand
=)
...
Reply
#9

Quote:
Originally Posted by CreativityLacker
Посмотреть сообщение
It's not inefficient bullshit
It is. You're running a loop that's going to execute 2000 times. Inside of that loop, you're running ANOTHER loop that will execute 500 times (unless you have re-defined MAX_PLAYERS), however that MAX_PLAYERS loop also executes 2000 times.

No, that's not inefficient! Of course not! /endsarcasm

Quote:
Originally Posted by CreativityLacker
Посмотреть сообщение
but only a scripter would know that.
I've been doing this longer than you have.

Quote:
Originally Posted by CreativityLacker
Посмотреть сообщение
Not gonna argue anymore, reported your post.
I really don't care. I know I'm right in calling you an idiot. The reason that many people on this forum can't do anything for themselves is because of people like YOU giving them inefficient scripts and saying "they don't know that other stuff." If they don't know it they need to learn it over the older methods.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)