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

[Pregunta] Habilidades


  
 
 
Thread Tools Display Modes
Author Message
wEEk
Senior Member
Join Date: Sep 2012
Old 09-09-2013 , 10:29   [Pregunta] Habilidades
#1

Tengo una duda de como guardar estas habilidades:

PHP Code:
#include < amxmodx >  
#include < amxmisc >  
#include < fun >  
#include < hamsandwich >  

#define PLUGIN    "Habilidades por puntos"  
#define AUTHOR    "cLAANS"  
#define VERSION    "1.2"  

#define MaxSlotServidor 33 

#define MarkBit(%1,%2) ( %1 |= ( 1 << ( %2 & 31 ) ) )  
#define ClearBit(%1,%2) ( %1 &= ~ ( 1 << ( %2 & 31 ) ) )  
#define IsBit(%1,%2) ( %1 & ( 1 << ( %2 & 31 ) ) ) 

new const TAG [ ] = "[HABILIDADES]"  

new Ham:Ham_Player_ResetMaxSpeed Ham_Item_PreFrame  

enum _
:DATA_MEJORA  
{  
    
MEJORA_NAME10 ],  
    
MEJORA_COSTO,  
    
MEJORA_MAX  
};  

new 
g_mejora_data[ ][ DATA_MEJORA ] =  
{  
    { 
"Vida",         1020 },  
    { 
"Chaleco",     1310 },  
    { 
"Velocidad",     11},  
    { 
"Gravedad",     164}  
};  

new 
g_habilidadMaxSlotServidor ][ ];  
new 
g_puntosMaxSlotServidor ];  

new 
g_conectado
new 
g_msgSayText;  

#define vida(%1)        (%1 * 15)   
#define chaleco(%1)     (%1 * 10)   
#define velocidad(%1)   (%1 * 0.1)  
#define gravedad(%1)    (%1 * 0.1)    

public plugin_init( )  
{  
    
register_pluginPLUGINVERSIONAUTHOR );  
     
    
register_clcmd"say /puntos" "show_menu_puntos" );  
     
    
g_msgSayText =     get_user_msgid"SayText" );  
     
    
RegisterHamHam_Player_ResetMaxSpeed"player""fw_Player_ResetMaxSpeed");   
    
RegisterHamHam_Spawn"player""fw_PlayerSpawn_Post");  
}  

public 
client_putinserverid MarkBitg_conectadoid ); 

public 
client_disconnectid ClearBitg_conectadoid ); 

public 
fw_PlayerSpawn_Postid )  
{      
    if( !
IsBitg_conectadoid ) )  
        return 
HAM_IGNORED;  
     
    
set_user_healthidget_user_healthid ) + vidag_habilidadid ][ ] ) );  
    
set_user_armoridget_user_armor(id ) + chalecog_habilidadid ][ ] ) );  
    
set_user_gravityidget_user_gravityid ) - gravedadg_habilidadid ][ ] ) );  
     
    
/* 
    En vez de utilizar get_user_health( id ) se podria usar el numero 100 si es que no tienen otro plugin que 
    Interfiera en la vida, lo mismo en la gravedad utilizando 1.0 en vez de get_user_gravity( id ) 
    En el chaleco no ya que queda de la ronda anterior 
    */  
    
return HAM_IGNORED;  
}  

public 
fw_Player_ResetMaxSpeedid )   
    
set_user_maxspeed(idget_user_maxspeedid ) + velocidadg_habilidadid ][ ] ) );  

public 
show_menu_puntosid )  
{     
    new 
iLen250 ]; 
     
    new 
hadle_puntos menu_create("\y=============================^n\w    Sistema de habilidades \d|| \wBy cLAANS ^n\y=============================^n""hadle_puntos")  
     
    for( new 
0sizeof g_mejora_datai++ )  
    {  
        if( 
g_habilidadid ][ ] <= g_mejora_data][ MEJORA_MAX ] )  
        {  
            if( 
g_puntosid ] >= g_mejora_data][ MEJORA_COSTO ] )  
                
