Raised This Month: $7 Target: $400
 1% 

[L4D2] Drop weapon when punched (v1.1)


Post New Thread Reply   
 
Thread Tools Display Modes
Author
cheewongken
Senior Member
Join Date: Feb 2009
Plugin ID:
1949
Plugin Version:
1.1
Plugin Category:
Gameplay
Plugin Game:
Left 4 Dead
Plugin Dependencies:
    Servers with this Plugin:
    4 
    Plugin Description:
    Survivors will drop their weapon when they get punched by a tank.
    Old 09-13-2010 , 01:06   [L4D2] Drop weapon when punched (v1.1)
    Reply With Quote #1

    [L4D2] Drop weapon when punched (v1.1)

    About:
    This is my first plugin that I'm posting here. I didn't notice anything like this when I got the idea... It makes you drop your weapon (Primary and Secondary only) when you get hit by a tank. To be fair your pistols/magnum will not be removed and you will be given a pistol if your melee weapon is dropped (as if you were incapacitated). This pistol will automatically be removed when you pick up another secondary weapon (other than a pistol)

    Cvars:
    l4d2_dwp_version
    - Self explanatory

    l4d2_dwp_enabled (Default: 1)
    - Is plugin enabled? 1=Yes, 0=No

    l4d2_dwp_drop_chainsaw (Default: 1)
    - Will you drop chainsaw if you get hit? 1=Yes, 0=No

    l4d2_dwp_drop_melee (Default: 1)
    - Will you drop melee weapon if you get hit? 1=Yes, 0=No

    l4d2_dwp_drop_when_incapped (Default: 0)
    - Will you drop weapon if you get incapped? 1=Yes, 0=No

    l4d2_dwp_give_pistol (Default: 1)
    - Will you get a pistol if you drop your melee weapon? 1=Yes, 0=No

    Note:
    • Occasionally when a tank hits you, his fist will hit the weapon as well. You will see the weapon speed off into the sky at high speed. The weapon can still be found though.

    Changelog
    v1.1
    Did as Silvers suggested
    v1.0
    Release

    Credits:
    Machine (for [L4D2] Weapon Drop)
    McFlurry (for [L4D2] Melee Mode v1.6.3 *Update*)
    mi123645 (for a bit of code i used)
    CrazzyMonkey (for testing it out)
    and the rest is mentioned in the source.
    Attached Files
    File Type: sp Get Plugin or Get Source (l4d2_drop_punched.sp - 3283 views - 12.2 KB)

    Last edited by cheewongken; 10-12-2010 at 01:17.
    cheewongken is offline
    CrazzyMonkey
    Junior Member
    Join Date: Aug 2010
    Old 09-13-2010 , 07:51   Re: [L4D2] Drop weapon when punched (v1.0)
    Reply With Quote #2

    The plugin works now!
    CrazzyMonkey is offline
    phoenix0001
    Senior Member
    Join Date: Apr 2010
    Location: China
    Old 10-09-2010 , 04:57   Re: [L4D2] Drop weapon when punched (v1.0)
    Reply With Quote #3

    Code:
    L 10/09/2010 - 16:03:37: SourceMod error session started
    L 10/09/2010 - 16:03:37: Info (map "c2m3_coaster") (file "errors_20101009.log")
    L 10/09/2010 - 16:03:37: [SM] Native "GetClientTeam" reported: Client index 0 is invalid
    L 10/09/2010 - 16:03:37: [SM] Displaying call stack trace for plugin "l4d2_drop_punched.smx":
    L 10/09/2010 - 16:03:37: [SM]   [0]  Line 111, /home/groups/alliedmodders/forums/files/4/7/8/2/7/73297.attach::PlayerHit()
    L 10/09/2010 - 16:24:05: Error log file session closed.
    L 10/09/2010 - 16:32:25: SourceMod error session started
    L 10/09/2010 - 16:32:25: Info (map "c2m4_barns") (file "errors_20101009.log")
    L 10/09/2010 - 16:32:25: [SM] Native "GetClientTeam" reported: Client index 0 is invalid
    L 10/09/2010 - 16:32:25: [SM] Displaying call stack trace for plugin "l4d2_drop_punched.smx":
    L 10/09/2010 - 16:32:25: [SM]   [0]  Line 111, /home/groups/alliedmodders/forums/files/4/7/8/2/7/73297.attach::PlayerHit()
    L 10/09/2010 - 16:51:59: Error log file session closed.
    __________________
    I like this BBS sharing of spirit

    I come from China, my English is poor
    phoenix0001 is offline
    cheewongken
    Senior Member
    Join Date: Feb 2009
    Old 10-09-2010 , 08:55   Re: [L4D2] Drop weapon when punched (v1.0)
    Reply With Quote #4

    I'll look into it when i get home tomorrow. Were you taking damage from the world at the time?
    cheewongken is offline
    cheewongken
    Senior Member
    Join Date: Feb 2009
    Old 10-10-2010 , 06:56   Re: [L4D2] Drop weapon when punched (v1.0)
    Reply With Quote #5

    Hey, I can't replicate that error.. can you tell me what was going on at the time?
    cheewongken is offline
    Silvers
    SourceMod Plugin Approver
    Join Date: Aug 2010
    Location: SpaceX
    Old 10-11-2010 , 00:22   Re: [L4D2] Drop weapon when punched (v1.0)
    Reply With Quote #6

    You should check that client is not invalid on line 111. Invalid being 0. Clients start from an index of 1. The IsValidClient() function does this, but you put GetClientTeam before the function checks.

    PHP Code:
    if (IsValidClient(attacker) && GetClientTeam(client) == && IsPlayerTank(attacker)) 


    Quote:
    Note: Registers all playable classes (Hunter, Smoker, Boomer, Tank, Survivors). See infected_hurt for Witch and Common Infected

    userid user ID who was hurt
    attacker user id who attacked
    attackerentid entity id who attacked, if attacker not a player, and userid therefore invalid
    I'm assuming the userID can also be invalid, like the player_death event. Bit cryptic if you ask me

    Hope it helps
    __________________
    Silvers is offline
    pisdone
    Member
    Join Date: Sep 2010
    Location: Italy
    Old 10-14-2010 , 13:05   Re: [L4D2] Drop weapon when punched (v1.1)
    Reply With Quote #7

    Gonna give it a try...maybe it will make coop a bit more hardcore ;)
    pisdone is offline
    KyleS
    SourceMod Plugin Approver
    Join Date: Jul 2009
    Location: Segmentation Fault.
    Old 10-04-2012 , 22:24   Re: [L4D2] Drop weapon when punched (v1.1)
    Reply With Quote #8

    Nice plugin!

    Manually adding to your ammo offset is a bit sketch You should probably also add an else check in your DropSlot function to see if a weapon is actually 'dropped', otherwise I can see an error happening when the client has no weapons and is hit.

    Regardless, cool concept
    KyleS is offline
    eyub
    Junior Member
    Join Date: Mar 2013
    Old 04-21-2013 , 14:31   Re: [L4D2] Drop weapon when punched (v1.1)
    Reply With Quote #9

    I have a request - is it possible to create a new mod so that when you are holding a pipebomb/molotov/bile and get punched - those objects go flying as well?

    Example) Tank punches you while you are holding the molotov in hand..... molotov goes flying and bursts on the ground somewhere.
    eyub is offline
    chatyak
    Senior Member
    Join Date: Aug 2011
    Old 12-19-2013 , 19:49   Re: [L4D2] Drop weapon when punched (v1.1)
    Reply With Quote #10

    Doesn't seem to be working anymore after the update.
    chatyak is offline
    Reply


    Thread Tools
    Display Modes

    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 22:49.


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