SA-MP Forums Archive
admincar restrict by vehicle color - 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)
+--- Thread: admincar restrict by vehicle color (/showthread.php?tid=375565)



admincar restrict by vehicle color - s3rserii - 07.09.2012

hey guys,
i will restrict my vehicles by vehicle color.
If the vehilce color1 and color2 is black, than only a admin can enter the vehicle. other play will be removed outiside.

my code:
Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    new color1, color2;
    color1 = 0;
    color2 = 0;
    if(newstate == PLAYER_STATE_DRIVER)
	{
		if(GetVehicleColor(GetPlayerVehicleID(playerid), color1, color2))
	    {
	         if(SpielerInfo[playerid][pAdmin] < 6)
	         {
	             RemovePlayerFromVehicle(playerid);
	             SendClientMessage(playerid, red, "{FF0000}[SERVER] {FFFFFF}Only for Admin");
	         }
	    }
 	}
	return 1;
}
but it will not work, it remove alle player form all vehicles abov admin lvl 6.. i will it only vor vehicles witch is black colored. i dont know how to code this.

i use this include: https://sampforum.blast.hk/showthread.php?tid=235398

hope for help


Re: admincar restrict by vehicle color - XGh0stz - 07.09.2012

Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    new color1, color2;
    if(newstate == PLAYER_STATE_DRIVER)
	{
GetVehicleColor(GetPlayerVehicleID(playerid),color1,color2);// Should be Indented, but this sets color1 & color2
		if( color1==1 && color2==1 && SpielerInfo[playerid][pAdmin]<6 )
	    {
	             RemovePlayerFromVehicle(playerid);
	             SendClientMessage(playerid, red, "{FF0000}[SERVER] {FFFFFF}Only for Admin");
	    }
 	}
	return 1;
}
Kinda rushing this, but give this a shot, you must first store the colors of the car to color1 and color2 by using GetVehicleColor() and then check if those colors are black along with if the player is admin etc.


AW: admincar restrict by vehicle color - s3rserii - 07.09.2012

thx your are the best