AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Redirecting weapon HUD/Sprite (https://forums.alliedmods.net/showthread.php?t=189320)

Y060N 07-05-2012 22:12

Redirecting weapon HUD/Sprite
 
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 


Arkshine 07-06-2012 13:11

Re: Redirecting weapon HUD/Sprite
 
write_byte( 0 );
SetHamReturnInteger(5);

The latter is wrong, it should SlotID + 1, so SetHamReturnInteger(1);

Y060N 07-06-2012 13:22

Re: Redirecting weapon HUD/Sprite
 
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.


All times are GMT -4. The time now is 15:23.

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