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

Solved Force Player Pickup


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
headshot910
Member
Join Date: Apr 2012
Old 03-28-2020 , 22:17   Force Player Pickup
Reply With Quote #1

Hi i'm trying to make a plugin that force player to pick up random weapons in range if they using knife.
This is what i have:

PHP Code:
while((find_ent_in_sphere(aOriginPICKUP_RANGE)) != 0)
{
    if(
is_user_alive(a))continue
    
pev(a,pev_classname,classname,32)        
    if(!
equal(classname,"weaponbox"))continue
    
    
//client_print(1, print_chat, "Ent: [%i] [%s]",a, classname)
    
dllfunc(DLLFunc_Touch,a,id)
    break;

So i tried to use
PHP Code:
dllfunc(DLLFunc_Touch,a,id
from Realistic Weapon Pickup by shine771 but when there is something available to pickup, game crash? Any suggestion?
__________________
Hi!
I'm here!

Last edited by Bugsy; 03-29-2020 at 01:03.
headshot910 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-28-2020 , 23:04   Re: Force Player Pickup
Reply With Quote #2

Try fake_touch() in engine module. Only downside is it will pick up the gun in the order that find_ent_in_sphere() identifies the entity. So if I drop a glock and deagle, and the glock is returned first when I execute the code, it will pick up the glock and ignore the deagle since I have the glock in pistol slot. You could make this smarter by identifying all nearby weapons, and prioritize which gets touched/picked up based on how good they are.

Your current code works fine for me:
PHP Code:

#include <amxmodx>
#include <engine>
#include <fakemeta>

public plugin_init() 
{
    
register_clcmd"say a" "asdas" );
}

public 
asdasid )
{
    new 
Float:fOrigin] , classname32 ];

    
pevid pev_origin fOrigin );
    
    while((
find_ent_in_sphere(afOrigin5000.0)) != 0)
    {
        if(
is_user_connected(a))continue

        
pev(a,pev_classname,classname,charsmax(classname))        
        if(!
equal(classname,"weaponbox"))continue
        
        
//client_print(1, print_chat, "Ent: [%i] [%s]",a, classname)
        //dllfunc(DLLFunc_Touch,a,id)
        
fake_touch(a,id)

        break;
    } 

__________________

Last edited by Bugsy; 03-28-2020 at 23:45.
Bugsy is offline
headshot910
Member
Join Date: Apr 2012
Old 03-29-2020 , 00:50   Re: Force Player Pickup
Reply With Quote #3

I hooked it with Ham_Item_PostFrame and somehow it's priority is the weapon i just drop

PHP Code:
#define PICKUP_RANGE 300.0
public plugin_init() 
{
    
RegisterHam(Ham_Item_PostFrame"weapon_knife""asdas"1)    
}

public 
asdasEnt )
{
    if(
pev_valid(Ent) != 2)
        return
    static 
idid get_pdata_cbase(Ent414)
    if(
get_pdata_cbase(id373) != Ent)
        return
    
    new 
Float:fOrigin] , classname32 ];
    
    
pevid pev_origin fOrigin );
    
    while((
find_ent_in_sphere(afOriginPICKUP_RANGE)) != 0)
    {
        if(
is_user_connected(a))continue
        
        
pev(a,pev_classname,classname,charsmax(classname))        
        if(!
equal(classname,"weaponbox"))continue
        
fake_touch(a,id)        
        break;
    } 

And it work good now thanks you again
__________________
Hi!
I'm here!

Last edited by headshot910; 03-29-2020 at 00:51.
headshot910 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 06:32.


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