AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Blocking Defuse (https://forums.alliedmods.net/showthread.php?t=47796)

The Specialist 11-26-2006 14:42

Blocking Defuse
 
Ok i need a good way to block a player from defusing the bomb. Without removing buttons. I know how to detect the bomb defuse proccess. But i need to block it after it starts . thank you.

Greenberet 11-26-2006 14:47

Re: Blocking Defuse
 
set_pev( id, pev_buttons, pev(id, pev_buttons ) & ~IN_USE )
same with oldbuttons should do the work
do this in prethink or else it will start again and again and again and again

The Specialist 11-26-2006 14:52

Re: Blocking Defuse
 
hmmmm. I didnt want to have to remove the buttons . Is that the only way to block this ?? if so it will have to do ++karma for the help :wink:

XxAvalanchexX 11-26-2006 14:53

Re: Blocking Defuse
 
You can hook when they start it and force them to execute "-use". This is what I did for one of my very first plugins, VIP Defuser 0.1 for the original AMX mod.

The Specialist 11-26-2006 14:55

Re: Blocking Defuse
 
Force them to execute ~IN_USE ?? can you explaine what you meen by this please ?:cry:

EDIT : heres my code so far but it crahsed my server .
Code:
#include <amxmodx> #include <fakemeta> new keys = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3; new g_Switch; public plugin_init() {  register_plugin("Cut The Right Wire","0.1","The Speicialist");  g_Switch = register_cvar("ctrw_switch","1");  register_menucmd(register_menuid("menu_show"),1023,"menu_choose");  register_logevent("bomb_defuse_no_kit", 3, "2=Begin_Bomb_Defuse_Without_Kit");  register_logevent("bomb_defuse_kit", 3, "2=Begin_Bomb_Defuse_With_Kit");  register_forward(FM_PlayerPreThink,"menu_choose"); } // detect defusing public bomb_defuse_no_kit() {  new id = get_loguser_index();    if(get_pcvar_num(g_Switch)==0)  {   return PLUGIN_HANDLED;  }else{   new menu[192];   format(menu,191,"Choose The Right Wire Or Die!^n1. Red^n2. Blue^n3. Green^n^n0. Die");   show_menu(id,keys,menu,-1,"menu_show");  }  return 0; } // detect defusing public bomb_defuse_kit() {  new id = get_loguser_index();    if(get_pcvar_num(g_Switch)==0)  {   return PLUGIN_HANDLED;  }else{   new menu[192];   format(menu,191,"Choose The Right Wire Or Die!^n1. Red^n2. Blue^n3. Green^n^n0. Die");   show_menu(id,keys,menu,-1,"menu_show");  }  return 0; } // remove use button and show menu public menu_choose(id,key) {  set_pev( id, pev_button, pev(id,pev_button) & ~IN_USE);  new const Time = get_cvar_num("mp_c4timer")  new wire = random(2);  switch(key)  {   case 0 :   {    if( wire == 0 )    {     set_cvar_num("mp_c4timer",(Time + 10));     return PLUGIN_HANDLED;    }else{     set_cvar_string("mp_c4timer","0");     return PLUGIN_HANDLED;    }   }   case 1:   {    if( wire == 1)    {     set_cvar_num("mp_c4timer",(Time + 10 ));     return PLUGIN_HANDLED;    }else{     set_cvar_string("mp_c4timer","0");     return PLUGIN_HANDLED;    }   }   case 2 :   {    if( wire == 2 )    {     set_cvar_num("mp_c4timer",(Time + 10 ));     return PLUGIN_HANDLED;    }else{     set_cvar_string("mp_c4timer","0");     return PLUGIN_HANDLED;    }   }  }  set_cvar_num("mp_c4timer",Time);  return PLUGIN_HANDLED; } // function to get index from log events stock get_loguser_index() {  new loguser[80], name[32];  read_logargv(0, loguser, 79);  parse_loguser(loguser, name, 31);  return get_user_index(name); }

XxAvalanchexX 11-26-2006 19:09

Re: Blocking Defuse
 
Code:
client_cmd(id,"-use");

Emp` 11-26-2006 20:44

Re: Blocking Defuse
 
or you could just give them a lil boost into the air (because you have to be on the ground to defuse)

Orangutanz 11-26-2006 21:07

Re: Blocking Defuse
 
If you are going to start blocking buttons its best to use CmdStart:
Code:
register_forward(FM_CmdStart, "CmdStart") public CmdStart(id, uc_handle, random_seed) {     if(!is_user_alive(id)) return FMRES_IGNORED     static buttons     buttons = get_uc(uc_handle, UC_Buttons)     if(buttons & IN_USE) buttons &= ~IN_USE     set_uc(uc_handle, UC_Buttons, buttons)     return FMRES_IGNORED }
Reason above method is more efficient is that it handles when buttons etc do something whereas using PreThink it doesn't.

The Specialist 11-27-2006 05:05

Re: Blocking Defuse
 
Ah, I think i got it now. Thanks for all the help guys ++karma:up:

Greenberet 11-30-2006 08:44

Re: Blocking Defuse
 
you dont need the
Code:
if(buttons & IN_USE)
part.
you can remove this

Code:
register_forward(FM_CmdStart, "CmdStart") public CmdStart(id, uc_handle, random_seed) {     if(!is_user_alive(id)) return FMRES_IGNORED     static buttons     buttons = get_uc(uc_handle, UC_Buttons)     buttons &= ~IN_USE     set_uc(uc_handle, UC_Buttons, buttons)     return FMRES_IGNORED }


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

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