[help] lose hp when near NPC how can i do ?
#1

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?
Reply
#2

pawn Код:
//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);
        }
}
Untested as always
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)