SA-MP Forums Archive
Encosto aparece mensagem? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: Encosto aparece mensagem? (/showthread.php?tid=612452)



Encosto aparece mensagem? - oDenniS - 18.07.2016

Galera tem alguma funзгo que tipo, eu chego perto do player, encosto nele e aparece uma mensagem?


Respuesta: Encosto aparece mensagem? - XandyMello - 18.07.2016

Tem sim. Terб que verificar se um player estб prуximo ao outro em um looping.

@Edit
Olha, use isso como lуgica, eu nгo testei mais acredito que irб funcionar.

pawn Код:
public OnPlayerUpdate(playerid)
    {
        for(new i = 0; i <MAX_PLAYERS; ++i)
        {
            if(ProxDetectorS(2.0, playerid, i)) SendClientMessage(playerid, -1, "Estou perto de vocк.");
        }
    }
pawn Код:
forward ProxDetectorS(Float:radi, playerid, targetid);
public ProxDetectorS(Float:radi, playerid, targetid)
{
    if(IsPlayerConnected(playerid)&&IsPlayerConnected(targetid))
    {
        new Float:posx, Float:posy, Float:posz;
        new Float:oldposx, Float:oldposy, Float:oldposz;
        new Float:tempposx, Float:tempposy, Float:tempposz;
        GetPlayerPos(playerid, oldposx, oldposy, oldposz);
        GetPlayerPos(targetid, posx, posy, posz);
        tempposx = (oldposx -posx);
        tempposy = (oldposy -posy);
        tempposz = (oldposz -posz);
        if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
        {
            return 1;
        }
    }
    return 0;
}