/viplist - is there any thing wrong?
#1

PHP код:
CMD:viplist(playeridparams[])
{
    new 
count 0string[128];
    for(new 
0MAX_PLAYERS++)
    {
    if(
IsPlayerConnected(i))
    {
    if(
PlayerInfo[i][pVIP] >= 1)
    {
    
format(stringsizeof(string),"- {ffff00}%s{00ff00}| {0066ff}(ID:%s) {00ff00}| {996600}Bronze V.I.P\n"GetName(i), i);
    
count++;
    }
    if(
PlayerInfo[i][pVIP] >= 2)
    {
    
format(stringsizeof(string),"- {ffff00}%s {00ff00}| {0066ff}(ID:%d) {00ff00}| {adad85}Silver V.I.P\n"GetName(i), i);
    
count++;
    }
    if(
PlayerInfo[i][pVIP] >= 3)
    {
    
format(stringsizeof(string),"- {ffff00}%s {00ff00}| {0066ff}(ID:%d) {00ff00}| {e68a00}GOLD V.I.P\n"GetName(i), i);
    
count++;
    }
    }
    }
    if(
count == 0)
    {
    
ShowPlayerDialog(playerid18DIALOG_STYLE_MSGBOX,"{00ff00}Online V.I.P(s):",string"Ok""");
    }
    else
    {
    
ShowPlayerDialog(playerid18DIALOG_STYLE_MSGBOX,"{00ff00}Online V.I.P(s):","There isn't any online V.I.P""Ok""");
    }
    return 
1;

is there any error anything something not normal with this code? if so hope you correct it for me
Reply
#2

Why didn't you compile it? The compiler would have told you.. anyway, I don't see anything wrong.
Reply
#3

Yes, that's the point i have compiled it, no errors no warnings allthings is clean...

but when i types it it show

There isn't any online vip... while there are..
Reply
#4

Yes there is:
  • Consider my vip level is 4 then

    Код:
    if(PlayerInfo[i][pVIP] >= 1) 
        { 
        format(string, sizeof(string),"- {ffff00}%s{00ff00}| {0066ff}(ID:%s) {00ff00}| {996600}Bronze V.I.P\n", GetName(i), i); 
        count++; 
        } 
        if(PlayerInfo[i][pVIP] >= 2) 
        { 
        format(string, sizeof(string),"- {ffff00}%s {00ff00}| {0066ff}(ID:%d) {00ff00}| {adad85}Silver V.I.P\n", GetName(i), i); 
        count++; 
        } 
        if(PlayerInfo[i][pVIP] >= 3) 
        { 
        format(string, sizeof(string),"- {ffff00}%s {00ff00}| {0066ff}(ID:%d) {00ff00}| {e68a00}GOLD V.I.P\n", GetName(i), i); 
        count++; 
        }
    The all that if condition is true for me you can use else ifs in this case or use switch to check values of variable PlayerInfo[i][pVIP] rather putting ranges (cause that better in this case i believe).

  • Next thing is use of general looping mechanism use foreach with Player iterator instead.

  • Код:
    if(IsPlayerConnected(i)) 
        { 
        if(PlayerInfo[i][pVIP] >= 1) 
        { 
        format(string, sizeof(string),"- {ffff00}%s{00ff00}| {0066ff}(ID:%s) {00ff00}| {996600}Bronze V.I.P\n", GetName(i), i); 
        count++; 
        } 
        if(PlayerInfo[i][pVIP] >= 2) 
        { 
        format(string, sizeof(string),"- {ffff00}%s {00ff00}| {0066ff}(ID:%d) {00ff00}| {adad85}Silver V.I.P\n", GetName(i), i); 
        count++; 
        } 
        if(PlayerInfo[i][pVIP] >= 3) 
        { 
        format(string, sizeof(string),"- {ffff00}%s {00ff00}| {0066ff}(ID:%d) {00ff00}| {e68a00}GOLD V.I.P\n", GetName(i), i); 
        count++; 
        }
    That will reset the string variable use strcat to concatenate strings

  • Код:
    if(count == 0) 
        { 
        ShowPlayerDialog(playerid, 18, DIALOG_STYLE_MSGBOX,"{00ff00}Online V.I.P(s):",string, "Ok", ""); 
        } 
        else 
        { 
        ShowPlayerDialog(playerid, 18, DIALOG_STYLE_MSGBOX,"{00ff00}Online V.I.P(s):","There isn't any online V.I.P", "Ok", ""); 
        }
    You mismatched conditions.
Reply
#5

PHP код:
if(count == 0
    { 
    
ShowPlayerDialog(playerid18DIALOG_STYLE_MSGBOX,"{00ff00}Online V.I.P(s):",string"Ok"""); 
    } 
    else 
    { 
    
ShowPlayerDialog(playerid18DIALOG_STYLE_MSGBOX,"{00ff00}Online V.I.P(s):","There isn't any online V.I.P""Ok"""); 
    } 
Reply
#6

PHP код:
#if defined Loop
    #undef Loop(%1)
#endif
#define Loop(%1) for(new %1 = GetPlayerPoolSize(); %1 != -1; %1 --) if(IsPlayerConnected(%1))
CMD:viplist(playerid)
{
    new 
count;
    
Loop(i)
    {
        if(
PlayerInfo[i][pVIP])
        {
            
format(stringsizeof string"- {ffff00}%s{00ff00}| {0066ff}(ID:%s) {00ff00}| %x %s\n"GetName(i), iGetVipColor(i), GetVipLevel(i));
            
strcat(stringstringsizeof string);
            
count += 1;
        }
    }
    if(!
count) return ShowPlayerDialog(playerid18DIALOG_STYLE_MSGBOX"{00ff00}Online VIPs:","There isn't any online V.I.P""Ok""");
    else return 
ShowPlayerDialog(playerid18DIALOG_STYLE_MSGBOX"{00ff00}Online VIPs:",string"Okay""");
}
GetVipLevel(playerid)
{
    new 
str[10];
    switch(
PlayerInfo[playerid][pVIP])
    {
        case 
0str "None";
        case 
1str "Bronze";
        case 
2str "Silver";
        case 
3str "Gold";
    }
    return 
str;
}
GetVipColor(playerid)
{
    new 
str[10];
    switch(
PlayerInfo[playerid][pVIP])
    {
        case 
1str "{996600}";
        case 
2str "{adad85}";
        case 
3str "{e68a00}";
    }
    return 
str;

Reply
#7

Fixed.

Thanks for you support
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)