Raised This Month: $ Target: $400
 0% 

force to use knife


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
KamiN
Senior Member
Join Date: Jun 2011
Old 06-13-2012 , 11:39   force to use knife
Reply With Quote #1

How to force all players or some group of them to use only knife and prevent them from changing weapon? Can somebody give me an example of code please
KamiN is offline
DjOptimuS
Senior Member
Join Date: Jan 2009
Old 06-13-2012 , 11:47   Re: force to use knife
Reply With Quote #2

If you intend to use this as a WarmUp round, the most efficient way is to remove all theyre money, strip the weapons, and give_item knife.

Other method for a WarmUp round is a plugin created by Alka

Here is the code:

PHP Code:
#include <amxmodx>

#define PLUGIN "WarmUp Round"
#define VERSION "1.0"
#define AUTHOR " Alka"

new bool:WarmUp;
new 
Seconds 45;

public 
plugin_init()
{
   
register_plugin(PLUGINVERSIONAUTHOR);
   
register_event("CurWeapon""Current_Weapon""be""1=1""2!29");
   
WarmUp true;
   
set_task(120.0"RemoveWarmUp"123);
   
set_task(1.0"ShowCountDown"1234,_,_,"b",_);
}

public 
Current_Weapon(id)
{
   if(
WarmUp)
      
engclient_cmd(id"weapon_knife");
}

public 
ShowCountDown()
{

   
set_hudmessage(44441290.030.1706.01.00.10.12);
   
show_hudmessage(0"WarmUp Round :: Time Left :: %d ::"Seconds);
   
Seconds--;
   if(
Seconds <= 0)
   {

      if(
task_exists(1234))
         
remove_task(1234);
      
WarmUp false;
      
server_cmd("sv_restartround 1");
      
client_print(0print_chat"*** Restarting LIVE :: GL & HF");
      return;
   }
}
public 
RemoveWarmUp() WarmUp false

Last edited by DjOptimuS; 06-13-2012 at 11:49. Reason: Code added
DjOptimuS is offline
KamiN
Senior Member
Join Date: Jun 2011
Old 06-13-2012 , 15:57   Re: force to use knife
Reply With Quote #3

No its not for warmup round. But its all i needed
Code:
engclient_cmd(id, "weapon_knife");

Last edited by KamiN; 06-13-2012 at 15:58.
KamiN is offline
DjOptimuS
Senior Member
Join Date: Jan 2009
Old 06-13-2012 , 16:08   Re: force to use knife
Reply With Quote #4

Be carefull with engclient_cmd working with weapons, because if a user has a ak47 for example, and you force him with engclient to swicth to knife, the engine death messages will be ok, but the AMXX stats system will count as a ak47 death instead of knife.

Last edited by DjOptimuS; 06-13-2012 at 16:09.
DjOptimuS is offline
KamiN
Senior Member
Join Date: Jun 2011
Old 06-14-2012 , 07:27   Re: force to use knife
Reply With Quote #5

So do you have any alternatives?
KamiN is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 06-14-2012 , 11:24   Re: force to use knife
Reply With Quote #6

you could use strip_user_weapons(id) & give_item(id, "weapon_knife")
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Diegorkable
Veteran Member
Join Date: Jun 2011
Old 06-15-2012 , 09:24   Re: force to use knife
Reply With Quote #7

Quote:
Originally Posted by Napoleon_be View Post
you could use strip_user_weapons(id) & give_item(id, "weapon_knife")
That method isn't always safe, it causes many weapons to be created and given, can crash server in certain situations.
__________________
My Projects:

Auto-Mix (Pug): 100%

Joined the Military (a soldier now) - Inactive
Diegorkable is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 06-15-2012 , 10:29   Re: force to use knife
Reply With Quote #8

Quote:
Originally Posted by Diegorkable View Post
That method isn't always safe, it causes many weapons to be created and given, can crash server in certain situations.
I use those alot, and my server ain't crashed a single time because of that.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
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 06:11.


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