AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Turning off mode (https://forums.alliedmods.net/showthread.php?t=120555)

reinert 03-06-2010 03:16

Turning off mode
 
Hi everybody, i got an menu like:

awp mode
knife mode
vampire mode
bullet mode

when u turn on a mode like Vampire mode, you get +5hp for kill and +10hp for headshot. but when i turn to awp mode, anyways vampire mode is applied to me, and still im getting +5/+10hp.
PHP Code:

public hook_death(id)
{
   
// Killer id
   
nKiller read_data(1)

   if ( (
read_data(3) == 1) && (read_data(5) == 0) )
   {
      
nHp_add get_pcvar_num (health_hs_add)
   }
   else
      
nHp_add get_pcvar_num (health_add)

   
nHp_max get_pcvar_num (health_max)

   
// Updating Killer HP
   
if(get_user_flags(nKiller) & ADMIN_LEVEL_H && vampiremode[id] == 1)
   
   
nKiller_hp get_user_health(nKiller)
   
nKiller_hp += nHp_add
   

   
// Maximum HP check
   
if (nKiller_hp nHp_maxnKiller_hp nHp_max
   set_user_health
(nKillernKiller_hp)
   


same thing is with Bullet mode, when its on i see Bullet_damage and when i switch it to another mode i still see damage.

worldspawn 03-06-2010 03:57

Re: Turning off mode
 
use booleans
Code:

new bool:is_vampire_active = false
when you press key in a menu(to activate vampire mode),
Code:

is_vampire_active = true
and when you hook deathmsg, check if this boolean is true to perform actions

PHP Code:

public hook_death(id

   if (
is_vampire_active == false
         return; 
   
// Killer id 
   
nKiller read_data(1

   if ( (
read_data(3) == 1) && (read_data(5) == 0) ) 
   { 
      
nHp_add get_pcvar_num (health_hs_add
   } 
   else 
      
nHp_add get_pcvar_num (health_add

   
nHp_max get_pcvar_num (health_max

   
// Updating Killer HP 
   
if(get_user_flags(nKiller) & ADMIN_LEVEL_H && vampiremode[id] == 1
    
   
nKiller_hp get_user_health(nKiller
   
nKiller_hp += nHp_add 
    

   
// Maximum HP check 
   
if (nKiller_hp nHp_maxnKiller_hp nHp_max 
   set_user_health
(nKillernKiller_hp
    



worldspawn 03-06-2010 04:06

Re: Turning off mode
 
lag

reinert 03-06-2010 08:14

Re: Turning off mode
 
Yes, but the problem is, when i turn off the mode, its still on, on the same round.

like when i choose other mode, the Bullet_Damage action is still working. I need a code that will turn off it or just check the public again after choosing it method. Because it only checks when round starts.


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

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