SA-MP Forums Archive
If a player stands 1m away from another player the person who has been approached gets 100HP. - 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: If a player stands 1m away from another player the person who has been approached gets 100HP. (/showthread.php?tid=348829)



If a player stands 1m away from another player the person who has been approached gets 100HP. - cloudysky - 06.06.2012

Hi, I'm trying to get it so when a player is 1m away from ANY other player on the server it gives the player who has been approached 100hp. I'm not entirely sure how to do this, I tried with OnPlayerUpdate, but I all i can think of is that the player would have to enter an ID, which I don't want.


Re: If a player stands 1m away from another player the person who has been approached gets 100HP. - milanosie - 06.06.2012

just loop trough all players and check if the player is near any of those players..


Re: If a player stands 1m away from another player the person who has been approached gets 100HP. - cloudysky - 06.06.2012

Do you mind giving me an example? I would appreciate that.


Re: If a player stands 1m away from another player the person who has been approached gets 100HP. - milanosie - 06.06.2012

Quote:
Originally Posted by cloudysky
Посмотреть сообщение
Do you mind giving me an example? I would appreciate that.
Sure

pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
    if(IsPlayerConnected(i))
    {
        new Float:x, Float:y, Float:z;
        GetPlayerPos(i, x, y, z);
        if(IsPlayerInRangeOfPoint(playerid, 1.0, x, y, z))
        {
            SetPlayerHealth(playerid, 100);
        }
    }
}



Re: If a player stands 1m away from another player the person who has been approached gets 100HP. - cloudysky - 06.06.2012

Thank you very much.