AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   VIPs doesn't appear in MotD (https://forums.alliedmods.net/showthread.php?t=214771)

Unkolix 04-29-2013 16:26

VIPs doesn't appear in MotD
 
The problem is that the code shows only me (maybe because others get free vip form 20:00)... I would like to see them in the motd too.
PHP Code:

new Array:g_Array;
/*Plugin Init*/
register_clcmd("say /vips","print_adminlist"
g_Array         ArrayCreate(64,32);
/***/
public client_authorized(id)
{
    if(
get_user_flags(id) & VIP_FLAG)
    {
        new 
g_Name[64];
        
get_user_name(id,g_Name,charsmax(g_Name));
            
        new 
g_Size ArraySize(g_Array);
        new 
szName[64];
            
        for(new 
0g_Sizei++)
        {
            
ArrayGetString(g_ArrayiszNamecharsmax(szName));
            
            if(
equal(g_NameszName))
            {
                return 
0;
            }
        }    
        
ArrayPushString(g_Array,g_Name);
    }
    return 
PLUGIN_CONTINUE
}

public 
client_disconnect(id)
{
    if(
get_user_flags(id) & VIP_FLAG)
    {
        new 
Name[64];
        
get_user_name(id,Name,charsmax(Name));
        
        new 
g_Size ArraySize(g_Array);
        new 
g_Name[64];
    
        for(new 
0g_Sizei++)
        {
            
ArrayGetString(g_Arrayig_Namecharsmax(g_Name));
            
            if(
equal(g_Name,Name))
            {
                
ArrayDeleteItem(g_Array,i);
                break;
            }
        }
    }
}
public 
client_infochanged(id)
{
    if(
get_user_flags(id) & VIP_FLAG)
    {
        new 
szName[64];
        
get_user_info(id,"name",szName,charsmax(szName));
        
        new 
Name[64];
        
get_user_name(id,Name,charsmax(Name));
        
        if(!
equal(szName,Name))
        {
            
ArrayPushString(g_Array,szName);
            
            new 
g_Size=ArraySize(g_Array);
            new 
g_Name[64];
            for(new 
0g_Sizei++)
            {
                
ArrayGetString(g_Arrayig_Namecharsmax(g_Name));
                
                if(
equal(g_Name,Name))
                {
                    
ArrayDeleteItem(g_Array,i);
                    break;
                }
            }
        }
    }
}
/*On Command*/
public print_adminlist(user
{
    new 
contact[112];
    
get_cvar_string("vip_contactinfo"contact63)
    new 
price[112];
    
get_cvar_string("vip_price"price63)
    new 
Data[g_Buffer], Leng_Name[64];
    
    
Len formatex(Data[Len], g_Buffer Len"<html><center><font color=yellow>%L <font color=green>%s.<font color=yellow> %L <font color=green>%s</font><body bgcolor=Black>"user"CONTACT"contactuser"MOTD_LINE_15"price);
    
Len += formatex(Data[Len], g_Buffer Len"<br><table border=1 width=300 cellspacing=0 bordercolor=#4A4344 style=color:#56A5EC;text-align:center;>");
    
Len += formatex(Data[Len], g_BufferLen"<tr><td><b>#</b></td><td><b>%L</b></td></tr>"user"VIPS_ONLINE");
    
    new 
g_Size ArraySize(g_Array);
    
    for(new 
0g_Sizei++)
    {
        
ArrayGetString(g_Arrayig_Namecharsmax(g_Name));
        
        
Len += formatex(Data[Len], g_Buffer Len"<tr><td><font color=Red>%d</font></td>"1);
        
Len += formatex(Data[Len], g_Buffer Len"<td>%s</td></tr>"g_Name);
    }
    
Len += formatex(Data[Len],g_Buffer Len,"</center></body></html>");
    new 
motd_name[64];
    
format(motd_name64"%L"user"WANTVIP_MOTD_NAME");
    
show_motd(userDatamotd_name);        



ConnorMcLeod 04-29-2013 17:59

Re: VIPs doesn't appear in MotD
 
Why do you bother setting a dynamic array ?
Just format the string when you need to show the motd and only check for admin flags ;)


All times are GMT -4. The time now is 10:51.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.