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

Change player's weapons with fakemeta


Post New Thread Reply   
 
Thread Tools Display Modes
NiHiLaNTh
Way Past Expiration
Join Date: May 2009
Location: Latvia
Old 09-24-2017 , 04:32   Re: Change player's weapons with fakemeta
Reply With Quote #11

VIP cannot receive any weapons apart from knife and handguns and [maybe] grenades. That's the limitation of the game.
__________________


Last edited by NiHiLaNTh; 09-24-2017 at 04:32.
NiHiLaNTh is offline
Send a message via Skype™ to NiHiLaNTh
Spirit_12
Veteran Member
Join Date: Dec 2012
Location: Toronto, CA
Old 09-24-2017 , 05:55   Re: Change player's weapons with fakemeta
Reply With Quote #12

Quote:
Originally Posted by NiHiLaNTh View Post
VIP cannot receive any weapons apart from knife and handguns and [maybe] grenades. That's the limitation of the game.
Not entirely true. I was able to find a way around it.
__________________
Spirit_12 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 09-24-2017 , 07:13   Re: Change player's weapons with fakemeta
Reply With Quote #13

You can't simply set some private data and change weapon, you need to create an entity and touch that entity with a player.
give_item does that, but it not work on vip because in CBasePlayerItem:: DefaultTouch game checks for vip and what weapon you want to give. In order to enable give_item on a vip player you can use the following code:

PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>
#include <engine>
#include <orpheu>
#include <orpheu_advanced>
#include <fun>

#if AMXX_VERSION_NUM < 183

#define INT_BYTES        4 
#define BYTE_BITS        8 

stock bool:get_pdata_bool(entcharbased_offsetintbase_linuxdiff 5

    return !!( 
get_pdata_int(entcharbased_offset INT_BYTESintbase_linuxdiff) & (0xFF<<((charbased_offset INT_BYTES) * BYTE_BITS)) ) 

#endif

const m_pfnTouch  5
const XoPfnTouch  1
const m_bIsVIP    837
 
public plugin_init()
{
    
/*
        | HACK
        | Instead of making a signature we simply create a weapon entity(can be any weapon)
        | Then we retrieve the touch function address from m_pfnTouch and hook DefaultTouch from that address
    */
    
new WeaponEntity create_entity("weapon_ak47")
    
ExecuteHamB(Ham_SpawnWeaponEntity)
    
    new 
DefaultTouchAddress get_pdata_int(WeaponEntitym_pfnTouchXoPfnTouch)

    if(
DefaultTouchAddress)
    {
        new 
OrpheuFunction:DefaultTouchFunction OrpheuCreateFunction(DefaultTouchAddress"DefaultTouch""CBasePlayerItem")
        
OrpheuRegisterHook(DefaultTouchFunction"CBasePlayerItem_DefaultTouch"OrpheuHookPre)
        
remove_entity(WeaponEntity)
    }
    
    
register_clcmd("test""ClientCommand_Test")
    
}

public 
ClientCommand_Test(id)
{
    
give_item(id"weapon_m4a1")
}

public 
OrpheuHookReturn:CBasePlayerItem_DefaultTouch(const Item, const id)
{
    if(
pev_valid(Item))
    {
        if(
is_user_alive(id))
        {
            if(
get_pdata_bool(idm_bIsVIP))
            { 
                if(
ExecuteHamB(Ham_AddPlayerItemidItem))
                {
                    
ExecuteHamB(Ham_Item_AttachToPlayerItemid)
                    
emit_sound(idCHAN_ITEM"items/gunpickup2.wav"VOL_NORMATTN_NORM0PITCH_NORM)
                }

                return 
OrpheuSupercede
            
}
        }
    }
    
    return 
OrpheuIgnored

Create a file called DefaultTouch in addons/amxmodx/configs/orpheu/functions/CBasePlayerItem
Code:
{
    "name"      : "DefaultTouch",
    "class"     : "CBasePlayerItem",
    "library"   : "mod",
    "arguments" :
    [
        {
            "type"  : "CBaseEntity *"
        }
    ]
}
To test, simply write "test" in console as a vip player and you'll see you get an m4a1.

Or you can try another way: set m_bIsVIP to false before give_item and to true after.
__________________

Last edited by HamletEagle; 09-24-2017 at 07:16.
HamletEagle is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 09-24-2017 , 08:39   Re: Change player's weapons with fakemeta
Reply With Quote #14

Cstrike have a native to check if a player is VIP. Check if is_user_alive instead of is_user_connected.

P.S: I didn't see the second page
__________________









Last edited by CrazY.; 09-24-2017 at 08:39.
CrazY. is offline
Spirit_12
Veteran Member
Join Date: Dec 2012
Location: Toronto, CA
Old 09-25-2017 , 20:52   Re: Change player's weapons with fakemeta
Reply With Quote #15

I was looking at increase vip bullets plugin. Connor has used pdata in that method. Was it only because it is a modification to clients inventory as opposed to adding an item?
__________________
Spirit_12 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 09-26-2017 , 00:56   Re: Change player's weapons with fakemeta
Reply With Quote #16

Most likely yes. Ammo are stored in offsets.
__________________
HamletEagle is offline
Reply



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 09:42.


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