AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Ham_Item_Deploy (https://forums.alliedmods.net/showthread.php?t=87949)

Dr.G 03-18-2009 14:06

Ham_Item_Deploy
 
shouldnt this work or did i leave something out by mistake? iam testing on DoD, but it doesnt work. the classnames is registered right, i dont get any errors.. is it an offset or something i missed?

Code:


new const Knife_Names[][] = { "weapon_amerknife", "weapon_spade", "weapon_gerknife" }
 
public plugin_init()
{
for (new i = 0; i < sizeof Knife_Names; i++)
 RegisterHam(Ham_Item_Deploy, Knife_Names[i], "current_wpn", 1)
}
 
public current_wpn(id)
{
client_print(id,3, "knife is forward")
}

- cheers!

ConnorMcLeod 03-18-2009 14:08

Re: Ham_Item_Deploy
 
You have missed the fact that the forward won't pass any player id, but weapon id.
Either you find the weapon offset m_pPlayer (could be the same as for cs1.6), either you retrieve the id using pev_owner.


Try using

RegisterHam(Ham_Item_Deploy, Knife_Names[i], "Knife_Deploy", 1)

PHP Code:

public Knife_DeployiEnt )
{
    new 
id pev(iEntpev_owner)
    for( new 
i=1i<=100i++)
    {
        if( 
get_pdata_cbase_safe(iEnti) )
        {
            
client_print(idprint_chat"Weapon Offset m_pPlayer could be %d"i)
        }
    }



Try this on windows, when you have found the offset, you can use this to retrieve player id :


Code:

#define m_pPlayer ??? // value you have found


public Knife_Deploy( iEnt )
{
    new id = get_pdata_cbase(iEnt, m_pPlayer, 4) // you will have to check that diff between win32 and linux is 4 for weapons entities

On cs1.6, value is 41, could be the same on dod.

Dr.G 03-18-2009 14:14

Re: Ham_Item_Deploy
 
lmao ok..

ConnorMcLeod 03-18-2009 14:23

Re: Ham_Item_Deploy
 
If you only want to detect knife, register CurWeapon with right args in the registering line should be enough.

If it's the same as in cs1.6, there's no other CurWeapon messages sent than the deployed one.

Dr.G 03-18-2009 14:43

Re: Ham_Item_Deploy
 
thanks ill test it later, and post the result.. thanks!

edit

btw what i wanted was to leave out the CurWeapon thing, i use that now..


All times are GMT -4. The time now is 08:58.

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