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

Solved L4d2 item or weapon message


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
maclarens
Senior Member
Join Date: Jul 2020
Location: Kz
Old 09-13-2023 , 08:49   L4d2 item or weapon message
Reply With Quote #1

Hello,pls help with realisation,i need if someone take any specific weapon, then get message "hello you take ak47" or its gnome..if take gnome & etc..
i try this but not working..


Code:
public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float f_Velocity[3], float f_Angles[3], int &weapon)
{
    if (!IsSurvivor(client)) return Plugin_Continue;
    if (buttons & IN_ATTACK)
    {
        char s_Weapon[32];
        weapon = GetEntDataEnt2(client, g_ActiveWeaponOffset);
        if (IsValidEntity(weapon)) GetEdictClassname(weapon, s_Weapon, sizeof(s_Weapon));
        if (StrEqual(s_Weapon, "weapon_rifle_ak47"))
        {
            PrintHintText(client, "%t", "hello this ak47");
        }
        
    }
    return Plugin_Continue;
}
stock bool IsSurvivor(int client)
{
    return client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2;
}

Last edited by maclarens; 09-16-2023 at 14:08.
maclarens is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 09-13-2023 , 17:26   Re: L4d2 item or weapon message
Reply With Quote #2

Use OnClientPutInServer and SDKHooks SDKHook_WeaponEquipPost. Use GetClientWeapon to retrieve the classname.

You can use:
GetEntPropString(weapon, Prop_Data, "m_strMapSetScriptName", classname, sizeof(classname));
on melee weapons to get the script name and identify the type of melee weapon.

%t is for translations, unless you have "hello this ak47" in a translation file and load that translation file, that won't work. Just print the string normally.
__________________

Last edited by Silvers; 09-13-2023 at 17:28.
Silvers is offline
maclarens
Senior Member
Join Date: Jul 2020
Location: Kz
Old 09-13-2023 , 19:46   Re: L4d2 item or weapon message
Reply With Quote #3

Silvers, ty! GetClientWeapon(client, sWeapon, sizeof(sWeapon)); working good for me!

Last edited by maclarens; 09-13-2023 at 19:46.
maclarens 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 13:31.


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