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

Give weapon to a player - drop the old one?


Post New Thread Reply   
 
Thread Tools Display Modes
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 06-27-2009 , 15:25   Re: Give weapon to a player - drop the old one?
Reply With Quote #11

Try this.

PHP Code:
// Global scope
new Handle:g_hDropWeapon;

public 
OnPluginStart()
{
    new 
Handle:hGameConf LoadGameConfigFile("blah.games");
    if (
hGameConf == INVALID_HANDLE)
    {
        
SetFailState("Unable to load gamedata file blah.games.txt");
    }

    
StartPrepSDKCall(SDKCall_Player);
    if (!
PrepSDKCall_SetSignature(SDKLibrary_Server"\x2A\x2A\x2A\x2A\x2A\x2A\x53\x55\x56\x57\x8B\xBC\x24\x40\x01\x00\x00\x32\xDB\x85\xFF\x8B\xF1\x0F"24))
    {
        
PrepSDKCall_SetSignature(SDKLibrary_Server"@_ZN9CCSPlayer12CSWeaponDropEP17CBaseCombatWeaponbb"0);
    }
    
PrepSDKCall_AddParameter(SDKType_CBaseEntitySDKPass_Pointer);
    
PrepSDKCall_AddParameter(SDKType_BoolSDKPass_Plain);
    
PrepSDKCall_AddParameter(SDKType_BoolSDKPass_Plain);
    
g_hDropWeapon EndPrepSDKCall();
}

// In your function
new ent;
if ((
ent GetPlayerWeaponSlot(targetslot)) != -1)
{
    
SDKCall(g_hDropWeapontargetentfalsefalse);

bl4nk is offline
~Gh05t~
Member
Join Date: Oct 2007
Old 06-30-2009 , 05:15   Re: Give weapon to a player - drop the old one?
Reply With Quote #12

Quote:
Originally Posted by bl4nk View Post
Try this.

PHP Code:
// Global scope
new Handle:g_hDropWeapon;

public 
OnPluginStart()
{
    
StartPrepSDKCall(SDKCall_Player);
    if (!
PrepSDKCall_SetSignature(SDKLibrary_Server"\x2A\x2A\x2A\x2A\x2A\x2A\x53\x55\x56\x57\x8B\xBC\x24\x40\x01\x00\x00\x32\xDB\x85\xFF\x8B\xF1\x0F"24))
    {
        
PrepSDKCall_SetSignature(SDKLibrary_Server"@_ZN9CCSPlayer12CSWeaponDropEP17CBaseCombatWeaponbb"0);
    }
    
PrepSDKCall_AddParameter(SDKType_CBaseEntitySDKPass_Pointer);
    
PrepSDKCall_AddParameter(SDKType_BoolSDKPass_Plain);
    
PrepSDKCall_AddParameter(SDKType_BoolSDKPass_Plain);
    
g_hDropWeapon EndPrepSDKCall();
}

// In your function
new ent;
if ((
ent GetPlayerWeaponSlot(targetslot)) != -1)
{
    
SDKCall(g_hDropWeapontargetentfalsefalse);

That works great! My server is Linux, so it should work for windows as well. Thanks!

@Greyscale: My solution worked, too. Only problem is, the dropped weapon is a new one (no silencer/full ammo), not the weapon the player used before. Weapons given by GivePlayerItem do always have full ammo.
~Gh05t~ is offline
Send a message via ICQ to ~Gh05t~
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 07:49.


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