Skin Check
#1

Hey,

I have a group, long story but I want to see a list of online members. But they must only appear if they use some skins, how (multiply skins)?
Let's just say that we will use skin ID 0, 1, 2 and 3 now
PHP код:
COMMAND:ulist(playeridparams[])
{
    new 
str[256], name[MAX_PLAYER_NAME], count 0;
    
SendClientMessage(playeridUNITED_COLOR"***LSPD United Members Online***");
    for(new 
0GetPlayerPoolSize(); <= ji++)
    {
        if(
united[i] > 0)
        {
            
GetPlayerName(inamesizeof(name));
            
format(str256"%s %s(%d)"GetUnitedFromLevel(i), namei);
            
SendClientMessage(playeridUNITED_COLORstr);
            
count++;
        }
    }
    if(
count == 0)
    {
        
SendClientMessage(playeridUNITED_COLOR"There are currently no LSPD United members online.");
    }
    return 
1;

Reply
#2

Put all skins in a constant array and then use in_array() to check whether the selected skin is in it. That function can probably be found in the useful functions topic.
Reply
#3

Quote:
Originally Posted by Vince
Посмотреть сообщение
Put all skins in a constant array and then use in_array() to check whether the selected skin is in it. That function can probably be found in the useful functions topic.
I'm dumb, I don't get you...
Reply
#4

Paste this function somewhere:
PHP код:
in_array(needle, const haystack[], size sizeof haystack, &index 0)
{
    for(new 
isizei++)
    {
        if(
haystack[i] == needle)
        {
            
index i;
            return 
true;
        }
    }
        
    return 
false;

Then alter the command like this:

PHP код:
COMMAND:ulist(playeridparams[])
{
    new 
str[256], name[MAX_PLAYER_NAME], count 0;
    
SendClientMessage(playeridUNITED_COLOR"***LSPD United Members Online***");
    static const 
SKINS_LIST[] = {0123};
    for(new 
0GetPlayerPoolSize(); <= ji++)
    {
        if(
united[i] > && in_array(GetPlayerSkin(i), SKINS_LIST))
        {
            
GetPlayerName(inamesizeof(name));
            
format(str256"%s %s(%d)"GetUnitedFromLevel(i), namei);
            
SendClientMessage(playeridUNITED_COLORstr);
            
count++;
        }
    }
    if(
count == 0)
    {
        
SendClientMessage(playeridUNITED_COLOR"There are currently no LSPD United members online.");
    }
    return 
1;

Reply
#5

Omg that's so complicated, can it be done easier?
Reply
#6

This is the easiest way it can get, sorry.
Reply
#7

Will do it then, thanks!
Reply
#8

Код:
if(GetPlayerSkin(i) == skinid) 
        { 
            GetPlayerName(i, name, sizeof(name)); 
            format(str, 256, "%s %s(%d)", GetUnitedFromLevel(i), name, i); 
            SendClientMessage(playerid, UNITED_COLOR, str); 
            count++;
        }
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)