How can I check player holding a key ?
#1

Hello guys
I am editing my fire system again and I experienced a bug -
The player reduces the fire's hp only when he taps the Fire button
Which means -
100 HP at start
100 Left Button clicks - Fire is 0 HP
Instead of reducing HP when the player HOLDS the button

Code
PHP код:
if (HOLDINGKEY_FIRE ))
    {
        new 
Float:fxFloat:fyFloat:fz;
        
GetDynamicObjectPos(FireObjectfxfyfz);
        new 
string[256];
        if(
GetPlayerWeapon(playerid) == 42 || GetVehicleModel(GetPlayerVehicleID(playerid)) == 407)
        {
            if(
IsPlayerInRangeOfPoint(playerid40.0fx,  fy,  fz))
             {
                   
FireHealth -= 1;
                
format(stringsizeof(string), "%d/100%"FireHealth);
                
Update3DTextLabelText(FireTextGREENstring);
                if(
FireHealth <= 0)
                {
                    
DestroyDynamicObject(FireObject);
                    
DestroyDynamicObject(SmokeObject);
                    
Delete3DTextLabel(FireText);
                    
FireHealth 0;
                    
FireTimer SetTimer("StartRandomFire"900000false);
                    
format(stringsizeof(string), "Auto-Dispatcher: The fire that was started has been successfully put out. Continue with normal duties.");
                    foreach(new 
Player
                    {
                        if(
IsACop(i) || IsAGov(i) || IsMedic(i) || IsSASD(i))
                        {
                            
SendClientMessage(iCOLOR_DEPTRADIOstring);
                        }
                    }
                    return 
1;
                }
            }
        }
    } 
Thanks in advice
Reply
#2

If you want a gradual reduction of the health, you need a timer to check multiple times.
Reply
#3

Quote:
Originally Posted by [WSF]ThA_Devil
Посмотреть сообщение
If you want a gradual reduction of the health, you need a timer to check multiple times.
Should I do it on loop and Kill the timer when the player leaves the Fire button ?
Reply
#4

Anyone ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)