01.10.2010, 10:14
Can anyone help me, im trying to do like if you are near certin NPC then you will lose hp how can i do like that?
//Somewhere in your script, best would be after you created the npc
SetTimerEx("DamagePlayersInRange", damage_interval, 1, "iff", npcid, range, damage);
forward public DamagePlayersInRange(npcid, Float:range, Float:damage);
public DamagePlayersInRange(npcid, Float:range, Float:damage)
{
new Float:x, Float:y, Float:z;
new Float:hp;
GetPlayerPos(npcid, x, y, z);
for(new i = 0; i < MAX_PLAYERS; i ++)
{
if(!IsPlayerConnected(i)) continue;
if(IsPlayerInRangeOfPoint(i, range, x, y, z))
{
GetPlayerHealth(i, hp);
SetPlayerHealth(i, hp - damage);
}
}