Raised This Month: $32 Target: $400
 8% 

Give Dropped Weapon


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 04-29-2017 , 19:51   Give Dropped Weapon
Reply With Quote #1

I'm trying to make a plugin that follow what CSGO does. This plugin makes the user take the dropped weapon with +use button, I don't know if it already exists, tell me if it's.

The problem is, how can I give the dropped weapon to the player?

Code

PHP Code:
#include <amxmodx>
#include <cstrike>
#include <engine>
#include <fakemeta>
#include <fun>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

const cDistance 100

new pCvarPluginEnabled

public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_forward(FM_CmdStart"fw_cmdstart")
}

public 
fw_cmdstart(iduc_handleseed)
{
    if(!
get_pcvar_num(pCvarPluginEnabled))
        return 
FMRES_IGNORED
    
    
if(!is_user_alive(id))
        return 
FMRES_IGNORED

    
if(get_uc(uc_handleUC_Buttons) & IN_USE)
    {
        new 
iTargetiBody
        get_user_aiming
(idiTargetiBodycDistance)
        
        if(
IsWeapon(iTarget))
        {
            
call_think(iTarget)
            
give_item(id/* How can I return the weapon name here? */)
        }
    }
    return 
FMRES_IGNORED
}

IsWeapon(iTargetId)
{
    new 
szTargetModel[32]
    
pev(iTargetIdpev_modelszTargetModelcharsmax(szTargetModel))
    
    if(
containi(szTargetModel"models/w_") == -1)
    {
        return 
false
    
}
    
    if(
equal(szTargetModel"models/w_backpack.mdl") || equal(szTargetModel"models/w_tighpack.mdl"))
    {
        return 
false
    
}
    
    return 
true

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

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

Last edited by EFFx; 04-29-2017 at 19:55.
EFFx is offline
Old 04-29-2017, 20:11
EFFx
This message has been deleted by EFFx.
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 04-29-2017 , 21:29   Re: Give Dropped Weapon
Reply With Quote #2

May be better just to emulate(force) touch? I'm also not sure that you can find weaponbox with get_user_aiming because it is SOLID_TRIGGER.
__________________

Last edited by PRoSToTeM@; 04-29-2017 at 21:30.
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 04-29-2017 , 21:46   Re: Give Dropped Weapon
Reply With Quote #3

I can't test anything here because I haven't CS installed but I suspected that get_user_aiming() couldn't work with weapons too.

I have had that idea:

PHP Code:
new const g_szAllWeapons[][] = 
{
    
"weapon_p228"
    
"",
    
"weapon_elite"
    
"weapon_scout",
    
"weapon_hegrenade"
    
"weapon_xm1014"
    
"weapon_c4"
    
"weapon_mac10"
    
"weapon_aug"
    
"weapon_smokegrenade"
    
"weapon_elite"
    
"weapon_fiveseven"
    
"weapon_ump45",
    
"weapon_sg550",
    
"weapon_galil"
    
"weapon_famas"
    
"weapon_usp"
    
"weapon_glock18"
    
"weapon_awp"
    
"weapon_mp5navy"
    
"weapon_m249",
    
"weapon_m3"
    
"weapon_m4a1",
    
"weapon_tmp"
    
"weapon_g3sg1",
    
"weapon_flashbang",
    
"weapon_deagle"
    
"weapon_sg552",
    
"weapon_ak47",
    
"",
    
"weapon_p90"

And

PHP Code:
give_item(idg_szAllWeapons[iTarget]) 
But I don't know if it works.
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

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

Last edited by EFFx; 04-29-2017 at 21:46.
EFFx is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 04-30-2017 , 00:11   Re: Give Dropped Weapon
Reply With Quote #4

Hook touch... Incase playet touch the wpn not to pick it up.

Am not sure if its better you can also get the wpn id by the entity model name?

But follow what hamlet told you.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 04-30-2017 at 03:22.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 04-30-2017 , 03:05   Re: Give Dropped Weapon
Reply With Quote #5

Quote:
/* How can I return the weapon name here? */
Use this stock made by connor:
PHP Code:
const XO_CWEAPONBOX 4
new const 
m_rgpPlayerItems_CWeaponBox[6] = {34,35,...}; 

GetWeaponBoxWeaponTypeent 

    new 
weapon
    for(new 
1i<= 5i++) 
    { 
        
weapon get_pdata_cbase(entm_rgpPlayerItems_CWeaponBox[i], XO_CWEAPONBOX); 
        if( 
weapon 
        { 
            return 
cs_get_weapon_id(weapon); 
        } 
    } 

    return 
0

It will return the CSW id of the weapon contained inside the box. After that, simply use get_weaponname to retrieve the weapon_*
__________________
HamletEagle is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 04-30-2017 , 13:26   Re: Give Dropped Weapon
Reply With Quote #6

Got it HamletEagle, but considering what Prostotema said, get_user_aiming() will work with dropped weapons? And the format that I said at #3 reply will work? I can't test it that's because I'm asking.
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

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

Last edited by EFFx; 04-30-2017 at 13:27.
EFFx is offline
PartialCloning
Senior Member
Join Date: Dec 2015
Old 04-30-2017 , 13:48   Re: Give Dropped Weapon
Reply With Quote #7

If you don't have CS installed why are you making plugins? You eventually have to test your code.

You should rewrite the whole code. Traceline to find the origin the player is aiming at. find_sphere class with a small radius in that origin for weaponbox. If you find weapons check the weapons they contain and find the one with the highest weight and fake_touch it.
PartialCloning is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 04-30-2017 , 14:02   Re: Give Dropped Weapon
Reply With Quote #8

Because I'm not with my default PC, I traveled then I want save the correct way and download it at my new PC.

Got a little what you said. So get_user_aiming() doesn't work with dropped weapons?

Edit1: This is my current code, I don't know what I should do now.

PHP Code:
public traceline_forward(Float:start[3], Float:end[3], conditionsidtrace)
{
    if(!
get_pcvar_num(pCvarPluginEnabled))
        return 
FMRES_IGNORED
    
    
if(!is_user_alive(id))
        return 
FMRES_IGNORED

    
if(!(get_user_button(id) & IN_USE))
    {
        return 
FMRES_IGNORED
    
}
    
    new 
Float:end_origin[3]
    
get_tr2(traceTR_vecEndPosend_origin)
    
    new 
szEntList[513]
    
find_sphere_class(0,"weaponbox"cDistanceszEntListcharsmax(szEntList), end_origin)
    return 
FMRES_IGNORED

That's the first way I'm using.
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

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

Last edited by EFFx; 04-30-2017 at 14:24.
EFFx is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 05-01-2017 , 12:50   Re: Give Dropped Weapon
Reply With Quote #9

https://forums.alliedmods.net/showpo...63&postcount=1


omgosh just search.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
PartialCloning
Senior Member
Join Date: Dec 2015
Old 05-01-2017 , 13:18   Re: Give Dropped Weapon
Reply With Quote #10

Use something like Ham_ObjectCaps to detect when the user is pressing +use. Check button & IN_USE as it's also called for nearby players. Then do a traceline ..etc
PartialCloning 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 18:58.


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