AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Dropping pistol while carrying shield (https://forums.alliedmods.net/showthread.php?t=195196)

Misery 09-04-2012 15:18

Dropping pistol while carrying shield
 
Hi,

Say a CT has both a USP and a shield. Now, I'd like my plugin to make that CT drop the USP without dropping the shield.

This is problematic... engclient_cmd(id, "drop", "weapon_usp") will not work : the shield is dropped, but not the usp. How can I do that?

Cordially,
Misery

Alekkkk 09-04-2012 15:58

Re: Dropping pistol while carrying shield
 
First thing i have in mind is that you can hook "drop" command and check if player have shield. Then you can take the pistol from the player .

Misery 09-04-2012 17:35

Re: Dropping pistol while carrying shield
 
Sorry, I don't get you?
If I "drop weapon_usp" while shield is "true", the shield will be dropped first. If I do another "drop weapon_usp", this time the USP will be dropped. But... the problem is that I don't want to make the player drop the shield, only the USP.

Liverwiz 09-05-2012 00:26

Re: Dropping pistol while carrying shield
 
try locking the weapon to knife while the shield is true. This way you don't need to force weapon dropping (which you'll just pick up anyway) and piss off clients.

Misery 09-05-2012 01:06

Re: Dropping pistol while carrying shield
 
Not really the best way... don't really like to get around what I initially wanted with a hackfix.
There's really absolutely no way? How can this even be possible... after all, that should be a simple operation.

Any low level/Orpheu based solution? Hamsandwich?

OvidiuS 09-05-2012 01:38

Re: Dropping pistol while carrying shield
 
It's not the way you wanted, but it can help you.
https://forums.alliedmods.net/showthread.php?t=131579

ConnorMcLeod 09-05-2012 01:51

Re: Dropping pistol while carrying shield
 
Try this :
PHP Code:

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

#define PLUGIN "Drop Gun Before Shield"
#define VERSION "0.0.1"

#define INT_BYTES        4
#define BYTE_BITS        8

#define m_pActiveItem 373
#define m_bHasShield 2043

public plugin_init()
{
    
register_pluginPLUGINVERSION"ConnorMcLeod" )
    
register_clcmd("drop""ClCmd_Drop")
}

public 
ClCmd_Dropid )
{
    if( 
is_user_alive(id) && get_pdata_bool(idm_bHasShield) )
    {
        new 
iActiveWeapon get_pdata_cbase(idm_pActiveItem)
        if( 
iActiveWeapon && ExecuteHam(Ham_Item_ItemSlotiActiveWeapon) == )
        {
            
set_pdata_bool(idm_bHasShieldfalse)
            
engclient_cmd(id"drop")
            
set_pdata_bool(idm_bHasShieldtrue)
            new 
iActiveWeapon get_pdata_cbase(idm_pActiveItem)
            if( 
iActiveWeapon )
            {
                
ExecuteHamB(Ham_Item_DeployiActiveWeapon)
            }
            return 
PLUGIN_HANDLED
        
}
    }
    return 
PLUGIN_CONTINUE
}

bool:get_pdata_bool(entcharbased_offsetintbase_linuxdiff 5)
{
    return !!( 
get_pdata_int(entcharbased_offset INT_BYTESintbase_linuxdiff) & (0xFF<<((charbased_offset INT_BYTES) * BYTE_BITS)) )
}

set_pdata_bool(entcharbased_offsetbool:valueintbase_linuxdiff 5)
{
    
set_pdata_char(entcharbased_offset_:valueintbase_linuxdiff)
}

set_pdata_char(entcharbased_offsetvalueintbase_linuxdiff 5)
{
    
value &= 0xFF
    
new int_offset_value get_pdata_int(entcharbased_offset INT_BYTESintbase_linuxdiff)
    new 
bit_decal = (charbased_offset INT_BYTES) * BYTE_BITS
    int_offset_value 
&= ~(0xFF<<bit_decal// clear byte
    
int_offset_value |= value<<bit_decal
    set_pdata_int
(entcharbased_offset INT_BYTESint_offset_valueintbase_linuxdiff)
    return 
1




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

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