formatexiLen charsmaxiLen ) , "\wAumentar : %s [%d / %d] \y[ Costo : %d P]"g_mejora_data[i][MEJORA_NAME],g_habilidadid ][ ], g_mejora_data][ MEJORA_MAX ], g_mejora_data][ MEJORA_COSTO ] );   
            else  
            
formatexiLen charsmaxiLen ) , "\dAumentar : %s [%d / %d] \r[P.Necesarios : %d]"g_mejora_data][ MEJORA_NAME ], g_habilidadid ][ ], g_mejora_data][ MEJORA_MAX ], g_mejora_data][ MEJORA_COSTO ] );  
             
            if(
g_habilidadid ][ ] >= g_mejora_data][ MEJORA_MAX ] )  
                
formatexiLen charsmaxiLen ) , "\d[%d] %s [%d / %d] \r[COMPLETADO]"i+1g_mejora_data][ MEJORA_NAME ], g_habilidadid ][ ], g_mejora_data][ MEJORA_MAX ] );             
        }  
         
        
menu_additemhadle_puntos iLen );  
    }  
     
    
menu_setprophadle_puntos MPROP_EXITNAME,"\ySalir" );  
    
menu_displayidhadle_puntos );      
     
    return 
PLUGIN_HANDLED;  
}  

public 
hadle_puntos(id menuitem)  
{   
    
menu_destroy(menu);  
     
    if (
item == MENU_EXIT)      
        return  
     
    if(
g_puntosid ] < g_mejora_dataitem ][ MEJORA_COSTO ] )  
    {  
        
hns_print_color(id"^x04%s^x01 Nesecitas^x03 %d^x01 puntos para mejorar^x03 %s^x01."TAGg_mejora_dataitem ][ MEJORA_COSTO ], g_mejora_dataitem ][ MEJORA_NAME ] );  
        
client_cmdid"spk buttons/button10.wav" );  
        return; 
    }  
     
    if(
g_habilidadid ][ item ] >= g_mejora_dataitem ][ MEJORA_MAX ] )  
    {  
        
hns_print_color(id"^x04%s^x01 Subistes el maximo de puntos para la mejora:^x03 %s^x01."TAGg_mejora_dataitem ][ MEJORA_NAME ] );  
        
client_cmdid"spk buttons/button10.wav" );  
        return;  
    }  
     
    
g_puntosid ] -= g_mejora_dataitem ][ MEJORA_COSTO ];  
    
g_habilidadid ][ item ]++;   
    
hns_print_colorid"^x04%s^x01 Subistes la mejora:^x03 %s^x01 ahora tenes^x03 %d^x01 /^x03 %d^x01 completada de ella. "TAGg_mejora_dataitem ][ MEJORA_NAME ], g_habilidadid ][ item ], g_mejora_dataitem ][ MEJORA_MAX ] );  
    
show_menu_puntosid );  
}  

stock hns_print_colorid, const mensaje[ ], any:...)  
{  
    if( !
IsBitg_conectadoid ) )  
        return;  
     
    static 
buffer192 ];  
    
vformat(buffercharsmax(buffer), mensaje3);  
     
    
message_begin(MSG_ONE_UNRELIABLEg_msgSayText_id );  
    
write_byteid );  
    
write_string(buffer );  
    
message_end( );      

No se si se guarda asi:

g_habilidad[ id ][ vida ]
g_habilidad[ id ][ chaleco ]

etc..

Se guarda asi? o de otra forma?

