SA-MP Forums Archive
Help with RAC Command - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help with RAC Command (/showthread.php?tid=95541)



Help with RAC Command - Rick_Jones - 04.09.2009

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


Re: Help with RAC Command - brett7 - 04.09.2009

first of all

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

because there clearly connected if they use a cmd


Re: Help with RAC Command - Rick_Jones - 04.09.2009

Lol,

I thought i could take it out.

Any help with making only unused cars respawn?

Rick


Re: Help with RAC Command - Clavius - 04.09.2009

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.


Re: Help with RAC Command - Rick_Jones - 05.09.2009

Please define these:

IsAnyPlayerInVehicle
vehicleid

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



Rick


Re: Help with RAC Command - bubka3 - 05.09.2009

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;
}




Re: Help with RAC Command - Clavius - 05.09.2009

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!