Raised This Month: $51 Target: $400
 12% 

[TUT] Crear usuarios vip desde archivo *.ini


  
 
 
Thread Tools Display Modes
Author Message
Anti
Senior Member
Join Date: Jul 2012
Location: sky
Old 08-20-2013 , 20:29   [TUT] Crear usuarios vip desde archivo *.ini
#1

Hola, como anduve sin internet un tiempo estube aburrido y me puse a joder con el pawn studio.
Acá les dejo un tuto(le puse aclaraciones a algunas lineas) medio feo de como crear usuarios "vips" desde un archivo .ini en la carpeta config.
No vi ninguno así que lo posteo, si le ven algo mal avisen


PHP Code:
/*
NOTA:
NO PONER MAS DE 20 VIPS, SI QUERES MAS EDITA EL DEFINE 'MAXVIPS';
LOS NAMES QUE TENGAN ';' O '/' O '/'(EN LAS SEGUNDA POSICION) NO LOS LEERA;
*/
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>

#define MAXVIPS    20
#define VIPSCARACT    32

new gFileName[] = "names_vip.ini";

new 
gVips[MAXVIPS+1][VIPSCARACT+1];

new 
PlayersVip[33];

public 
plugin_init()
{
    
register_plugin("Usuarios vip en *.ini""1.0""Anti");
    
}

public 
client_putinserver(id)
    
set_task(3.0"get_user_vip"id)

public 
get_user_vip(id)
{
    new 
Path[256];
    
get_configsdir(Pathcharsmax(Path));
    
formatex(Pathcharsmax(Path),"%s/%s"PathgFileName);// ruta del archivo .ini
    
    
if(!file_exists(Path))
    {
        
client_print(idprint_chat"El archivo %s no existe, crealo y pone los vips!!!"gFileName);// si no existe el archivo
        
return PLUGIN_HANDLED;
    }
    
    new 
fopen(Path"rt");            // abrimos y leemos el archivo
    
    
new iName[VIPSCARACT+1];
    new 
gName[32];
    new 
Vip;
    
get_user_name(idgName31)        //obtenemos el nombre del player
    
while(!feof(f))
    {
        
fgets(fiNamecharsmax(iName));//obtenemos el nombre de gFileName
        
        
copy(gVips[Vip], charsmax(gVips), iName);
        
Vip++;
        
        if(
Vip >= MAXVIPS) break;
        
        if(!
iName[0] || iName[0] == ';'
        
|| iName[0] == '/' && iName[1] == '/' ) continue;// si el nombre tiene ';' O '/' O '/'(EN LAS SEGUNDA POSICION) LOS LEERA;
        
        
if ( equalgNameiName ))        // si el nombre del player es igual a el del archivo es le mandamos un hudd
            
esVip(id)
    }
    
fclose(f);                          //cerramos el archivo
    
return PLUGIN_HANDLED;
}

public 
esVip(id)
{
    new 
szName[32]
    
get_user_name(idszName31)
    
PlayersVip[id] = 1;
    
set_hudmessage(2000100)
    
show_hudmessage(0"%s es usuario vip!!"szName)
    
/*----Pones el code----*/

PD: Yo los subí con la mejor onda espero que me respondan así!!
gracias a Roccoxx por hacerme acordar de que no es conveniente abrir muchas veces el archivo .ini por eso verifiquen el vip una vez sola o lo menos posible

Last edited by Anti; 08-21-2013 at 17:41.
Anti is offline
Send a message via Skype™ to Anti
Roccoxx
AlliedModders Donor
Join Date: Jan 2012
Location: Argentina
Old 08-20-2013 , 21:17   Re: [TUT] Crear usuarios vip desde archivo *.ini
#2

te parece bien ejecutar tantas cosas cada vez que revive un jugador

de onda lo digo, no intenten aportar sino estan seguros que lo que hacen es la mejor forma para los usuarios nuevos.
__________________
Tutorials here (Spanish)

Like as another Pijudo said: "Tired and retired"
Roccoxx is offline
Send a message via MSN to Roccoxx
Anti
Senior Member
Join Date: Jul 2012
Location: sky
Old 08-20-2013 , 21:57   Re: [TUT] Crear usuarios vip desde archivo *.ini
#3

si, iba a aclararlo pero se me paso este caso es un ejemplo, cada uno lo adaptara a sus necesidades.
gracias roccoxx!!
si ven algo mas mal avisen
Anti is offline
Send a message via Skype™ to Anti
gladius
Veteran Member
Join Date: Jul 2008
Location: Santiago, Chile
Old 08-20-2013 , 22:22   Re: [TUT] Crear usuarios vip desde archivo *.ini
#4

Usa Arrays o Tries queda más bonito y dinámico.
__________________
Proyects
Kreedz Chile Mod [100%] (Fixing some details).


Last edited by gladius; 08-20-2013 at 22:23.
gladius is offline
Send a message via MSN to gladius Send a message via Skype™ to gladius
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
DiegoCS
Senior Member
Join Date: Mar 2013
Old 08-21-2013 , 07:02   Re: [TUT] Crear usuarios vip desde archivo *.ini
#6

está piola .
Lo Adaptare a algún mod que valla a usar .
DiegoCS is offline
Anti
Senior Member
Join Date: Jul 2012
Location: sky
Old 08-21-2013 , 14:12   Re: [TUT] Crear usuarios vip desde archivo *.ini
#7

Quote:
Originally Posted by r0ma View Post
PD: Nunca usas hamsandwich
si, quedo del edit anterior
Anti is offline
Send a message via Skype™ to Anti
Roccoxx
AlliedModders Donor
Join Date: Jan 2012
Location: Argentina
Old 08-21-2013 , 17:12   Re: [TUT] Crear usuarios vip desde archivo *.ini
#8

buena r0m@
__________________
Tutorials here (Spanish)

Like as another Pijudo said: "Tired and retired"
Roccoxx is offline
Send a message via MSN to Roccoxx
Anti
Senior Member
Join Date: Jul 2012
Location: sky
Old 08-23-2013 , 23:17   Re: [TUT] Crear usuarios vip desde archivo *.ini
#9

@r0ma se entusiasma en dejarme mal :/
Anti is offline
Send a message via Skype™ to Anti
Winchester90
Senior Member
Join Date: May 2013
Location: Dale! RG4L Baby
Old 09-05-2013 , 06:31   Re: [TUT] Crear usuarios vip desde archivo *.ini
#10

No anda este tuto :\ O puse mal los datos en el .ini o nose :S Puse lo mismo que en users ini y no anda LOL
__________________
Proyectos No comercio XD
Zombie Resurection 1.0 (45%)
Winchester90 is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:44.


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