SA-MP Forums Archive
Police Special Car - 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: Police Special Car (/showthread.php?tid=608749)



Police Special Car - rishabh - 04.06.2016

I want a normal car like infernus in police faction too. For that what should i do so that in that specific infernus(police faction's) only cops can enter. Like in "police rancher" i had simply defined that if someone who not belongs to cop faction, try to enter in car with "model id of police rancher" then it prevent it from entering. But in case of infernus I can't do that because the model id of police infernus and normal infernus are same!. What should i do?


Re: Police Special Car - Luicy. - 04.06.2016

PHP код:
new policeInfernus[MAX_VEHICLES];

//in gamemodeinit
policeInfernus[1] = CreateVehicle(...);

//in the check.
if(vehicleid == policeInfernus[1])
... 



Re: Police Special Car - rishabh - 05.06.2016

Thanks Meller. It works but not when "new policeInfernus[MAX_VEHICLES];" and using various types as policeInfernus[1] and so on. It stores "0" at place of vehicle id in policeInfernus[1].

When i did this > "new policeInfernus;" and store vehicle id in this, it stores the correct vehicle id. But i think it will be a big task to create these seperate variables for each car. Why "new policeInfernus[MAX_VEHICLES];" is not working?


Re: Police Special Car - CSLangdale - 05.06.2016

Код:
new LEOveh[19];
Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
	new vehicleid = GetPlayerVehicleID(playerid);

	switch(newstate)
	{
	case PLAYER_STATE_DRIVER:
	    {
     		if(vehicleid >= LEOveh[0] && LEOveh[18] >= vehicleid)
			{
			    if(PlayerInfo[playerid][Faction] != 1)
				{
				    SendClientMessage(playerid, COLOR_WHITE, "You are not a Police Office and do not have the keys for this vehicle");
					RemovePlayerFromVehicle(playerid);
				}
			}
// Add to gamemodeinit
Код:
	LEOveh[0] = CreateVehicle(561,1530.7141,-1644.6859,5.5957,180.2718,0,0,2000); // Stratum
	LEOveh[1] = CreateVehicle(560,1534.6045,-1644.6677,5.5957,180.2718,0,0,2000); // Sultan
	LEOveh[2] = CreateVehicle(560,1538.8458,-1644.6477,5.5957,180.2718,0,0,2000); // Sultan
	LEOveh[3] = CreateVehicle(561,1526.9716,-1644.7039,5.5957,180.2718,0,0,2000); // Stratum
	LEOveh[4] = CreateVehicle(490,1528.9757,-1687.9369,6.0183,269.7481,0,0,2000); // F.B.I Rancher
	LEOveh[5] = CreateVehicle(490,1528.9938,-1683.8076,6.0182,269.7481,0,0,2000); // F.B.I Rancher
	LEOveh[6] = CreateVehicle(596,1544.8733,-1668.2935,5.6122,90.2933,1,0,2000); // L.S.P.D Cruiser
	LEOveh[7] = CreateVehicle(596,1544.8948,-1672.4688,5.6122,90.2933,1,0,2000); // L.S.P.D Cruiser
	LEOveh[8] = CreateVehicle(596,1544.9147,-1676.3838,5.6122,90.2933,1,0,2000); // L.S.P.D Cruiser
	LEOveh[9] = CreateVehicle(596,1544.9349,-1680.3630,5.6122,90.2933,1,0,2000); // L.S.P.D Cruiser
	LEOveh[10] = CreateVehicle(596,1544.9562,-1684.4753,5.6122,90.2933,1,0,2000); // L.S.P.D Cruiser
try adding that then it will kick them if they are not police vehicles but make sure you change the numbers for your own needs


Re: Police Special Car - Dayrion - 05.06.2016

Quote:
Originally Posted by rishabh
Посмотреть сообщение
Thanks Meller. It works but not when "new policeInfernus[MAX_VEHICLES];" and using various types as policeInfernus[1] and so on. It stores "0" at place of vehicle id in policeInfernus[1].

When i did this > "new policeInfernus;" and store vehicle id in this, it stores the correct vehicle id. But i think it will be a big task to create these seperate variables for each car. Why "new policeInfernus[MAX_VEHICLES];" is not working?
For the first care it's policeInfernus[0], the second policeInfernus[1], etc...
policeInfernus can stop only 1 car, MAX_VEHICLE allow you to stock 2000 cars in a list.


Re: Police Special Car - rishabh - 06.06.2016

Quote:

For the first care it's policeInfernus[0], the second policeInfernus[1], etc...

Код HTML:
new policeInfernus[MAX_VEHICLES];

//in gamemodeinit
policeInfernus[0] = CreateVehicle(...);
policeInfernus[1] = CreateVehicle(...);
policeInfernus[2] = CreateVehicle(...);


//in the check.
if(vehicleid == policeInfernus[0],policeInfernus[1],policeInfernus[2])
...  
This too doesn't work, still stores '0' at place of 'vehicleid'.


Re: Police Special Car - Sew_Sumi - 06.06.2016

That line will not work.

Код:
if(vehicleid == policeInfernus[0]||vehicleid == policeInfernus[1]||vehicleid == policeInfernus[2])



Re: Police Special Car - rishabh - 06.06.2016

On doing this too... Its not working. They have stored '0' in it.


Re: Police Special Car - Sew_Sumi - 06.06.2016

Post up what code you've got currently.

Код:
if(vehicleid >= LEOveh[0] && LEOveh[18] >= vehicleid)
This doesn't work like this


Re: Police Special Car - CSLangdale - 06.06.2016

Yea it does work I use that in my script and it works perfectly for me