PHP Code:
GuardarDatos(id)
{
    
// Esto lo Hice para demostrar solamente obviamente dentro del ZP tiene una Variable para obtener el Nombre si es que usan zp.
    
new gName[32]
    
get_user_name(idgNamecharsmax(gName))
    
    
// Le damos Formato a szKey con el Nombre "db_datos" para luego usarlo
    
formatex(szKeycharsmax(szKey), "db_datos")
    
    
// Lo mismo aquí pero con szData pero con la diferencia que aquí le seteamos el valor actual de cada variable.
    
formatex(szDatacharsmax(szData), "%d %d %d %d"g_habilidad[id][vida], g_habilidad[id][chaleco], g_habilidad[id][velocidad], g_habilidad[id][gravedad])
    
    
// Seteamos la key, nombre del usuario y la data
    
nfv_set_data(VaultFileszKeygNameszData)
}

// Función privada para Cargar los Datos de los Usuarios
CargarDatos(id)
{    
new 
gName[32], g_Load_vida[25], g_Load_chaleco[25], g_Load_velocidad[25], g_Load_gravedad[25]
get_user_name(idgNamecharsmax(gName))

formatex(szKeycharsmax(szKey), "db_datos")

// Creo que si no existe el key y la data con ese nombre se returnea
if(!nfv_get_data(VaultFileszKeygNameszDatasizeof(szData) - 1))
    return;
    
    
// Separamos los Datos y los guardamos en una variable
    
parse(szDatag_Load_vidacharsmax(g_Load_vida), g_Load_chalecocharsmax(g_Load_chaleco), g_Load_velocidadcharsmax(g_Load_velocidad), g_Load_gravedadcharsmax(g_Load_gravedad))
    
    
// Le damos los datos Parseados de la data convertidos en numeros
    
g_habilidad[id][vida] = str_to_num(g_Load_vida)
    
g_habilidad[id][chaleco] = str_to_num(g_Load_chaleco)
    
g_habilidad[id][velocidad] = str_to_num(g_Load_velocidad)
    
g_habilidad[id][gravedad] = str_to_num(g_Load_gravedad)

__________________
Aprendiendo de nadie
wEEk is offline
Sangriento
Junior Member
Join Date: Apr 2012
Old 09-09-2013 , 11:22   Re: [Pregunta] Habilidades
#2

corrijanme si estoy mal pero pienso q es asi para guardar esas variables

PHP Code:
    g_habilidad[id][0] = str_to_num(g_Load_vida
    
g_habilidad[id][1] = str_to_num(g_Load_chaleco
    
g_habilidad[id][2] = str_to_num(g_Load_velocidad
    
g_habilidad[id][3] = str_to_num(g_Load_gravedad

   
// lo mismo en donde se guardan 
   
g_habilidad[id][0], g_habilidad[id][1], g_habilidad[id][2], g_habilidad[id][3
Sangriento is offline
lucas_7_94
Leche Loco
Join Date: Mar 2009
Location: Argentina
Old 09-10-2013 , 09:55   Re: [Pregunta] Habilidades
#3

el segundo parametro que le metes a la variable no es válida, es una palabra y por lo menos , en el código que dejaste , no hay en ningun lugar donde las declares.

Cabe aclarar QUE podes usarla , pero TENES QUE DEFINIRLA , por ejemplo , en una estructura.

Revisa tutos de enums , te vas a sacar la duda rapidamente a lo que me refiero.
__________________
ATWWMH - MiniDuels
Madness is like gravity, just need a little push.
lucas_7_94 is offline
Send a message via Skype™ to lucas_7_94
wEEk
Senior Member
Join Date: Sep 2012
Old 09-10-2013 , 12:44   Re: [Pregunta] Habilidades
#4

Quote:
Originally Posted by lucas_7_94 View Post
el segundo parametro que le metes a la variable no es válida, es una palabra y por lo menos , en el código que dejaste , no hay en ningun lugar donde las declares.

Cabe aclarar QUE podes usarla , pero TENES QUE DEFINIRLA , por ejemplo , en una estructura.

Revisa tutos de enums , te vas a sacar la duda rapidamente a lo que me refiero.
Dale, ahora los reviso. Ya lo use como lo dijo sangriento y si guardo bien. Gracias
__________________
Aprendiendo de nadie
wEEk is offline
 


Thread Tools
Display Modes

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 05:04.


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