AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   User status icon don't disappear when weapon isn't he grenade (https://forums.alliedmods.net/showthread.php?t=167262)

m0skVi4a 09-13-2011 14:26

User status icon don't disappear when weapon isn't he grenade
 
Hello
I have a litle problem that i can't solve...
Here is a code
PHP Code:

public PreThink(id)
{
    new 
clipammo
    
new userweapon get_user_weapon(idclipammo)
        
    if(
userweapon == CSW_HEGRENADE && g_Weapon[id])
    {
        if(!(
pev(id,pev_button) & FL_ONGROUND))
        {    
            
message_begin(MSG_ONE,iconstatus,{0,0,0},id);
            
write_byte(1);
            
write_string("item_healthkit");
            
write_byte(255);
            
write_byte(0); 
            
write_byte(0);
            
message_end();
        }
    }


The problem is that when i change to he grenade the icon show, but after i change to he grenade when i change to other weapon, the icon stil show. I want the icon to show only when user current wepon is he grenade. How can i fixit?

Emp` 09-13-2011 15:03

Re: User status icon don't disappear when weapon isn't he grenade
 
A. Don't use prethink for this.
B. Send the message again with the first byte being 0 to remove the icon status.

m0skVi4a 09-13-2011 15:10

Re: User status icon don't disappear when weapon isn't he grenade
 
What to use else prethink

Stereo 09-13-2011 15:12

Re: User status icon don't disappear when weapon isn't he grenade
 
you need register event CurWeapon and check if the weapon is he grenade (with get_user_weapon(index) ) or not

m0skVi4a 09-13-2011 15:14

Re: User status icon don't disappear when weapon isn't he grenade
 
PHP Code:

public CurWeapon(id)
{
    new 
clipammo
    
new userweapon get_user_weapon(idclipammo)
        
    if(
userweapon == CSW_HEGRENADE && g_Weapon[id])
    {
        if(!(
pev(id,pev_button) & FL_ONGROUND))
        {    
            
message_begin(MSG_ONE,iconstatus,{0,0,0},id);
            
write_byte(1);
            
write_string("item_healthkit");
            
write_byte(255);
            
write_byte(0); 
            
write_byte(0);
            
message_end();
        }
    }
    else
    {
        if(!(
pev(id,pev_button) & FL_ONGROUND))
        {    
            
message_begin(MSG_ONE,iconstatus,{0,0,0},id);
            
write_byte(0);
            
write_string("item_healthkit");
            
write_byte(255);
            
write_byte(0); 
            
write_byte(0);
            
message_end();
        }
    }    


that?

Stereo 09-13-2011 15:27

Re: User status icon don't disappear when weapon isn't he grenade
 
Yes but:

PHP Code:

new clipammo
new userweapon get_user_weapon(idclipammo


:arrow::arrow:

PHP Code:

new userweapon get_user_weapon(id

And to hide the icon:


PHP Code:

message_begin(MSG_ONE,iconstatus,{0,0,0},id);
write_byte(0);
write_string("item_healthkit");
write_byte(255); //Unnecessary
write_byte(0); //Unnecessary
write_byte(0); //Unnecessary
message_end(); 


m0skVi4a 09-13-2011 15:36

Re: User status icon don't disappear when weapon isn't he grenade
 
Yes now work. Because you both help me i've not give any one +karma


All times are GMT -4. The time now is 01:30.

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