Raised This Month: $ Target: $400
 0% 

Redirecting weapon HUD/Sprite


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Y060N
BANNED
Join Date: Dec 2011
Location: www.equilibriumcs.com
Old 07-05-2012 , 22:12   Redirecting weapon HUD/Sprite
Reply With Quote #1

I've only included part of the code but it should be enough to see what my problem is. Right now it's in first slot, first spot - and here it works. But when I try to redirect it to any other slot/spot it just disappears and nothing is on my HUD besides my regular weapons. I'd like to know what I am doing wrong with this to cause the problem. Some people have reported that the weapon appears above and below their primary weapon, for me it is only above the primary weapon (where according to the code it should be - but there is probably something wrong). I'd like to know if you could offer some help.

Something else is when an attack is made with this weapon it says "C4 must be planted at a bomb site!" and I want to remove this. Currently the code that I have doesn't work.

Would be much appreciated!

PHP Code:
public plugin_init()
{
    
register_message(get_user_msgid("TextMsg"), "Message_TextMsg")
    
register_clcmd("weapon_NemBaz""ClientCommand_SelectNemBaz")
    
    
RegisterHam(Ham_Item_AddToPlayer"weapon_c4""OnAddToPlayerNemBaz", .Post true)
    
RegisterHam(Ham_Item_ItemSlot"weapon_c4""OnItemSlotNemBaz")
}

public 
plugin_precache()
{
    
precache_generic("sprites/weapon_NemBaz.txt")
    
precache_generic("sprites/640hud19.spr")
    
precache_generic("sprites/640hud20.spr")
}

public 
ClientCommand_SelectNemBaz( const client )  
{  
    
engclient_cmdclient"weapon_c4" );  
}  

public 
OnAddToPlayerNemBaz( const item, const player )
{
    if( 
pev_validitem ) && is_user_aliveplayer ) && flag_get(g_Isevilnemplayer)) // just for safety.
    
{
        
message_beginMSG_ONEMsgIndexWeaponList, .player player );
        {
            
write_string("weapon_NemBaz");    // WeaponName
            
write_byte( -);                   // PrimaryAmmoID
            
write_byte( -);                   // PrimaryAmmoMaxAmount
            
write_byte( -);                   // SecondaryAmmoID
            
write_byte( -);                   // SecondaryAmmoMaxAmount
            
write_byte);                    // SlotID (0...N)    <== Changed here (was 2)
            
write_byte);                    // NumberInSlot (1...N)
            
write_byteCSW_C4 );            // WeaponID
            
write_byte);                    // Flags
        
}
        
message_end();
    }
}

public 
OnItemSlotNemBaz( const item )
{
    
SetHamReturnInteger(5);
    return 
HAM_SUPERCEDE;
}

public 
Message_TextMsg(iMsgIdiMsgDestid)
{
    if( !
id && get_msg_arg_int(1) == print_center )
    {
        new 
szMessage[64]
        
get_msg_arg_string(2szMessagecharsmax(szMessage))
        if( 
equal(szMessage"C4 must be planted at a bomb site!") )
        {
            return 
PLUGIN_HANDLED
        
}
    }
    return 
PLUGIN_CONTINUE

weapon_NemBaz.txt:
PHP Code:
2
weapon            640 640hud19    0    135    170    45
weapon_s        640 640hud20    0    135    170    45 
Y060N is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 07-06-2012 , 13:11   Re: Redirecting weapon HUD/Sprite
Reply With Quote #2

write_byte( 0 );
SetHamReturnInteger(5);

The latter is wrong, it should SlotID + 1, so SetHamReturnInteger(1);
__________________
Arkshine is offline
Y060N
BANNED
Join Date: Dec 2011
Location: www.equilibriumcs.com
Old 07-06-2012 , 13:22   Re: Redirecting weapon HUD/Sprite
Reply With Quote #3

Ah perfect. Thanks a lot man!

Edit: Actually when I change the slots again to anything but 0, let's say I changed to this, to put in pistol slot:

write_byte( 1 );
SetHamReturnInteger(2);


It just doesn't show up.

Last edited by Y060N; 07-06-2012 at 13:45.
Y060N 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 15:23.


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