#1

I got a /vips cmd to show online vips
But if i am not a vip and other player is vip it doesnt show him and say There are no VIP's online!
If i am a vip it show both of us
Any help please
Here is the code



Код:
CMD:vips(playerid, params[])
{
    new string[128], acount = 0, Name[MAX_PLAYER_NAME];
    foreach(Player, i) {
        if(IsPlayerVipMember(playerid)) {
            acount++;
        }
    }
    if(acount > 0) {
        SendClientMessage(playerid, COLOR_GREEN, "----------Online VIP's----------");
        foreach(Player, i) {
            if(IsPlayerVipMember(playerid)) {
                GetPlayerName(i, Name, sizeof(Name));
                format(string, sizeof string, "VIP: %s", Name);
                SendClientMessage(playerid, COLOR_GREEN, string);
            }
        }
        format(string, sizeof string, "Total VIP's online: %d.", acount);
        SendClientMessage(playerid, -1, string);
    }
    else if(acount < 1) SendClientMessage(playerid, 0xD8D8D8FF, "There are no VIP's online!");
    return 1;
}
Reply
#2

PHP код:
CMD:vips(playeridparams[])
{
    new 
string[128], acount 0Name[MAX_PLAYER_NAME];
    foreach(
Playeri) {
        if(
IsPlayerVipMember(i)) {
            
acount++;
        }
    }
    if(
acount 0) {
        
SendClientMessage(playeridCOLOR_GREEN"----------Online VIP's----------");
        foreach(
Playeri) {
            if(
IsPlayerVipMember(i)) {
                
GetPlayerName(iNamesizeof(Name));
                
format(stringsizeof string"VIP: %s"Name);
                
SendClientMessage(playeridCOLOR_GREENstring);
            }
        }
        
format(stringsizeof string"Total VIP's online: %d."acount);
        
SendClientMessage(playerid, -1string);
    }
    else if(
acount 1SendClientMessage(playerid0xD8D8D8FF"There are no VIP's online!");
    return 
1;

You were checking if the player who typed /vips is a vip, you checked this GetPlayerPoolSize() (x) amount of times.
Reply
#3

Quote:
Originally Posted by Meller
Посмотреть сообщение
PHP код:
CMD:vips(playeridparams[])
{
    new 
string[128], acount 0Name[MAX_PLAYER_NAME];
    foreach(
Playeri) {
        if(
IsPlayerVipMember(i)) {
            
acount++;
        }
    }
    if(
acount 0) {
        
SendClientMessage(playeridCOLOR_GREEN"----------Online VIP's----------");
        foreach(
Playeri) {
            if(
IsPlayerVipMember(i)) {
                
GetPlayerName(iNamesizeof(Name));
                
format(stringsizeof string"VIP: %s"Name);
                
SendClientMessage(playeridCOLOR_GREENstring);
            }
        }
        
format(stringsizeof string"Total VIP's online: %d."acount);
        
SendClientMessage(playerid, -1string);
    }
    else if(
acount 1SendClientMessage(playerid0xD8D8D8FF"There are no VIP's online!");
    return 
1;

You were checking if the player who typed /vips is a vip, you checked this GetPlayerPoolSize() (x) amount of times.
If you failed to understand what he meant to say,

You used the "playerid" passed from the /vips command into the loop.
Therefore, you were checking the current person who typed /vips is a vip.
For eg: If I'm vip and I used the command, it would take my player id and the IsPlayerVipMember() check would be true.
This will make your acount = 1 and it will only show you as the vip in /vips.

Did you understand?

Please try and understand the code!
Reply
#4

Yeah i understand
thank you both now it working good
+rep both
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)