Raised This Month: $115 Target: $400
 28% 

[TUT] Custom Weapon Hud Sprites + Slot Redirection


Post New Thread Reply   
 
Thread Tools Display Modes
ElijahDD
Junior Member
Join Date: Aug 2018
Old 08-27-2018 , 12:52   Re: [TUT] Custom Weapon Hud Sprites + Slot Redirection
Reply With Quote #101

Quote:
Originally Posted by HamletEagle View Post
Look at this thread: https://forums.alliedmods.net/showthread.php?t=270408, especially https://forums.alliedmods.net/showpo...7&postcount=55
You don't have to use okapi if you don't want to. Instead of calling CGrenade_ShootTimed2/CGrenade_ShootTimed/CGrenade_ShootSmokeGrenade you can create a fake grenade entity, set it's origin(vecSrc) and velocity(vecThrow) and then recode the explosion effects/damage, but this is not very smart/efficient.
Another way would be to simply recode CGrenade_ShootTimed2 in pawn(I assume you want to throw hegrenades), it's not hard, I did that before.

https://github.com/s1lentq/ReGameDLL...enade.cpp#L876
The only tricky part is this:
PHP Code:
pGrenade->SetTouch(&CGrenade::BounceTouch);
pGrenade->SetThink(&CGrenade::TumbleThink); 
But this can be done either with orpheu or doing what connor does here: https://forums.alliedmods.net/showthread.php?p=1920279 to retrieve BounceTouch and TumbleThink address. Then you simply set it to m_pfnThink and m_pfnTouch offsets(set_pdata_int).
Thank you, i'll try
but, i replace m249 by my grenade(something like heal greneade), can i use it for throw my grenade, not flash, HE, smoke?
--
Another question (sorry for oftop), maybe u know method how to detect that player stop send packets to server?

Last edited by ElijahDD; 08-27-2018 at 12:59.
ElijahDD is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-27-2018 , 13:00   Re: [TUT] Custom Weapon Hud Sprites + Slot Redirection
Reply With Quote #102

Yes, it is possible and probably easier, forget what I said about orpheu/okapi.
Hook PrimaryAttack for m249, supercede and then simply create a custom entity using the code I linked before to set it's origin and velocity. Basically take only the math from the link. Next thing is to hook touch for your custom entity and make it do something.
__________________
HamletEagle is offline
Krtola
Veteran Member
Join Date: Oct 2013
Location: Serbia
Old 04-28-2019 , 11:36   Re: [TUT] Custom Weapon Hud Sprites + Slot Redirection
Reply With Quote #103

I use exactly the same code from first post and plugin work fine. But getting error in console every time I switch on knife. Error is
PHP Code:
uncnown command"weapon_ArkFlare" 
What is the problem?

PHP Code:
#include <amxmodx>  
#include <hamsandwich>  
#include <fakemeta>  

new MsgIndexWeaponList;  

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

public 
plugin_init()  
{  
    
RegisterHamHam_Item_AddToPlayer"weapon_knife""OnAddToPlayerKnife", .Post true );  
    
RegisterHamHam_Item_ItemSlot"weapon_knife""OnItemSlotKnife" );  

    
register_clcmd"weapon_ArkFlare""ClientCommand_SelectFlare" );  

    
MsgIndexWeaponList get_user_msgid"WeaponList" );  
}  

public 
ClientCommand_SelectFlare( const client )  
{  
    
engclient_cmdclient"weapon_knife" );  
}  

public 
OnAddToPlayerKnife( const item, const player )  
{  
    if( 
pev_validitem ) && is_user_aliveplayer ) ) // just for safety.  
    
{  
        
message_beginMSG_ONEMsgIndexWeaponList, .player player );  
        {  
            
write_string"weapon_ArkFlare" );  // WeaponName  
            
write_byte( -);                   // PrimaryAmmoID  
            
write_byte( -);                   // PrimaryAmmoMaxAmount  
            
write_byte( -);                   // SecondaryAmmoID  
            
write_byte( -);                   // SecondaryAmmoMaxAmount  
            
write_byte);                    // SlotID (0...N)  
            
write_byte);                    // NumberInSlot (1...N)  
            
write_byteCSW_KNIFE );            // WeaponID  
            
write_byte);                    // Flags  
        
}  
        
message_end();  
    }  
}  

public 
OnItemSlotKnife( const item )  
{  
    
SetHamReturnInteger);  
    return 
HAM_SUPERCEDE;  

__________________
Check my new Zombie Mod (2019)
Look at the video below to see gameplay

https://www.youtube.com/watch?v=U4mf9obA6x0
Krtola is offline
Send a message via Skype™ to Krtola
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 04-28-2019 , 14:28   Re: [TUT] Custom Weapon Hud Sprites + Slot Redirection
Reply With Quote #104

register_concmd
__________________
Accepting private $$$ plugins requests.

@Steam: crazy770
@Discord: CrazY.#5317

Website | Channel

CrazY. is online now
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 04-28-2019 , 18:26   Re: [TUT] Custom Weapon Hud Sprites + Slot Redirection
Reply With Quote #105

No, clcmd is what should be used here. Concmd is for executing commands via the server console and the client console. Clcmd is client only.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Krtola
Veteran Member
Join Date: Oct 2013
Location: Serbia
Old 04-29-2019 , 07:26   Re: [TUT] Custom Weapon Hud Sprites + Slot Redirection
Reply With Quote #106

Tested with flashbang and smokegrenade,and I get
PHP Code:
uncnown command 
only for knife.
__________________
Check my new Zombie Mod (2019)
Look at the video below to see gameplay

https://www.youtube.com/watch?v=U4mf9obA6x0
Krtola is offline
Send a message via Skype™ to Krtola
Reply


Thread Tools
Display Modes

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 16:41.


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