07.02.2010, 10:22
Hey, Im a newb with timers, just look at this, how to kill the regernation timer after you have full health?
/takedrugs cmd:
Regernation function:
/takedrugs cmd:
Код:
if (strcmp("/takedrugs",cmdtext,true)==0) { if(pInfo[playerid][HasDrugs] == 0) { SendClientMessage(playerid, 0xFF0000AA, "Error: You don't have any drugs to take!"); } else { SetTimer("Regernation",5000,true); SendClientMessage(playerid, 0xFFFF00AA, "You took the drugs! You will regernate health every 10 seconds!"); pInfo[playerid][HasDrugs] = 0; SetPlayerDrunkLevel(playerid, 1000); } return 1; }
Код:
forward Regernation(playerid); public Regernation(playerid) { new Float:Health; GetPlayerHealth(playerid, Health); SetPlayerHealth(playerid, Health + 10.0); if(Health >= 100) { pInfo[playerid][OnDrugs] = 0; SetPlayerDrunkLevel(playerid, 0); SendClientMessage(playerid, 0xFFFF00AA, "You are now not on drugs anymore!"); KillTimer("Regernation"); } return 1; }