Grouping Skins -
Robert_Crawford - 12.03.2012
Hey, i know in the GF there was the
how was that defined, is there a better way?
Re: Grouping Skins -
MP2 - 12.03.2012
The simplest way is
pawn Код:
if(GetPlayerSkin(playerid) == ls cop skin id || GetPlayerSkin(playerid) == sf cop skin id || GetPlayerSkin(playerid) == lv cop skin id)
Re: Grouping Skins -
[ABK]Antonio - 12.03.2012
You don't need a fancy function for it, just add a new variable in the player info enum. If they're a cop, you set it to 1 or true, if not its false.
EDIT: if you really wanna check skins though, I'd recommend not using just an if statement but a switch
pawn Код:
stock IsACop(playerid)
{
switch(GetPlayerSkin(playerid))
{
case 280..288: return true;
case 165, 166: return true;
default: return false;
}
}
Re: Grouping Skins -
MP2 - 12.03.2012
It depends on whether he wants to know if the player is using a cop skin or if, like you say, they are a cop in the variables.
Re: Grouping Skins -
Robert_Crawford - 12.03.2012
Quote:
Originally Posted by MP2
The simplest way is
pawn Код:
if(GetPlayerSkin(playerid) == ls cop skin id || GetPlayerSkin(playerid) == sf cop skin id || GetPlayerSkin(playerid) == lv cop skin id)
|
Actually you mean your code would be?
pawn Код:
if(GetPlayerSkin(playerid) == 276 || 274 || 275 || 275 || 277 ||278 || 279)
Re: Grouping Skins -
MP2 - 12.03.2012
No. Read my post. GetPlayerSkin is used more than once.
Re: Grouping Skins -
[ABK]Antonio - 12.03.2012
Quote:
Originally Posted by Robert_Crawford
Actually you mean your code would be?
pawn Код:
if(GetPlayerSkin(playerid) == 276 || 274 || 275 || 275 || 277 ||278 || 279)
|
I would use a switch for that very reason. If you use an if statement it and have a lot of skins to go through it will gain length pretty fast. With an if statement you could do
case 274..279: return true;
It wont take as much space and will be more efficient
P.S.
What 274..279 means is 274-279. It checks 274, 275, 276, etc.
0..100 would be 0 to 100
default: is basically an else statement. if it isn't any of the cases, it will do the default action which is return false;
Re: Grouping Skins -
KingHual - 12.03.2012
Quote:
Originally Posted by Robert_Crawford
Actually you mean your code would be?
pawn Код:
if(GetPlayerSkin(playerid) == 276 || 274 || 275 || 275 || 277 ||278 || 279)
|
That's not a proper way to handle "If" statements.
Re: Grouping Skins -
MP2 - 12.03.2012
Quote:
Originally Posted by [ABK]Antonio
I would use a switch for that very reason. If you use an if statement it and have a lot of skins to go through it will gain length pretty fast. With an if statement you could do
case 274..279: return true;
It wont take as much space and will be more efficient
|
You are right, a switch statement would be a better alternative.
Re: Grouping Skins -
Robert_Crawford - 12.03.2012
pawn Код:
public RandomFireTimer()
{
new rndfire = random(sizeof(RandomFireSpawn));
{
AddFire(RandomFireSpawn[rndfire][0][0], RandomFireSpawn[rndfire][0][1], RandomFireSpawn[rndfire][0][2]);
AddFire(RandomFireSpawn[rndfire][1][0], RandomFireSpawn[rndfire][1][1], RandomFireSpawn[rndfire][1][2]);
AddFire(RandomFireSpawn[rndfire][2][0], RandomFireSpawn[rndfire][2][1], RandomFireSpawn[rndfire][2][2]);
AddFire(RandomFireSpawn[rndfire][3][0], RandomFireSpawn[rndfire][3][1], RandomFireSpawn[rndfire][3][2]);
}
if(GetPlayerSkin(playerid) == 276 || 274 || 275 || 275 || 277 ||278 || 279)
{
SendClientMessage(playerid,0xff000000," Dispatch: A Fire Has Been Located. Please Respond."
SendClientMessage(playerid,0xff000000," Dispatch: The Location Has Been Marked On Your GPS."
}
return 1;
}
This is what i'm wanting to do. Or is there a way i could check if a player is part of a faction in a fs?