Check if Player is in one of 4 Vehicle ids
#9

Quote:
Originally Posted by Maxandmov
Посмотреть сообщение
There's a simple way to deal with it. You can create an array of siren-only vehicles and check if it is in the list.
On my server, I used to check whether some skin I chose is faction only. That's how it looked like:

Код:
new DoCSkins[] =
{
	70, 71, 74, 280, 281, 282, 288, 284, 285, 283, 265, 266, 267, 274, 275, 276, 277, 278, 300,
	301, 302, 306, 307, 308, 309, 310, 311, 279
};

...

stock IsDoCSkin(id)
{
	for(new i = 0; i < sizeof(DoCSkins); i++)
	{
	    if(id == DoCSkins[i]) return 1;
	}
	return 0;
}
The check itself is done like that in my case:

Код:
if(IsDoCSkin(modelid))
{
   //Do your actions here
}
Reestablish the same structure for the checks you need, and it'll be fine.

P.S. This array is defined globally, don't initialise it in some functions or whatever.
P.P.S. imo this approach is comfortable since it simply requires you to add newly picked vehicles/skins/whatever you use it with into the array to then do the same check which requires no changes in its code.
I did it this way now:

Код:
IsAUndercoverVehicle(vehicleid)
{
	new vModel = GetVehicleModel(vehicleid);
    for(new i = 0; i < sizeof(UCAutos); i++)
    {
    	if(vModel == UCAutos[i]) return true;
	}
	return false;
}

Код:
if(!IsAUndercoverVehicle(vID))return SendClientMessage(playerid,COLOR_RED,"Du sitzt in keinem PD Premier/Sultan/Cheetah/Securicar");
Код:
new UCAutos[] = {
	428,
	415,
	560,
	426
};
Thanks, it works now
Reply


Messages In This Thread
Check if Player is in one of 4 Vehicle ids - by ImTobi - 14.04.2018, 14:28
Re: Check if Player is in one of 4 Vehicle ids - by std - 14.04.2018, 15:02
Re: Check if Player is in one of 4 Vehicle ids - by ImTobi - 14.04.2018, 15:07
Re: Check if Player is in one of 4 Vehicle ids - by ImTobi - 14.04.2018, 15:11
Re: Check if Player is in one of 4 Vehicle ids - by std - 14.04.2018, 15:40
Re: Check if Player is in one of 4 Vehicle ids - by ImTobi - 14.04.2018, 15:57
Re: Check if Player is in one of 4 Vehicle ids - by TitoRayne - 15.04.2018, 00:06
Re: Check if Player is in one of 4 Vehicle ids - by Maxandmov - 15.04.2018, 07:42
Re: Check if Player is in one of 4 Vehicle ids - by ImTobi - 15.04.2018, 08:57
Re: Check if Player is in one of 4 Vehicle ids - by Maxandmov - 15.04.2018, 20:04

Forum Jump:


Users browsing this thread: 3 Guest(s)