Raised This Month: $ Target: $400
 0% 

[Duda] frags/guardado


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
wEEk
Senior Member
Join Date: Sep 2012
Old 05-13-2013 , 23:33   [Duda] frags/guardado
#1

Alguien me dice si esto esta bien?

son los plugins de frags por level de r0ma y junte el guardado de DJHD

PHP Code:
#include <amxmodx> 
#include <hamsandwich> 
#include <engine> 
#include <nfvault>

#define PLUGIN "Niveles + Guardado" 
#define VERSION "1.0" 
#define AUTHOR "r0ma y DJHD" 

#define TAG "[AMXX]" 

#define next_level(%1) ((%1 + 1) * (power(%1, 2) / 2)) /2 


new g_level[33
new 
g_frags[33
new 
g_conectado[33

new 
g_maxplayersg_msgSayText
new VaultFile[128], szData[180], szKey[30]

public 
plugin_init() { 
    
register_plugin(PLUGINVERSIONAUTHOR
     
    
RegisterHam(Ham_Killed"player""fw_PlayerKilled")//Evento de hamsandwich que se llama cuando matan a alguien. 
     
    
new ent create_entity("info_target")//Creo 1 entidad 
    
entity_set_string(entEV_SZ_classname"entity_task")//Le seteo 1 classname 
    
entity_set_float(entEV_FL_nextthink1.0)//La ago pensar cada 1.0 segundos 
     
    
register_think("entity_task""fw_ShowHUD")//El think de la entidad que va mostrar el hud 
     
    
g_maxplayers get_maxplayers() 
    
g_msgSayText get_user_msgid("SayText"
    
nfv_file("Datos"VaultFilecharsmax(VaultFile))


public 
client_putinserver(id

    
g_conectado[id] = 
    CargarDatos
(id


public 
client_disconnect(id

    
g_conectado[id] = 0
    GuardarDatos
(id)


public 
fw_PlayerKilled(victimattacker

    if(!
g_conectado[victim] || !g_conectado[attacker] || victim == attacker || get_user_team(victim) == get_user_team(attacker))
        return 
     
    
g_frags[attacker]++ 
    
check_level(attacker


public 
fw_ShowHUD(ent)

    static 
id 
     
    set_hudmessage
(852552120.800.1200.9)
    for( 
id 1id <= g_maxplayersid++) 
    { 
        if(!
g_conectado[id]) 
            continue 
         
        
show_hudmessage(id"[Nivel:%d][Frags:%d/%d]"g_level[id], g_frags[id], next_level(g_level[id]))
    } 
     
    
entity_set_float(entEV_FL_nextthink1.0


public 
check_level(id

    while(
g_frags[id] >= next_level(g_level[id])) 
    { 
        
g_level[id]++
        
g_frags[id] = 
        hns_print_color
(id"^x04%s^x01 Felicitaciones subiste a nivel:^x04 %d^x01."TAGg_level[id]) 
    } 


stock hns_print_color(id, const mensaje[], any:...)

    static 
buffer[192
    
vformat(buffercharsmax(buffer), mensaje3
     
    
message_begin(MSG_ONE_UNRELIABLEg_msgSayText_id
    
write_byte(id
    
write_string(buffer
    
message_end() 
}  

GuardarDatos(id)
{
    new 
gName[32]
    
get_user_name(idgNamecharsmax(gName))
    
    
formatex(szKeycharsmax(szKey), "db_datos")
    
    
formatex(szDatacharsmax(szData), "|Level:%d| |Frags:%d|"g_level[id], g_frags[id])
    
    
nfv_set_data(VaultFileszKeygNameszData)
}

CargarDatos(id)
{    
    new 
gName[32], g_Load_level[25], g_Load_frags[25]
    
get_user_name(idgNamecharsmax(gName))
    
    
formatex(szKeycharsmax(szKey), "db_datos")
    
     if(!
nfv_get_data(VaultFileszKeygNameszDatasizeof(szData) - 1))
        return;
    
    
parse(szDatag_Load_levelcharsmax(g_Load_level), g_Load_fragscharsmax(g_Load_frags))
    
    
g_level[id] = str_to_num(g_Load_level)
    
g_frags[id] = str_to_num(g_Load_frags)

Edit: lo prove, anda pero, se me bugea la parte de los frags me aparece asi

Code:
Nivel: 0 Frags: 0/0

La parte de los frags esto:

PHP Code:
 show_hudmessage(id"[Nivel:%d][Frags:%d/%d]"g_level[id], g_frags[id], next_level(g_level[id])) 

Last edited by wEEk; 05-14-2013 at 02:47.
wEEk 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 20:04.


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