Raised This Month: $ Target: $400
 0% 

Ham_Spawn not called


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GuskiS
Veteran Member
Join Date: Aug 2007
Location: Latvia
Old 07-14-2014 , 11:32   Ham_Spawn not called
Reply With Quote #1

Why isn't Ham_Spawn called when player survives the round? Atleast this isn't working:
PHP Code:
public Ham_Spawn_post(id)
{
    if(
is_user_alive(id))
    {
        
message_begin(MSG_ONEg_pMsgHideWeapon_id);
        
write_byte(8);
        
message_end();
    }

It only works if player was dead or just have joined server. After that, I keep seeing my radar, hp, ap.
I wonder, why is that.

EDIT: Let me rephrase it, that message isn't called after player spawn, just after death(in new round) and if he just joined.
__________________
Finished mods:
Trouble in Terrorist Town
MurderMod
The Hidden
Cowboys vs Indians
JailBreak Supreme
Survival Madness

Last edited by GuskiS; 07-14-2014 at 12:17.
GuskiS is offline
Nextra
Veteran Member
Join Date: Apr 2008
Location: Germany
Old 07-14-2014 , 11:51   Re: Ham_Spawn not called
Reply With Quote #2

It is definitely called for everyone immediately after the new round is set up. Please post a complete example plugin.
__________________
In Flames we trust!
Nextra is offline
GuskiS
Veteran Member
Join Date: Aug 2007
Location: Latvia
Old 07-14-2014 , 12:16   Re: Ham_Spawn not called
Reply With Quote #3

Thats the whole plugin
Ok my bad, it is called, but that message doesn't work in that Ham_Spawn. Wrote in first post a bit clearer.
PHP Code:
#include <amxmodx>
#include <cstrike>
#include <fakemeta>
#include <hamsandwich>

new const g_szPriWeapGive[][] =
{
    
"weapon_ak47",
    
"weapon_m4a1",
    
"weapon_awp",
    
"weapon_m3"
};

new const 
g_szPriWeapName[][] =
{
    
"CV-47",
    
"M4A1",
    
"Magnum",
    
"12 Gauge"
};

new const 
g_iPriWeapAmmo[] =
{
    
90,
    
90,
    
30,
    
32
};

new const 
g_szSecWeapGive[][] =
{
    
"weapon_usp",
    
"weapon_glock18",
    
"weapon_elite",
    
"weapon_deagle"
};

new const 
g_szSecWeapName[][] =
{
    
"K&M .45",
    
"9X19mm",
    
".40 Dual",
    
"Night Hawk"
};

new const 
g_iSecWeapAmmo[] =
{
    
100,
    
120,
    
120,
    
35
};

new 
g_iPlayerWeaps[33], g_pMsgHideWeapon;

public 
plugin_init()
{
    
register_plugin("[TH] Weapons menu""1.0.0""GuskiS");
    
RegisterHam(Ham_Spawn"player""Ham_Spawn_post"1true);
    
g_pMsgHideWeapon get_user_msgid("HideWeapon");
}

public 
Ham_Spawn_post(id)
{
    if(
is_user_alive(id))
    {
        
message_begin(MSG_ONEg_pMsgHideWeapon_id);
        
write_byte(8);
        
message_end();

        
show_weapon_menu(id);
    }
}

public 
show_weapon_menu(id)
{
    if(
is_user_alive(id) && !th_get_playerdata(idPD_HIDDEN))
    {
        static 
menuoption[64], data[3];
        
menu menu_create("Weapon menu""show_weapon_menu_handle");

        if(!
g_iPlayerWeaps[id])
        {
            for(new 
0sizeof(g_szPriWeapName); i++)
            {
                
formatex(optioncharsmax(option), "%s"g_szPriWeapName[i]);
                
num_to_str(idatacharsmax(data));
                
menu_additem(menuoptiondata0);
            }
        }
        else
        {
            for(new 
0sizeof(g_szSecWeapName); i++)
            {
                
formatex(optioncharsmax(option), "%s"g_szSecWeapName[i]);
                
num_to_str(idatacharsmax(data));
                
menu_additem(menuoptiondata0);
            }
        }

        
menu_display(idmenu);
    }
}

public 
show_weapon_menu_handle(idmenuitem)
{
    if(
item == MENU_EXIT || !is_user_alive(id) || th_get_playerdata(idPD_HIDDEN))
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }

    new 
accesscallbacknum[3];
    
menu_item_getinfo(menuitemaccessnumcharsmax(num), __callback);
    
menu_destroy(menu);

    new 
pick str_to_num(num);
    if(!
g_iPlayerWeaps[id])
    {
        
ham_give_weapon(idg_szPriWeapGive[pick]);
        
cs_set_user_bpammo(idget_weaponid(g_szPriWeapGive[pick]), g_iPriWeapAmmo[pick]);
        
g_iPlayerWeaps[id] = true;
        
show_weapon_menu(id);
    }
    else
    {
        
ham_give_weapon(idg_szSecWeapGive[pick]);
        
cs_set_user_bpammo(idget_weaponid(g_szSecWeapGive[pick]), g_iSecWeapAmmo[pick]);
        
g_iPlayerWeaps[id] = false;
    }

    return 
PLUGIN_HANDLED;

__________________
Finished mods:
Trouble in Terrorist Town
MurderMod
The Hidden
Cowboys vs Indians
JailBreak Supreme
Survival Madness

Last edited by GuskiS; 07-14-2014 at 12:18.
GuskiS is offline
NikKOo31
Senior Member
Join Date: May 2013
Location: Home
Old 07-14-2014 , 12:23   Re: Ham_Spawn not called
Reply With Quote #4

Have you tried adding client prints to actually know if it is being called or not?
NikKOo31 is offline
GuskiS
Veteran Member
Join Date: Aug 2007
Location: Latvia
Old 07-14-2014 , 12:27   Re: Ham_Spawn not called
Reply With Quote #5

Menu shows up.
__________________
Finished mods:
Trouble in Terrorist Town
MurderMod
The Hidden
Cowboys vs Indians
JailBreak Supreme
Survival Madness
GuskiS is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 07-14-2014 , 16:27   Re: Ham_Spawn not called
Reply With Quote #6

How about adding some delay to it? Perhaps a task with 0.1 or 0.2 second delay. Maybe it gets overridden with a new message for some reason?
klippy is offline
GuskiS
Veteran Member
Join Date: Aug 2007
Location: Latvia
Old 07-14-2014 , 17:47   Re: Ham_Spawn not called
Reply With Quote #7

Hmm, will try to block it, and send when I need.
__________________
Finished mods:
Trouble in Terrorist Town
MurderMod
The Hidden
Cowboys vs Indians
JailBreak Supreme
Survival Madness
GuskiS is offline
NikKOo31
Senior Member
Join Date: May 2013
Location: Home
Old 07-14-2014 , 20:13   Re: Ham_Spawn not called
Reply With Quote #8

In my experience, prints are always better

PHP Code:
public Ham_Spawn_post(id)
{
    
client_print(idprint_chat"[debug] ham spawn was executed")
    
    if(
is_user_alive(id))
    {
        
message_begin(MSG_ONEg_pMsgHideWeapon_id);
        
write_byte(8);
        
message_end();

        
show_weapon_menu(id);
        
client_print(idprint_chat"[debug] the menu will show up now")
    }
    else
        
client_print(idprint_chat"[debug] the menu won't show because you are not alive yet and KliPPy was right")

Then you will know if the problem is ham_spawn or maybe the menu (?
NikKOo31 is offline
GuskiS
Veteran Member
Join Date: Aug 2007
Location: Latvia
Old 07-14-2014 , 21:22   Re: Ham_Spawn not called
Reply With Quote #9

Like I said, menu is working, the message isn't.
__________________
Finished mods:
Trouble in Terrorist Town
MurderMod
The Hidden
Cowboys vs Indians
JailBreak Supreme
Survival Madness
GuskiS is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 07-14-2014 , 23:32   Re: Ham_Spawn not called
Reply With Quote #10

It can't be the whole plugin because you have removed some things like custom includes.
I tested both the message by itself, and your plugin with the undefined funcs commented out. Both work fine.
Also FYI not going to work until game commencing.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
Reply



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 21:06.


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