Raised This Month: $ Target: $400
 0% 

Drop raised weapon


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Reiko1231
Member
Join Date: Apr 2013
Location: Russia
Old 04-10-2013 , 14:26   Drop raised weapon
Reply With Quote #1

How drop only raised weapon?
Supposably, player pickup awp. How make him to drop it?
Reiko1231 is offline
ajr1234
Senior Member
Join Date: Mar 2011
Location: Chicago, IL, U.S.A.
Old 04-10-2013 , 17:06   Re: Drop raised weapon
Reply With Quote #2

Set the weapon ammo to zero and then remove it from the slot. Lastly, create a new weapon entity with zero ammo and teleport it to the player's origin. Relevant functions:

RemovePlayerItem
GetPlayerWeaponSlot
CreateEntityByName

Search for those functions on alliedmods. There are many examples on dropping weapons.
ajr1234 is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 04-10-2013 , 22:49   Re: Drop raised weapon
Reply With Quote #3

Or CS_DropWeapon.
bl4nk is offline
sdz
Senior Member
Join Date: Feb 2012
Old 04-10-2013 , 23:17   Re: Drop raised weapon
Reply With Quote #4

PHP Code:
{
     
decl String:Weapon[MAX_NAME_LENGTH];
     for(new 
1GetMaxClientsX++;)
     {
          
GetClientWeapon(XWeaponsizeof(Weapon));
          if(
Weapon == "weapon_awp")
          {
               
CS_DropWeapon(X"weapon_awp"truefalse);
          }
     }

Crudely written on iPod, let me know if anything is baring, I don't use loops often.

Last edited by sdz; 04-10-2013 at 23:21.
sdz is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 04-11-2013 , 02:41   Re: Drop raised weapon
Reply With Quote #5

There are too many things wrong with the code you just posted. Something like this would be better (requires SDKHooks):
PHP Code:
public OnPluginStart() {
    for (new 
1<= MaxClientsi++) {
        if (
IsClientInGame(i)) {
            
SDKHook(iSDKHook_WeaponEquipHook_WeaponEquip);
        }
    }
}

public 
OnClientPutInServer(iClient) {
    
SDKHook(iClientSDKHook_WeaponEquipHook_WeaponEquip);
}

public 
Action:Hook_WeaponEquip(iClientiWeapon) {
    
decl String:szClassName[32];
    
GetEdictClassname(iWeaponszClassNamesizeof(szClassName));
    
    if (
strcmp(szClassName"weapon_awp") == 0) {
        
CS_DropWeapon(iClientiWeapontrue);
    }


Last edited by bl4nk; 04-11-2013 at 09:14. Reason: forgot IsClientInGame check
bl4nk is offline
Reiko1231
Member
Join Date: Apr 2013
Location: Russia
Old 04-11-2013 , 12:35   Re: Drop raised weapon
Reply With Quote #6

I got error: undefined sybmol: CS_DropWeapon.
I already include <cstrike>, and compile.exe work with CS_SwitchTeam, buy on CS_DropWeapon I see error.
How remove this error?.. Where I can get normal cstrike.inc? Or problem in sourcemod?
I copy CS_DropWeapon from cstrike.inc, wrote it by myself, and always see that error.
I get cstrike from new sourcemod (1.4.7) from official site, and problem still remain.

Last edited by Reiko1231; 04-11-2013 at 13:01.
Reiko1231 is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 04-11-2013 , 16:57   Re: Drop raised weapon
Reply With Quote #7

Here, this compiles fine for me.
Attached Files
File Type: sp Get Plugin or Get Source (dropawps.sp - 152 views - 653 Bytes)
File Type: smx dropawps.smx (3.0 KB, 57 views)
bl4nk is offline
sdz
Senior Member
Join Date: Feb 2012
Old 04-11-2013 , 21:43   Re: Drop raised weapon
Reply With Quote #8

Thanks for that Blank, I figured my code would have been pretty ratchet
sdz is offline
Reiko1231
Member
Join Date: Apr 2013
Location: Russia
Old 04-12-2013 , 11:54   Re: Drop raised weapon
Reply With Quote #9

I solved problem, but I have a new one:
When I pickup any weapon, I see in console: "CS_DropWeapon reported: Weapon X is not owned by Y client"
And player don't drop weapon. By the way, error in console only at beginning round. After two-three retry pickup error doesn't display in console, but weapon always pickup.
Reiko1231 is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 04-12-2013 , 13:43   Re: Drop raised weapon
Reply With Quote #10

I guess WeaponEquip would be too early to drop the weapon, since it's not equipped to the player just yet. Try the attached version out.
Attached Files
File Type: sp Get Plugin or Get Source (dropawps.sp - 171 views - 1.1 KB)
File Type: smx dropawps.smx (3.5 KB, 60 views)
bl4nk 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 11:07.


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