Raised This Month: $ Target: $400
 0% 

Grenade Name return


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 02-03-2017 , 01:23   Grenade Name return
Reply With Quote #1

How can I return the grenade's name when it touch a player?

I have a method but I want to know if have any other better than mine.
Thats the code that I'm using:

PHP Code:
new const szGrenades[] =
{
    
"smokegrenade",
    
"flashbang"
}

new 
g_gGrenadeType 
PHP Code:
register_touch("player","grenade","fwd_touch")
register_clcmd("say /grenadeUsed""showLastGrenade"
PHP Code:
public showLastGrenade(id)
{
     
console_print(id,"%s",GetGrenadeType(g_gGrenadeType)) 
PHP Code:
public fwd_touch(touchedtoucher
{
    new 
id pev(toucherpev_owner)
    if(
get_user_team(id) != get_user_team(touched))
    {
        new 
GrenadeType = (get_pdata_int(toucher114) & 3)
        
        if(
GrenadeType != CSW_HEGRENADE)
        {
            if(
fGetDistance(touchertouched) <= 5.0)
            {
                
g_gGrenadeType GrenadeType
            
}
        }
    }

PHP Code:
Float:fGetDistance(const touchedPlayer, const toucherPlayer)
{
    new 
Float:fOrigin[2][3]
    
pev(touchedPlayerpev_originfOrigin[0])
    
pev(toucherPlayerpev_originfOrigin[1])
    
    new 
Float:floatDistance fOrigin[1][2] - fOrigin[0][2]
    
    return 
floatDistance

PHP Code:
GetGrenadeType(GrenadeType)
{
    switch(
GrenadeType)
    {
        case 
CSW_SMOKEGRENADEg_gGrenadeType szGrenades[0]
        case 
CSW_FLASHBANGg_gGrenadeType szGrenades[1]
    }
    return 
g_gGrenadeType

__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo

Last edited by EFFx; 02-03-2017 at 01:24.
EFFx is offline
 



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 21:02.


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