Raised This Month: $12 Target: $400
 3% 

[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 original plugins for cs 1.6 and subscribe on channel
Look at the video below to see blind grenade for zombies

https://www.youtube.com/watch?v=ORC7ZmoaipQ

Look at the video below to see Zombie Hide And Seek mode

https://www.youtube.com/watch?v=xpyYb65EgGs
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
__________________








CrazY. is offline
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 original plugins for cs 1.6 and subscribe on channel
Look at the video below to see blind grenade for zombies

https://www.youtube.com/watch?v=ORC7ZmoaipQ

Look at the video below to see Zombie Hide And Seek mode

https://www.youtube.com/watch?v=xpyYb65EgGs
Krtola is offline
Send a message via Skype™ to Krtola
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 09-05-2023 , 06:43   Re: [TUT] Custom Weapon Hud Sprites + Slot Redirection
Reply With Quote #107

I've configured the slot redirection to put the RPG-7 in slot 4.
However, the RPG-7 does not appear in slot 4 as expected. Instead, it shows up in slots 1, 2, 3, and 5 without any issues.

I've double-checked my configuration files and scripts, but I can't figure out what's causing this problem. I would greatly appreciate it if someone could help me troubleshoot this issue and provide guidance on how to make the RPG-7 appear in slot 4 as intended.


PHP Code:
#define PRI_AMMO_ID 2
#define SLOT_ID 3
#define NUM_IN_SLOT 1
#define ITEM_FLAGS 0

RegisterHam(Ham_Item_ItemSlotWEAPON_BASE_ENT"@Ham_CBasePlayer_ItemSlot");
    
@
Ham_CBasePlayer_ItemSlot( const item )
{
    
SetHamReturnInteger(SLOT_ID 1);
    return 
HAM_SUPERCEDE;
}

public 
fw_Item_AddToPlayer_Post(entid) {
    switch(
entity_get_int(entEV_INT_impulse)) {
        case 
0UTIL_Weaponlist(idWEAPON_BASE_ENTPRI_AMMO_ID9001WEAPON_BASE_CSW0);
        case 
WEAPON_SPECIAL_KEYUTIL_Weaponlist(idWEAPON_SPRITE_NAMEPRI_AMMO_IDWEAPON_AMMOSLOT_IDNUM_IN_SLOTWEAPON_BASE_CSWITEM_FLAGS);
    }

Attached Files
File Type: sma Get Plugin or Get Source (ze_extra_rpg7.sma - 67 views - 19.2 KB)
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.

Last edited by Supremache; 09-06-2023 at 07:10. Reason: Solved: #define NUM_IN_SLOT 4
Supremache is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 09-25-2023 , 14:34   Re: [TUT] Custom Weapon Hud Sprites + Slot Redirection
Reply With Quote #108

Quote:
Originally Posted by Supremache View Post
I've configured the slot redirection to put the RPG-7 in slot 4.
However, the RPG-7 does not appear in slot 4 as expected. Instead, it shows up in slots 1, 2, 3, and 5 without any issues.

I've double-checked my configuration files and scripts, but I can't figure out what's causing this problem. I would greatly appreciate it if someone could help me troubleshoot this issue and provide guidance on how to make the RPG-7 appear in slot 4 as intended.


PHP Code:
#define PRI_AMMO_ID 2
#define SLOT_ID 3
#define NUM_IN_SLOT 1
#define ITEM_FLAGS 0

RegisterHam(Ham_Item_ItemSlotWEAPON_BASE_ENT"@Ham_CBasePlayer_ItemSlot");
    
@
Ham_CBasePlayer_ItemSlot( const item )
{
    
SetHamReturnInteger(SLOT_ID 1);
    return 
HAM_SUPERCEDE;
}

public 
fw_Item_AddToPlayer_Post(entid) {
    switch(
entity_get_int(entEV_INT_impulse)) {
        case 
0UTIL_Weaponlist(idWEAPON_BASE_ENTPRI_AMMO_ID9001WEAPON_BASE_CSW0);
        case 
WEAPON_SPECIAL_KEYUTIL_Weaponlist(idWEAPON_SPRITE_NAMEPRI_AMMO_IDWEAPON_AMMOSLOT_IDNUM_IN_SLOTWEAPON_BASE_CSWITEM_FLAGS);
    }

Consider this information: https://wiki.alliedmods.net/CS_WeaponList_Message_Dump

Take a look to the NumberInSlot parameter: weapon_ak47 is listed in position 1, same as weapon_hegrenade. NumberInSlot should be changed to another unused position, like 4 (1=he, 2=fb, 3=sg)
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
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 06:27.


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