AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Tuning off public method on menu select (https://forums.alliedmods.net/showthread.php?t=121053)

reinert 03-11-2010 05:51

Tuning off public method on menu select
 
Why the hell this script is working wrong ? when i choose bullet damage mode. it shows damage done, but i can't turn it off anymore after 1 us

The actual problem is that the Bullet Mode won't turn off correctly. because when i turn it off, the "public on_damage" won't check player again, it checks only on plugin load ;(

PHP Code:

#include <amxmodx>

 
new bool:BulletMode[33] = false;
 new 
bool:VampireMode[33] = false;

 public 
plugin_init()
 {
    
register_plugin("TEST""1.0""Addinol");
    
    
register_event("Damage""on_damage""b""2!0""3=0""4!0")

    
g_MsgSync CreateHudSyncObj()

#if defined DAMAGE_RECIEVED
    
g_MsgSync2 CreateHudSyncObj()
#endif
 
}


 public 
Menu(id)
 {

    new 
menu menu_create("\rPLAYER Menu:""menu_handler");


    
//Now lets add some things to select from the menu
    
menu_additem(menu"\wBullet Mode""1"0);
    
menu_additem(menu"\wVampire Mode""1"0);


    
menu_setprop(menuMPROP_EXITMEXIT_ALL);


    
menu_display(idmenu0);
 }
 public 
menu_handler(idmenuitem)
 {
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu);

        return 
PLUGIN_HANDLED;
    }

    new 
data[6], iName[64];
    new 
accesscallback;

    
menu_item_getinfo(menuitemaccessdata,5iName63callback);

    new 
key str_to_num(data);
    switch(
key)
    {
        case 
1:
        {
      
BulletMode[id] = true;
      
VampireMode[id] = false;
          
client_print(idprint_chat"Bullet Damage activated");
          
menu_destroy(menu);
          return 
PLUGIN_HANDLED;
        }
        case 
2:
        {
      
BulletMode[id] = false;
      
VampireMode[id] = true;
          
client_print(idprint_chat"Vampire Mode activated");
          
menu_destroy(menu);
          return 
PLUGIN_HANDLED;
        }
    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;
 }

public 
on_damage(id)
{
    new 
attacker get_user_attacker(id)

#if defined DAMAGE_RECIEVED

    
if ( is_user_connected(id) && is_user_connected(attacker) )
    if (
get_user_flags(attacker) & ADMIN_LEVEL_H && BulletMode[id] == true)
    {
        new 
damage read_data(2)

        
set_hudmessage(255000.450.5020.14.00.10.1, -1)
        
ShowSyncHudMsg(idg_MsgSync2"%i^n"damage)
#else
    
if ( BulletMode[id] == true && get_user_flags(attacker) & ADMIN_LEVEL_H )
    {
        new 
damage read_data(2)
#endif
        
set_hudmessage(0100200, -1.00.5520.14.00.020.02, -1)
        
ShowSyncHudMsg(attackerg_MsgSync"%i^n"damage)
    }else{
    return 
PLUGIN_HANDLED;
}
    return 
PLUGIN_HANDLED;



shuttle_wave 03-11-2010 06:37

Re: Tuning off public method on menu select
 
u dont need to destroy menu on every option

reinert 03-11-2010 07:06

Re: Tuning off public method on menu select
 
ok but the problem is when I use Bullet Mode, the Bullet Damage turn on, everything is good, but then on next round I want to use Vampire mode, but the Bullet Mode won't turn off, I Still can see damage done.

Backstabnoob 03-11-2010 09:28

Re: Tuning off public method on menu select
 
Then check it on every round start, or how often you want it.

reinert 03-11-2010 09:34

Re: Tuning off public method on menu select
 
Hmm it would be great if I could know how to do it :)

Backstabnoob 03-11-2010 12:46

Re: Tuning off public method on menu select
 
How do you call the menu?

reinert 03-11-2010 15:56

Re: Tuning off public method on menu select
 
PHP Code:

    register_clcmd("say /vipmenu","vipmenu"ADMIN_LEVEL_H


PHP Code:

public vipmenu(id) {    

   if(
get_user_flags(id) & ADMIN_LEVEL_H)
   {
    if (
playerUsedVipMenu[id] == true)
    {
        
client_print(idprint_chat"you can use vipmenu once per round");
        return 
PLUGIN_HANDLED;
    }
    
Menu(id);
    
playerUsedVipMenu[id] = true;
    return 
PLUGIN_HANDLED;
   }else{
       
client_print(idprint_chat"vipmenu only for vips");       
    }
   return 
PLUGIN_HANDLED;




All times are GMT -4. The time now is 08:36.

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