View Single Post
r0ma
Senior Member
Join Date: Apr 2012
Location: Great Tomb of Nazarick
Old 08-20-2013 , 22:43   Re: [TUT] Crear usuarios vip desde archivo *.ini
#5

Nunca usas hamsandwich

Edit:
PHP Code:
#include < amxmodx >
#include < amxmisc >

new g_flags33 ];
new 
Trie:g_vip;

public 
plugin_init( ) {
    
register_plugin"Vip""1.0.0""r0ma'" );
}

public 
plugin_cfg( ) {
    new 
buffer64 ], steam33 ], flags33 ], file;
    
    
g_vip TrieCreate( );
    
    
get_configsdirbuffercharsmaxbuffer ) );
    
addbuffercharsmaxbuffer ), "/vips.ini" );
    
    if( !
file_existsbuffer ) ) {
        
file fopenbuffer"wt" );
        
        
fprintffile"; Si la linea tiene ; al principio no los tomara;Como crear un usuario vip.^n;^"steam_id^" ^"abcdefghijklmnopqrstu^"" );
        
        
fclosefile );
        
        return;
    }
    
    
file fopenbuffer"rt" );
    
    while( !
feoffile ) ) {
        
fgetsfilebuffercharsmaxbuffer ) );
        
trimbuffer );
        
        if( !
buffer] || buffer] == ';' )
            continue;
        
        
parsebuffersteamcharsmaxsteam ), flagscharsmaxflags ) );
        
        
remove_quotessteam );
        
remove_quotesflags );
        
        
TrieSetCellg_vipsteamread_flagsflags ) );
    }
    
    
fclosefile );
}

public 
plugin_end( ) {
    
TrieDestroyg_vip );
}

public 
plugin_natives( ) {
    
register_native"get_user_vip""native_get_user_vip");
    
register_native"set_user_vip""native_set_user_vip");
}

public 
client_putinserverid ) {
    
check_user_vipid );
}

public 
check_user_vipid ) {
    new 
steamid33 ];
    
    
get_user_authididsteamidcharsmaxsteamid ) );
    
    if( 
TrieKeyExistsg_vipsteamid ) ) {
        new 
flags;
        
TrieGetCellg_vipsteamidflags );
        
        
g_flagsid ] |= flags;
    }
    else
        
g_flagsid ] = 0;
}

public 
native_get_user_vipid ) {
    return 
g_flagsid ];
}

public 
native_set_user_vipidflags ) {
    
g_flagsid ] |= flags;
    
    return 
1;

vips.inc
PHP Code:
#if defined _vips_included
  #endinput
#endif
#define _vips_included

#define VIP_A (1<<0)
#define VIP_B (1<<1)
#define VIP_C (1<<2)
#define VIP_D (1<<3)
#define VIP_E (1<<4)
#define VIP_F (1<<5)
#define VIP_G (1<<6)
#define VIP_H (1<<7)
#define VIP_I (1<<8)
#define VIP_J (1<<9)
#define VIP_K (1<<10)
#define VIP_L (1<<11)
#define VIP_M (1<<12)
#define VIP_N (1<<13)
#define VIP_O (1<<14)
#define VIP_P (1<<15)
#define VIP_Q (1<<16)
#define VIP_R (1<<17)
#define VIP_S (1<<18)
#define VIP_T (1<<19)
#define VIP_U (1<<20)

native get_user_vipid );
native set_user_vipidflags ); 
EDIT2:

Vips Via MySQL:
PHP Code:
#include < amxmodx >
#include < amxmisc >
#include < sqlx >

/* 
CREATE TABLE `users_vip` (
    `steam` VARCHAR( 33 ) NOT NULL ,
    `flags` VARCHAR( 33 ) NOT NULL ,
    UNIQUE (
        `steam`
    )
) ENGINE = MYISAM ;
*/

new g_flags33 ];
new 
Trie:g_vip;

public 
plugin_init( ) {
    
register_plugin"Vip""1.0.0""r0ma'" );
}

public 
plugin_cfg( ) {
    
    
g_vip TrieCreate( );
    
    new 
Handle:hTuple SQL_MakeDbTuple"127.0.0.1""root""""vip" );
    
    if( !
hTuple ) {
        
log_to_file"sql_error.txt""Error al conectar con la MySQL" );
        
        return;
    }
    
    new 
error128 ], iError;
    
    
hTuple SQL_ConnecthTupleiErrorerrorcharsmaxerror ) );
    
    if( !
hTuple ) {
        
log_to_file"sql_error.txt""Error al conectar '%d': %s"iErrorerror );
        
        return;
    }
    
    new 
Handle:Query SQL_PrepareQueryhTuple"SELECT * FROM users_vip" );
    
    if( 
SQL_ExecuteQuery ) ) {
        new 
steam33 ], flags33 ];
        
        while( 
SQL_MoreResultsQuery ) ) {
            
SQL_ReadResultQuery0steamcharsmaxsteam ) );
            
SQL_ReadResultQuery1flagscharsmaxflags ) );
            
            
SQL_NextRowQuery );
            
            
TrieSetCellg_vipsteamread_flagsflags ) );
        }
    }
    
    
SQL_FreeHandleQuery );
    
SQL_FreeHandlehTuple );
}

public 
plugin_end( ) {
    
TrieDestroyg_vip );
}

public 
plugin_natives( ) {
    
register_native"get_user_vip""native_get_user_vip");
    
register_native"set_user_vip""native_set_user_vip");
}

public 
client_putinserverid ) {
    
check_user_vipid );
}

public 
check_user_vipid ) {
    new 
steamid33 ];
    
    
get_user_authididsteamidcharsmaxsteamid ) );
    
    if( 
TrieKeyExistsg_vipsteamid ) ) {
        new 
flags;
        
TrieGetCellg_vipsteamidflags );
        
        
g_flagsid ] |= flags;
    }
    else
        
g_flagsid ] = 0;
}

public 
native_get_user_vipid ) {
    return 
g_flagsid ];
}

public 
native_set_user_vipidflags ) {
    
g_flagsid ] |= flags;
    
    return 
1;

__________________
Discord:FluffyDeveloper#4753
Github: https://github.com/francoromaniello
AMX-ES: https://amxmodx-es.com/r0ma'

Last edited by r0ma; 08-23-2013 at 23:12.
r0ma is offline
Send a message via MSN to r0ma