SA-MP Forums Archive
Setting a timer - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Setting a timer (/showthread.php?tid=636470)



Setting a timer - aoky - 27.06.2017

PHP код:
if (PlayerHealth <= 25)
        {
        if(
Character[hitid][BrutalM] == && playerid != INVALID_PLAYER_ID)
           {
            
GetPlayerPos(hitidBMPos[hitid][0], BMPos[hitid][1], BMPos[hitid][2]);
            
Character[hitid][BrutalM] = 1;
            
Character[hitid][CanAccept] = 0;
            
LegHit[hitid] = 0;
            
ApplyAnim(hitid);
            
AllowDamage[playerid] = 1;
            
SetTimerEx("AllowDamageTimer"3000false"i"playerid);
            
format(DTextSsizeof(DTextS), "(( %s is currently injured, type /damages %i for more info. ))"GetName(hitid), hitid);
            
label[hitid] = Create3DTextLabel(DTextSCOLOR_REDBMPos[hitid][0], BMPos[hitid][1], BMPos[hitid][2], 10.00);
            
Attach3DTextLabelToPlayer(label[hitid], hitid000.7);
            
ClearPlayerWeapons(hitid);
            
format(strsizeof(str),"%s was brutally wounded by %s.",GetRoleplayName(hitid),GetRoleplayName(playerid));
            
SendAdminsMessage(1COLOR_REDstr); 
This is the main bit. It's not putting him into BrutalM = 1; because damage gets returned as 0; due to the AllowDamage function.
PHP код:
AllowDamage[playerid] = 1;
      
SetTimerEx("AllowDamageTimer"3000false"i"playerid); 
PHP код:
public AllowDamageTimer(playerid)
{
    
AllowDamage[playerid] = 1;

PHP код:
    if(AllowDamage[hitid] == 1)
    {
    return 
1;
     }
    if(
AllowDamage[hitid] == 0)
    {
    return 
0;
    } 
How else can I do this to make it so when BrutalM = 1; he can't take damage for 3 seconds?



Re: Setting a timer - NaS - 27.06.2017

Use a new variable (eg. "AllowDamageTick") and save the tick count instead of setting the timer (returned by GetTickCount()).

When getting damage, do GetTickCount() - AllowDamageTick and if that value is greater than 3000 set AllowDamage to 1 again, otherwise deny the damage.

Also, when a player gets brutally wounded, shouldn't it set

Код:
AllowDamage[playerid] = 0;
instead of setting it to 1?