Grouping Skins
#1

Hey, i know in the GF there was the
pawn Код:
If Is A Cop
how was that defined, is there a better way?
Reply
#2

The simplest way is

pawn Код:
if(GetPlayerSkin(playerid) == ls cop skin id || GetPlayerSkin(playerid) == sf cop skin id || GetPlayerSkin(playerid) == lv cop skin id)
Reply
#3

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;
    }
}
Reply
#4

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.
Reply
#5

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)
Reply
#6

No. Read my post. GetPlayerSkin is used more than once.
Reply
#7

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;
Reply
#8

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.
Reply
#9

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.
Reply
#10

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?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)