AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Pick up gun owner info (https://forums.alliedmods.net/showthread.php?t=332013)

FeehSK 04-18-2021 12:18

Pick up gun owner info
 
Hi, guys!

How can I get information about the owner of the dropped weapon? Whether the skin is activated or not.

Bugsy 04-18-2021 22:13

Re: Pick up gun owner info
 
You can get the player who dropped it by checking the pev_owner value of the weaponbox entity. To get additional details, you can use pev_classname, pev_model, etc. If you need a specific value customer for your plugin, you can use a pev_iuser field. But be aware that other plugins may use the field and could cause conflict with yours.

PHP Code:


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

public plugin_init() 
{
    
RegisterHamHam_Touch "weaponbox" "WeaponboxTouch" true );
    
register_forwardFM_SetModel "SetModel" );
}

public 
WeaponboxTouchiEntity )
{
    static 
iOwner iOtherInfo
    
    if ( 
peviEntity pev_flags ) & FL_ONGROUND )
    {
        
iOwner peviEntity pev_owner );
        
//iOwner = player who dropped item
        
        
iOtherInfo peviEntity pev_iuser2 );
        
//iOtherInfo = value set to pev_iuser2 when item was dropped
    
}


public 
SetModeliEntity , const szModel[] )
{
    new 
szClassname32 ];
    
    
peviEntity pev_classname szClassname charsmaxszClassname ) );
    
    if ( 
equal szClassname "weaponbox" ) )
    {
        
set_peviEntity pev_iuser2 12345 );
    }



FeehSK 04-19-2021 22:29

Re: Pick up gun owner info
 
Quote:

Originally Posted by Bugsy (Post 2744477)
You can get the player who dropped it by checking the pev_owner value of the weaponbox entity. To get additional details, you can use pev_classname, pev_model, etc. If you need a specific value customer for your plugin, you can use a pev_iuser field. But be aware that other plugins may use the field and could cause conflict with yours.

PHP Code:


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

public plugin_init() 
{
    
RegisterHamHam_Touch "weaponbox" "WeaponboxTouch" true );
    
register_forwardFM_SetModel "SetModel" );
}

public 
WeaponboxTouchiEntity )
{
    static 
iOwner iOtherInfo
    
    if ( 
peviEntity pev_flags ) & FL_ONGROUND )
    {
        
iOwner peviEntity pev_owner );
        
//iOwner = player who dropped item
        
        
iOtherInfo peviEntity pev_iuser2 );
        
//iOtherInfo = value set to pev_iuser2 when item was dropped
    
}


public 
SetModeliEntity , const szModel[] )
{
    new 
szClassname32 ];
    
    
peviEntity pev_classname szClassname charsmaxszClassname ) );
    
    if ( 
equal szClassname "weaponbox" ) )
    {
        
set_peviEntity pev_iuser2 12345 );
    }




Can you show me an example of what it would be like for the Y player to see the skin that X dropped?

FeehSK 04-27-2021 21:26

Re: Pick up gun owner info
 
Quote:

Originally Posted by FeehSK (Post 2744572)
Can you show me an example of what it would be like for the Y player to see the skin that X dropped?

?

Bugsy 04-27-2021 21:43

Re: Pick up gun owner info
 
I would need to see how the the skin is applied to the weapon. Is it only set as the model?

FeehSK 04-28-2021 20:30

Re: Pick up gun owner info
 
Quote:

Originally Posted by Bugsy (Post 2745249)
I would need to see how the the skin is applied to the weapon. Is it only set as the model?

PHP Code:

new V_MODEL[64] = "models/new/v_ak47.mdl"
new P_MODEL[64] = "models/new/p_ak47.mdl"


public plugin_init()
{
    
register_event("CurWeapon","CurrentWeapon","be","1=1")
}

public 
CurrentWeapon(id)
{
     
replace_weapon_models(idread_data(2))
}

replace_weapon_models(idweaponid)
{
    switch (
weaponid)
    {
        case 
CSW_AK47:
        {
            if(
iSelect[id])
            {
                
set_pev(idpev_viewmodel2V_MODEL)
                
set_pev(idpev_weaponmodel2P_MODEL)
            }            
        }
    }



Bugsy 04-28-2021 22:18

Re: Pick up gun owner info
 
Try this.. when a weapon is touched/picked up, check the pev_iuser2 value of the entity [ pev( [entity id] , pev_iuser2 ) ], if it's 1, then it had the model set. If your plugin removes the models, then be sure to call set_pev( iEntID , pev_iuser2 , 0 ) on it.
PHP Code:


#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#define m_pActiveItem 373
#define XO_PLAYER 5

new V_MODEL[64] = "models/new/v_ak47.mdl"
new P_MODEL[64] = "models/new/p_ak47.mdl"

new iSelectMAX_PLAYERS ];

public 
plugin_init()
{
    
register_event("CurWeapon","CurrentWeapon","be","1=1")
}

public 
CurrentWeapon(id)
{
    
replace_weapon_models(idread_data(2))
}

replace_weapon_models(idweaponid)
{
    new 
iEntID;
    
    switch ( 
weaponid )
    {
        case 
CSW_AK47:
        {
            if ( 
iSelectid ] )
            {
                
set_pev(idpev_viewmodel2V_MODEL)
                
set_pev(idpev_weaponmodel2P_MODEL)

                if ( ( 
iEntID get_pdata_cbaseid m_pActiveItem XO_PLAYER ) ) > 
                {
                    
set_peviEntID pev_iuser2 );
                }
            }            
        }
    }



FeehSK 05-04-2021 12:38

Re: Pick up gun owner info
 
Quote:

Originally Posted by Bugsy (Post 2745350)
Try this.. when a weapon is touched/picked up, check the pev_iuser2 value of the entity [ pev( [entity id] , pev_iuser2 ) ], if it's 1, then it had the model set. If your plugin removes the models, then be sure to call set_pev( iEntID , pev_iuser2 , 0 ) on it.
PHP Code:


#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#define m_pActiveItem 373
#define XO_PLAYER 5

new V_MODEL[64] = "models/new/v_ak47.mdl"
new P_MODEL[64] = "models/new/p_ak47.mdl"

new iSelectMAX_PLAYERS ];

public 
plugin_init()
{
    
register_event("CurWeapon","CurrentWeapon","be","1=1")
}

public 
CurrentWeapon(id)
{
    
replace_weapon_models(idread_data(2))
}

replace_weapon_models(idweaponid)
{
    new 
iEntID;
    
    switch ( 
weaponid )
    {
        case 
CSW_AK47:
        {
            if ( 
iSelectid ] )
            {
                
set_pev(idpev_viewmodel2V_MODEL)
                
set_pev(idpev_weaponmodel2P_MODEL)

                if ( ( 
iEntID get_pdata_cbaseid m_pActiveItem XO_PLAYER ) ) > 
                {
                    
set_peviEntID pev_iuser2 );
                }
            }            
        }
    }



Is it possible to make a switch with pev?

Bugsy 05-04-2021 17:40

Re: Pick up gun owner info
 
Of course, but why? It's either 0 or 1 in which an if-statement works fine.

FeehSK 05-04-2021 20:19

Re: Pick up gun owner info
 
Quote:

Originally Posted by Bugsy (Post 2745936)
Of course, but why? It's either 0 or 1 in which an if-statement works fine.

I will add more skin and with that more pev. I will add 3 skins. I was wondering if you have a problem using a switch


All times are GMT -4. The time now is 08:48.

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