COMMAND:ulist(playerid, params[])
{
new str[256], name[MAX_PLAYER_NAME], count = 0;
SendClientMessage(playerid, UNITED_COLOR, "***LSPD United Members Online***");
for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
{
if(united[i] > 0)
{
GetPlayerName(i, name, sizeof(name));
format(str, 256, "%s %s(%d)", GetUnitedFromLevel(i), name, i);
SendClientMessage(playerid, UNITED_COLOR, str);
count++;
}
}
if(count == 0)
{
SendClientMessage(playerid, UNITED_COLOR, "There are currently no LSPD United members online.");
}
return 1;
}
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.
|
in_array(needle, const haystack[], size = sizeof haystack, &index = 0)
{
for(new i; i < size; i++)
{
if(haystack[i] == needle)
{
index = i;
return true;
}
}
return false;
}
COMMAND:ulist(playerid, params[])
{
new str[256], name[MAX_PLAYER_NAME], count = 0;
SendClientMessage(playerid, UNITED_COLOR, "***LSPD United Members Online***");
static const SKINS_LIST[] = {0, 1, 2, 3};
for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
{
if(united[i] > 0 && in_array(GetPlayerSkin(i), SKINS_LIST))
{
GetPlayerName(i, name, sizeof(name));
format(str, 256, "%s %s(%d)", GetUnitedFromLevel(i), name, i);
SendClientMessage(playerid, UNITED_COLOR, str);
count++;
}
}
if(count == 0)
{
SendClientMessage(playerid, UNITED_COLOR, "There are currently no LSPD United members online.");
}
return 1;
}
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++; }