AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Handlers not called or called wrong :/ (https://forums.alliedmods.net/showthread.php?t=163741)

Neeeeeeeeeel.- 08-02-2011 17:43

Handlers not called or called wrong :/
 
Well, it's very strange for me... I have two menus in mi ZP

Here is the first:
PHP Code:

public show_menu_pj_cuenta(id)
{
    static 
menu[500], len
    len 
0
    
    len 
+= formatex(menu[len], charsmax(menu) - len"\y-------------------------------^n\r[%s] \wVersion: \y%s^n\
    \y-------------------------------^n\wCuenta: \r%s^n^n"
GameVersionUser[id])
    
    new 
fecha[33], ip[33]
    
get_time("%d/%m/%Y"fecha32)
    
get_user_ip(idip321)
    
    
g_query SQL_PrepareQuery(g_hTuple"UPDATE `cuentas_zp` SET `UltimaFecha`='%s', `UltimaIP`='%s', `Online`='0' WHERE ( `Usuario`='%s' )"fechaipUser[id])
    
SQL_Execute(g_query)
    
    for(new 
i5i++)
    {
        if(!
equal(g_pj[id][i], ""))
        {
            if(
== 4)
                
len += formatex(menu[len], charsmax(menu) - len"\r%d. \wPersonaje: \y%s^n^n"i+1g_pj[id][i])
            else
                
len += formatex(menu[len], charsmax(menu) - len"\r%d. \wPersonaje: \y%s^n"i+1g_pj[id][i])
        }
        else
        {
            if(
== 4)
                
len += formatex(menu[len], charsmax(menu) - len"\r%d. \wCrear personaje \r(Slot %d)^n^n"i+1i+1)
            else
                
len += formatex(menu[len], charsmax(menu) - len"\r%d. \wCrear personaje \r(Slot %d)^n"i+1i+1)
        }
    }
    
    
len += formatex(menu[len], charsmax(menu) - len"\r6. \yCambiar password^n")
    
    
escape_sql(g_playername[id], 31)
    
g_query SQL_PrepareQuery(g_hTuple"SELECT `Autologin` FROM `cuentas_zp` WHERE `Usuario`='%s'"User[id])
    
    if (
SQL_Execute(g_query))
    {
        if (
SQL_NumResults(g_query))
            
AutoLogin[id] = SQL_ReadResult(g_query0)
    }
            
    
len += formatex(menu[len], charsmax(menu) - len"\r7. \w%s autologin"AutoLogin[id] ? "Desactivar" "Activar")
    
show_menu(idKEYSMENUmenu, -1"Pj cuenta")


This menu shows to the client their owns characters in their account... if the character slot is empty you could create a new one.
The thing is when you try to create in slots 3 o 4 the handler is not called, the menu refresh but nothing happens, i try with new style menues and its the same error, not error logs in console.

And here is the second menu:
PHP Code:

public show_menu_crear_pj(id)
{
    static 
menu[500], len
    len 
0
    
    len 
+= formatex(menu[len], charsmax(menu) - len"\y-------------------------------^n\r[%s] \wVersion: \y%s^n\
    \y-------------------------------^n^n\w¿Como deseas ponerle nombre a tu personaje?^n^n"
GameVersion)
    
    
len += formatex(menu[len], charsmax(menu) - len"\r1. \wNombre actual: \y%s^n"g_playername[id])
    
    
len += formatex(menu[len], charsmax(menu) - len"\r2. \wEscribir manualmente^n^n")
    
    
len += formatex(menu[len], charsmax(menu) - len"\r0. \wMenu anterior")
    
show_menu(idKEYSMENUmenu, -1"Crear pj")
}

public 
menu_crear_pj(idkey)
{
    switch (
key)
    {
        case 
0:
        {
            
escape_sql(g_playername[id], 31)
            
g_query SQL_PrepareQuery(g_hTuple"SELECT `Nombre` FROM `pjs_zp` WHERE `Nombre`='%s'"g_playername[id])
            
            if (
SQL_Execute(g_query))
            {
                if (!
SQL_NumResults(g_query))
                {
                    
g_query SQL_PrepareQuery(g_hTuple"INSERT INTO `pjs_zp` (`Nombre`) VALUES ('%s')"g_playername[id])
                    
SQL_Execute(g_query)
                    
                    
g_query SQL_PrepareQuery(g_hTuple"UPDATE `cuentas_zp` SET `Pj%d`='%s' WHERE `Usuario`='%s'", (g_pj_num[id] + 1), g_playername[id] ,User[id])
                    
SQL_Execute(g_query)

                    
client_print(idprint_center"Personaje creado correctamente!")
                    
client_cmd(id"spk buttons/button9.wav")
                    
copy(g_pj_actual[id], 31g_playername[id])
                    
MenuPersonaje(id)
                }
                
                else
                {
                    
client_print(idprint_center"Nombre en uso. Sali, cambialo y crea tu pj nuevamente")
                    
client_cmd(id"spk buttons/button10.wav")
                    
show_menu_pj_cuenta(id)
                }
            }
        }
        
        case 
1:
        {
            
ChatColor(id"!g[ZP] !yFuncion deshabilitada")
            
client_cmd(id"spk buttons/button10.wav")
            
show_menu_pj_cuenta(id)
        }
        
        case 
9: return PLUGIN_HANDLED
    
}
    
    return 
PLUGIN_HANDLED


When you create a character by the other menu this menu is called... You have two options to set a character name but thats not important, i have problems with the fisrt option... the handler is not called, i put debug messages in the handler and nothing... y also tried with old style menues... nothing happend.

Thank you for your time.

fysiks 08-02-2011 17:58

Re: Handlers not called or called wrong :/
 
Show the full code (attach it).

Neeeeeeeeeel.- 08-02-2011 21:46

Re: Handlers not called or called wrong :/
 
I cannot do that :S If you need any specific function i'll put it but the whole code have a lot of things that i did and i dont want to do public :S

fysiks 08-02-2011 22:20

Re: Handlers not called or called wrong :/
 
You could at least show ALL the code related to the problem (menus).

Hunter-Digital 08-03-2011 04:59

Re: Handlers not called or called wrong :/
 
Have you added a debug message to the verry start of the callback and have you printed the variables to see if all is called well ?

Do your menu titles match for the callbacks in register_menu() ?
And are you sure you don't have duplicates of that title ?

If you're unsure, show the code where you register the menus, constants and everything else related to those menus.

Neeeeeeeeeel.- 08-05-2011 17:59

Re: Handlers not called or called wrong :/
 
I dont know way but I desactived autologin code, then I complied and works perfect. When I activate autologin code again it works perfect o.O

Sorry for my later answer...

I have other problem...
I dont know whats wrong here :/

Code:

L 07/29/2011 - 14:17:44: Start of error session.
L 07/29/2011 - 14:17:44: Info (map "de_dust2") (file "addons/amxmodx/logs/error_20110729.log")
L 07/29/2011 - 14:17:44: [MySQL] Invalid info tuple handle: 1
L 07/29/2011 - 14:17:44: [AMXX] Displaying debug trace (plugin "zp-infernus.amxx")
L 07/29/2011 - 14:17:44: [AMXX] Run time error 10: native error (native "SQL_Connect")
L 07/29/2011 - 14:17:44: [AMXX]    [0] zp-infernus.sma::Save (line 3224)
L 07/29/2011 - 14:17:44: [AMXX]    [1] zp-infernus.sma::FwServerShutdown (line 4236)

PHP Code:

register_forward(FM_Sys_Error"FwServerShutdown")
    
register_forward(FM_GameShutdown"FwServerShutdown")
    
register_forward(FM_ServerDeactivate "FwServerShutdown"

PHP Code:

public FwServerShutdown()
{
    for (new 
id 1id <= g_maxplayersid++) 
    {
        
Save(id10)
    }


PHP Code:

public Save(idtype)
{
    if(!
LogeadoUSR[id] || LogeadoUSR[id] == 1) return PLUGIN_HANDLED

    g_hTuple 
SQL_Connect(g_Sqlnumerrorcharsmax(error))
    
    if(
type || type == 10)
    {
        
g_query SQL_PrepareQuery(g_hTuple"UPDATE `pjs_zp` SET `ClaseHumana`='%d', `ClaseZombie`='%d', `Level`='%d', `Ammopacks`='%d', `Resets`='%d', `Puntos`='%d' WHERE ( `Nombre`='%s' )"
        
g_humanclassnext[id], 
        
g_zombieclassnext[id], 
        
g_level[id], 
        
g_ammopacks[id], 
        
g_reset[id], 
        
g_points[id], 
        
g_pj_actual[id])
        
SQL_Execute(g_query)
    }
    
    if(
type == || type == 10)
    {
        
g_query SQL_PrepareQuery(g_hTuple"UPDATE `pjs_zp` SET `hVida`='%d', `hVelocidad`='%d', `hGravedad`='%d', `hDamage`='%d', `hArmor`='%d' WHERE ( `Nombre`='%s' )",
        
g_hab[id][HAB_HUMAN][HUMAN_HP],
        
g_hab[id][HAB_HUMAN][HUMAN_SPEED],
        
g_hab[id][HAB_HUMAN][HUMAN_GRAVITY],
        
g_hab[id][HAB_HUMAN][HUMAN_DAMAGE],
        
g_hab[id][HAB_HUMAN][HUMAN_ARMOR],
        
g_pj_actual[id])
        
SQL_Execute(g_query)
    }
    
    if(
type == || type == 10)
    {
        
g_query SQL_PrepareQuery(g_hTuple"UPDATE `pjs_zp` SET `zVida`='%d', `zVelocidad`='%d', `zGravedad`='%d' WHERE ( `Nombre`='%s' )"
        
g_hab[id][HAB_ZOMBIE][ZOMBIE_HP],
        
g_hab[id][HAB_ZOMBIE][ZOMBIE_SPEED],
        
g_hab[id][HAB_ZOMBIE][ZOMBIE_GRAVITY],
        
g_pj_actual[id])
        
SQL_Execute(g_query)
    }
    
    if(
type == || type == 10)
    {
        
g_query SQL_PrepareQuery(g_hTuple"UPDATE `pjs_zp` SET `HUD_STATS_X`='%f', `HUD_STATS_Y`='%f', `HUD_TITILEO`='%d', \
        `HUD_RED`='%d', `HUD_GREEN`='%d', `HUD_BLUE`='%d' WHERE ( `Nombre`='%s' )"

        
HUD_STATS_X[id],
        
HUD_STATS_Y[id], 
        
HUD_TITILEO[id],
        
HUD_RED[id],
        
HUD_GREEN[id],
        
HUD_BLUE[id],
        
g_pj_actual[id])
        
SQL_Execute(g_query)
    }
    
    if(
type == || type == 10)
    {
        
g_query SQL_PrepareQuery(g_hTuple"UPDATE `pjs_zp` SET `Quest_Zombies`='%d', `Quest_Humanos`='%d', `Quest_Infectados`='%d', `Quest_Level`='%d' WHERE ( `Nombre`='%s' )",
        
g_obj[id][0], g_obj[id][1], g_obj[id][2], g_level_m[id], g_pj_actual[id])
        
SQL_Execute(g_query)
    }
    
    return 
PLUGIN_HANDLED



lucas_7_94 08-05-2011 19:15

Re: Handlers not called or called wrong :/
 
i think 'g_hTuple' should be Handle:g_hTuple. check if the connection is 'Empty_Handle' .

And you can use switch to optimize the code.

Regards.

Neeeeeeeeeel.- 08-05-2011 21:11

Re: Handlers not called or called wrong :/
 
I put new Handle:g_hTuple when I create it... and I use it in other codes (into the same plugin) and works perfectly.

I thought that couldnt be switched, because the thinks its if i put save(index, 1) only check the first part or the second in case 2.. and if i put save(index, 10) it will save all that things so i cannot do a switch (i think).


All times are GMT -4. The time now is 03:19.

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