Help with Anti Avoid Death
#1

I got some teleports commands and a /heal command to refill health, i want to add : that the player must wait 10 seconds before using them from the last damage.
/heal command:
pawn Код:
CMD:heal(playerid,params[])
{
    GivePlayerMoney(playerid, -500);
    SetPlayerHealth(playerid, 100.0);
    return 1;
}
+Rep for helpers!!!
Reply
#2

pawn Код:
//in the beginning
new bool:recentlydamaged[MAX_PLAYERS];

//Under OnPlayerTakeDamage:
recentlydamaged[playerid] = true;
SetTimerEx("RecentDTimer", 10000, 0, "d", playerid);

//the timer
forward RecentDTimer(playerid);
public RecentDTimrt(playerid) return recentlydamaged[playerid] = false;

//your cmd
CMD:heal(playerid,params[])
{
    if(recentlydamaged[playerid]) return SendClientMessage(playerid, -1, "ERROR: You have been recently damaged");
    GivePlayerMoney(playerid, -500);
    SetPlayerHealth(playerid, 100.0);
    return 1;
}
Reply
#3

I believe in this particular case using timers is not a necessary, you can use gettime() instead.
Reply
#4

Yeah, that would be more efficient
Reply
#5

or Gettickcount ,??
Reply
#6

pawn Код:
//in the beginning
new count[MAX_PLAYERS];

//Under OnPlayerTakeDamage:
count[playerid] = GetTickCount();

//your cmd
CMD:heal(playerid,params[])
{
    if(GetTickCount() - count[playerid]  > 10000) return SendClientMessage(playerid, -1, "ERROR: You have been recently damaged");
    GivePlayerMoney(playerid, -500);
    SetPlayerHealth(playerid, 100.0);
    return 1;
}
Reply
#7

Thanks!!! +Rep !
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)