AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Approved Plugins (https://forums.alliedmods.net/forumdisplay.php?f=8)
-   -   Knife Management v3.3 by Jon (https://forums.alliedmods.net/showthread.php?t=100506)

Jon 08-15-2009 08:28

Knife Management v3.3 by Jon
 
1 Attachment(s)
Description:

A plugin intended for knife only servers. See features below.


Features:
  • Strip weapons and blocks buying
  • Respawn mode
  • No slashing on _acer maps
  • Disable spraying _wires maps
  • 3rd-person camera
  • Free hit system
  • Checks hp on 35hp and 1hp maps (as it sometimes bugs)
  • Ghost chat (dead and living can read each other's chat messages)

About free hit system:

If you've played a little knife you probably know about free hits. When two players are battling and one of them are low, he could ask the other for a free hit for the battle to be fair (a stab without the other attacking). With this system you can just press your +use key on your enemy three times and a menu will appear for him. If he accepts, your enemy's health will be set to the same as yours.


Cvars:

km_respawn 1/0 - Enable/disable respawn mode (default: 0)

km_freehits Freehits - Sets number of free hits a player can request each round, 0 = disable this feature. (default: 2)

km_camera 1/0 - If enabled, camera is allowed. (default: 1)

km_stabacer 1/0 - If enabled, players will be forced to stab on _acer maps. (default: 0)

km_ghostchat 1/0 - If enabled, dead and living can read each others chat messages. (default: 1)


Commands
:

/cam or /camera - Toggles 3rd-person camera. Can be disabled by cvar.


Credits:
  • Original free hit system idea, grimvh2

Additions:

Knife Distance by SchlumPF
No Slashing Zones by grimvh2



Jon 08-15-2009 08:28

Re: Knife Management v3.0 by Jon
 
Changelog:

1.0 -> 3.0 - Private plugin

3.0 -> 3.1 - Minor fixes and a new method for blocking buy and giving/stripping weapons. Fun and fakemeta no longer needed. Thanks to Arkshine.

3.1 -> 3.2
- Added ghostchat feature
- Added different respawn method, you now respawn by pressing your attack1 button (normally left mousebutton).
- Added removal of existing guns on maps

3.2 -> 3.21
- Fixed ghostchat bug

3.21 -> 3.22
- Removed a useless variable
- Added cstrike for team retriving

3.22 -> 3.23
- Minor optimizations

3.23 -> 3.3
- Removed that you have to click to respawn
- Now stripping and giving weapons on each spawn
- Minor code improvements

KadiR 08-15-2009 08:50

Re: Knife Management v3.0 by Jon
 
nice, gj! :mrgreen:

Arkshine 08-15-2009 09:09

Re: Knife Management v3.0 by Jon
 
It seems well coded, though there are some minor things :

- To disable buy and giving weapon, in this case, I would prefer to use keyvalue and letting the engine doing its job without any extra calls each time. And about the buy, I prefer to see the original message saying you can't buy. An example ( it's possible to use Ham_Spawn instead of pnf_keyvalue() :
Code:
    public plugin_precache()     {         new Entity;                 Entity = create_entity( "info_map_parameters" );         DispatchKeyValue( Entity, "buying", "3" );         DispatchSpawn( Entity );                 Entity = create_entity( "player_weaponstrip" );         DispatchKeyValue( Entity, "targetname", "stripper" );         DispatchSpawn( Entity );                 Entity = create_entity( "game_player_equip" );         DispatchKeyValue( Entity, "weapon_knife", "1" );         DispatchKeyValue( Entity, "targetname"  , "equipement" );         DispatchSpawn( Entity );                 Entity = create_entity( "multi_manager" );         DispatchKeyValue( Entity, "equipement", "0.5"   );         DispatchKeyValue( Entity, "stripper"  , "0"     );         DispatchKeyValue( Entity, "targetname", "game_playerspawn" );         DispatchKeyValue( Entity, "spawnflags", "1"     );         DispatchSpawn( Entity );     }         public pfn_keyvalue( Entity )     {         new ClassName[ 20 ];         new KeyName  [ 16 ];         new Value    [ 20 ];                 copy_keyvalue( ClassName, charsmax( ClassName ), KeyName, charsmax( KeyName ), Value, charsmax( Value ) );                 if ( equal( ClassName, "info_map_parameters" ) || equal( ClassName, "player_weaponstrip" ) ||              equal( ClassName, "game_player_equip" )   || equal( ClassName, "func_buyzone" ) )         {             remove_entity( Entity );             return PLUGIN_HANDLED;         }                 return PLUGIN_CONTINUE;     }
- In fwdCmdStart(), you could use directly get_user_weapon() and no need to return FMRES_SUPERCEDE, FMRES_HANDLED is enough. But I would use the weapon's offsets ( m_flNextPrimaryAttack (46) / m_flNextSecondaryAttack (47) ) to block primary/secondary knife attack, it will be more efficient and you would not need to use FM_CmdStart.
- g_iMapType & TYPE_35HP || g_iMapType & TYPE_1HP ) ; you can do g_iMapType & ( TYPE_35HP | TYPE_1HP )
- Adding ML ?
- Never tried yet, but about the respawn stuff, it may interesting to use another condition than game_playerspawn if you use keyvalue, see http://twhl.co.za/wiki.php?id=1082

That's all. :mrgreen:

KadiR 08-15-2009 09:15

Re: Knife Management v3.0 by Jon
 
wow, arkshine is a nice plugin checker :mrgreen:

Jon 08-15-2009 09:25

Re: Knife Management v3.0 by Jon
 
Thanks for your corrections and suggestions.

Quote:

Originally Posted by Arkshine (Post 900999)
But I would use the weapon's offsets ( m_flNextPrimaryAttack (46) / m_flNextSecondaryAttack (47) ) to block primary/secondary knife attack, it will be more efficient and you would not need to use FM_CmdStart.

In what forward? I haven't worked so much with offsets before.

Arkshine 08-15-2009 09:27

Re: Knife Management v3.0 by Jon
 
The best place I would think is Ham_Item_Deploy ( as post ).

Jon 08-15-2009 09:40

Re: Knife Management v3.0 by Jon
 
I found this method rather simple and satisfying:

PHP Code:

RegisterHamHam_Weapon_PrimaryAttack"weapon_knife""fwdTest" );

public 
fwdTestiEntity )
{
    
ExecuteHamHam_Weapon_SecondaryAttackiEntity );
    return 
HAM_SUPERCEDE;


Since I am switching attack and attack2.

Mouseglider 08-15-2009 09:41

Re: Knife Management v3.0 by Jon
 
Great Plugin :D

Arkshine 08-15-2009 09:48

Re: Knife Management v3.0 by Jon
 
Quote:

Since I am switching attack and attack2.
I think I've misread the code. You want to block the primary attack only. In this case, yes, your way is nice and enough.


All times are GMT -4. The time now is 11:53.

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