Help with RAC Command
#1

Sup,

I got a Respawn all cars command from a good friend of mine working on his script. And it respawns all the cars. Even if they have ppl in it. So can you guys fix that? I dont no how.

Heres the code:

Код:
			if(strcmp(cmdtext, "/respawnallcars", true) == 0 || strcmp(cmdtext, "/rac", true) == 0)
	{
	  if(IsPlayerConnected(playerid))
	  {
	    if(PlayerInfo[playerid][pAdminlevel] < 1)
			{
			  return 0;
			}
			for(new car = 1; car <= 268; car++)
			{
				SetVehicleToRespawn(car);
			}
			GetPlayerName(playerid, sendername, sizeof(sendername));
			format(string, sizeof(string), "[ADMIN] All cars respawned by %s.", sendername);
			SendClientMessageToAll(COLOR_RED,string);
		}
		return 1;
	}
Please Help,

Rick
Reply
#2

first of all

you dont need this: if(IsPlayerConnected(playerid))

because there clearly connected if they use a cmd
Reply
#3

Lol,

I thought i could take it out.

Any help with making only unused cars respawn?

Rick
Reply
#4

pawn Код:
if(strcmp(cmdtext, "/respawnallcars", true) == 0 || strcmp(cmdtext, "/rac", true) == 0)
    {
        if(PlayerInfo[playerid][pAdminlevel] < 1) return 0;
        for(new car = 0; car < MAX_VEHICLES; car++)
        {
            if (!IsAnyPlayerInVehicle(car)
            {
                SetVehicleToRespawn(car);
            }
        }
        GetPlayerName(playerid, sendername, sizeof(sendername));
        format(string, sizeof(string), "[ADMIN] All cars respawned by %s.", sendername);
        SendClientMessageToAll(COLOR_RED,string);
        return 1;
    }
// bottom
stock IsAnyPlayerInVehicle(vehicleid)
{
    for(new i = 0; i < MAX_PLAYERS; i++) if (IsPlayerInVehicle(vehicleid, i)) return 1;
    return 0;
}
This will do the trick.
Reply
#5

Please define these:

IsAnyPlayerInVehicle
vehicleid

Those are the only things, and it should work. Thanks



Rick
Reply
#6

Try This
Quote:

if(strcmp(cmdtext, "/respawnallcars", true) == 0 || strcmp(cmdtext, "/rac", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pAdminlevel] < 1)
{
return 0;
}
for(new car = 1; car <= 268; car++)
{
if (!IsAnyPlayerInVehicle(car))
{
SetVehicleToRespawn(car);
}
}
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "[ADMIN] All cars respawned by %s.", sendername);
SendClientMessageToAll(COLOR_RED,string);
}
return 1;
}

And at the bottom
Quote:

stock IsAnyPlayerInVehicle(vehicleid)
{
for(new i = 0; i < MAX_PLAYERS; i++) if (IsPlayerInVehicle(vehicleid, i)) return 1;
return 0;
}

Reply
#7

Quote:
Originally Posted by Rick_Jones
Please define these:

IsAnyPlayerInVehicle
vehicleid

Those are the only things, and it should work. Thanks



Rick
Scroll down, it's there under the command I posted!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)