AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   force to use knife (https://forums.alliedmods.net/showthread.php?t=187457)

KamiN 06-13-2012 11:39

force to use knife
 
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 :)

DjOptimuS 06-13-2012 11:47

Re: force to use knife
 
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


KamiN 06-13-2012 15:57

Re: force to use knife
 
No its not for warmup round. But its all i needed
Code:

engclient_cmd(id, "weapon_knife");

DjOptimuS 06-13-2012 16:08

Re: force to use knife
 
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.

KamiN 06-14-2012 07:27

Re: force to use knife
 
So do you have any alternatives?

Napoleon_be 06-14-2012 11:24

Re: force to use knife
 
you could use strip_user_weapons(id) & give_item(id, "weapon_knife")

Diegorkable 06-15-2012 09:24

Re: force to use knife
 
Quote:

Originally Posted by Napoleon_be (Post 1728628)
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.

Napoleon_be 06-15-2012 10:29

Re: force to use knife
 
Quote:

Originally Posted by Diegorkable (Post 1729204)
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.


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

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