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

[L4D2] How to get melee ID or String Name?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
FuzzOne
Member
Join Date: Nov 2009
Location: Brazil
Old 02-04-2010 , 21:21   [L4D2] How to get melee ID or String Name?
Reply With Quote #1

Hi! I got some troubles trying to get the ID or String Name of a melee weapon in the player, to block the use of katana by a flaged player, but it always return not valid entity or something...

Tryed to use SDK:
Code:
OnClientPutOnServer

SDKHook(client, SDKHook_WeaponCanUse, OnCanUse); 
(and OnCanSwitchTo and OnWeaponEquip)

decl String:sWeapon[32];
GetEdictClassname(weapon, sWeapon, sizeof(sWeapon));


It succefully identify and block the "bullets" weapons, but looks like cant handle with the melee weapons, seaching by classname.

I tryed search by the model name using the same sdk process and by:

Code:
new slot = 1;
new meleeweapon = GetPlayerWeaponSlot(client, slot);

new String:modelname[128];
GetEntPropString(meleeweapon , Prop_Data, "m_ModelName", modelname, 128);
and by:

Code:
GetEntPropString(weapon , Prop_Data, "m_ModelName", modelname, 128);


but i think i dont made it right to remove the weapon from the player:

Code:
if(StrEqual(modelname, "v_katana.mdl")) (i also tryed w_katana.mdl)
    { remove
Can someone help a little to "detect" the melee weapon on the player?

Thank you!
FuzzOne is offline
Send a message via MSN to FuzzOne
FuzzOne
Member
Join Date: Nov 2009
Location: Brazil
Old 02-04-2010 , 21:38   Re: [L4D2] How to get melee ID or String Name?
Reply With Quote #2

Just to enjoy the the open thread, i got two questions:

1° Its possible to change the time betwen melee swings? By the "meleeweapon" scripts or using the sourcemod?

2° If i hook the "rescue_door_open" event, it will fire on realism?
FuzzOne is offline
Send a message via MSN to FuzzOne
AtomicStryker
Veteran Member
Join Date: Apr 2009
Location: Teutonia!!
Old 02-05-2010 , 16:38   Re: [L4D2] How to get melee ID or String Name?
Reply With Quote #3

@FuzzOne

Are you sure you got the right slot number? Also, why not just use GetEdictClassName on the weapon entity - it should return a unique name.

Post #2:

1: It's not, i tried. Melee weapons bug out VIOLENTLY if you try to set a "next attack time".

2: Why not try it out
AtomicStryker is offline
psychonic

BAFFLED
Join Date: May 2008
Old 02-05-2010 , 18:16   Re: [L4D2] How to get melee ID or String Name?
Reply With Quote #4

I don't have time atm to pull out the exact code, but SuperLogs: L4D has an example of how to get the melee weapon name.
psychonic is offline
psychonic

BAFFLED
Join Date: May 2008
Old 02-05-2010 , 20:39   Re: [L4D2] How to get melee ID or String Name?
Reply With Quote #5

Quote:
Originally Posted by psychonic View Post
I don't have time atm to pull out the exact code, but SuperLogs: L4D has an example of how to get the melee weapon name.
Followup to this ^

PHP Code:
        decl String:szWeapon[64];
        
GetEventString(event"weapon"szWeaponsizeof(szWeapon));
        if (
strncmp(szWeapon"melee"5) == 0)
        {
            new 
iWeapon GetEntDataEnt2(attackerg_iActiveWeaponOffset);
            if (
IsValidEdict(iWeapon))
            {
                
GetEdictClassname(iWeaponszWeaponsizeof(szWeapon));
                if (
strncmp(szWeapon[7], "melee"5) == 0)
                {
                    
GetEntPropString(iWeaponProp_Data"m_strMapSetScriptName"szWeaponsizeof(szWeapon));
                    
SetEventString(event"weapon"szWeapon);
                }
            }
        } 
This is what SuperLogs:L4D uses to get the melee weapon name (it uses it to overwrite "melee" on the death log)
psychonic is offline
AtomicStryker
Veteran Member
Join Date: Apr 2009
Location: Teutonia!!
Old 02-06-2010 , 05:55   Re: [L4D2] How to get melee ID or String Name?
Reply With Quote #6

Awesome, thanks! I was just fooling around with the model Index, but that differs from map to map
AtomicStryker 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 14:47.


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