Senior Member
Join Date: Apr 2012
Location: Great Tomb of Nazarick
|
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_flags[ 33 ]; new Trie:g_vip;
public plugin_init( ) { register_plugin( "Vip", "1.0.0", "r0ma'" ); }
public plugin_cfg( ) { new buffer[ 64 ], steam[ 33 ], flags[ 33 ], file; g_vip = TrieCreate( ); get_configsdir( buffer, charsmax( buffer ) ); add( buffer, charsmax( buffer ), "/vips.ini" ); if( !file_exists( buffer ) ) { file = fopen( buffer, "wt" ); fprintf( file, "; Si la linea tiene ; al principio no los tomara;Como crear un usuario vip.^n;^"steam_id^" ^"abcdefghijklmnopqrstu^"" ); fclose( file ); return; } file = fopen( buffer, "rt" ); while( !feof( file ) ) { fgets( file, buffer, charsmax( buffer ) ); trim( buffer ); if( !buffer[ 0 ] || buffer[ 0 ] == ';' ) continue; parse( buffer, steam, charsmax( steam ), flags, charsmax( flags ) ); remove_quotes( steam ); remove_quotes( flags ); TrieSetCell( g_vip, steam, read_flags( flags ) ); } fclose( file ); }
public plugin_end( ) { TrieDestroy( g_vip ); }
public plugin_natives( ) { register_native( "get_user_vip", "native_get_user_vip", 1 ); register_native( "set_user_vip", "native_set_user_vip", 1 ); }
public client_putinserver( id ) { check_user_vip( id ); }
public check_user_vip( id ) { new steamid[ 33 ]; get_user_authid( id, steamid, charsmax( steamid ) ); if( TrieKeyExists( g_vip, steamid ) ) { new flags; TrieGetCell( g_vip, steamid, flags ); g_flags[ id ] |= flags; } else g_flags[ id ] = 0; }
public native_get_user_vip( id ) { return g_flags[ id ]; }
public native_set_user_vip( id, flags ) { g_flags[ id ] |= 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_vip( id ); native set_user_vip( id, flags );
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_flags[ 33 ]; 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 error[ 128 ], iError; hTuple = SQL_Connect( hTuple, iError, error, charsmax( error ) ); if( !hTuple ) { log_to_file( "sql_error.txt", "Error al conectar '%d': %s", iError, error ); return; } new Handle:Query = SQL_PrepareQuery( hTuple, "SELECT * FROM users_vip" ); if( SQL_Execute( Query ) ) { new steam[ 33 ], flags[ 33 ]; while( SQL_MoreResults( Query ) ) { SQL_ReadResult( Query, 0, steam, charsmax( steam ) ); SQL_ReadResult( Query, 1, flags, charsmax( flags ) ); SQL_NextRow( Query ); TrieSetCell( g_vip, steam, read_flags( flags ) ); } } SQL_FreeHandle( Query ); SQL_FreeHandle( hTuple ); }
public plugin_end( ) { TrieDestroy( g_vip ); }
public plugin_natives( ) { register_native( "get_user_vip", "native_get_user_vip", 1 ); register_native( "set_user_vip", "native_set_user_vip", 1 ); }
public client_putinserver( id ) { check_user_vip( id ); }
public check_user_vip( id ) { new steamid[ 33 ]; get_user_authid( id, steamid, charsmax( steamid ) ); if( TrieKeyExists( g_vip, steamid ) ) { new flags; TrieGetCell( g_vip, steamid, flags ); g_flags[ id ] |= flags; } else g_flags[ id ] = 0; }
public native_get_user_vip( id ) { return g_flags[ id ]; }
public native_set_user_vip( id, flags ) { g_flags[ id ] |= flags; return 1; }
__________________
Last edited by r0ma; 08-23-2013 at 23:12.
|
|