Portal SAMP
[Ajuda] Como detectar se um player esta nadando? - Versão de Impressão

+- Portal SAMP (https://portalsamp.com)
+-- Fórum: SA-MP (https://portalsamp.com/forumdisplay.php?fid=5)
+--- Fórum: Área de suporte (https://portalsamp.com/forumdisplay.php?fid=6)
+--- Tópico: [Ajuda] Como detectar se um player esta nadando? (/showthread.php?tid=3004)



Como detectar se um player esta nadando? - Murilo Cod - 18/11/2022

Como eu posso detectar se um player esta nadando?


RE: Como detectar se um player esta nadando? - White_Blue - 18/11/2022

Tem uma include bem legal que adiciona algumas callbacks úteis para o SA-MP. E nela tem a callback IsPlayerSwimming(playerid) onde é possível verificar se o player está nadando.

Você também pode usar GetPlayerAnimationIndex.


Include:
https://github.com/emmet-jones/New-SA-MP-callbacks/blob/master/callbacks.inc

GetAnimationIndex:
Código PHP:
stock IsPlayerSwimming(playerid) return (1538 <= GetPlayerAnimationIndex(playerid) <= 1544



RE: Como detectar se um player esta nadando? - Murilo Cod - 19/11/2022

Obrigado pena que n detecta quando um mobile está nadando mas pra pc detecta normal


RE: Como detectar se um player esta nadando? - Carlos Victor - 19/11/2022

Código:
stock IsPlayerInWater(playerid)
{
    new Float:Z;
    GetPlayerPos(playerid, Z, Z, Z);

    if(Z < 0.7) {
        switch(GetPlayerAnimationIndex(playerid)) {
            case 1543, 1538, 1539:
                return 1;
        }
    }

    if(GetPlayerDistanceFromPoint(playerid, -965, 2438, 42) <= 700 && Z < 45)
        return 1;

    new Float:water_places[][] =
    {
        {25.0,    2313.0,   -1417.0,    23.0},
        {15.0,    1280.0,   -773.0,     1082.0},
        {15.0,    1279.0,   -804.0,     86.0},
        {20.0,    1094.0,   -674.0,     111.0},
        {26.0,    194.0,    -1232.0,    76.0},
        {25.0,    2583.0,   2385.0,     15.0},
        {25.0,    225.0,    -1187.0,    73.0},
        {50.0,    1973.0,   -1198.0,    17.0},
        {140.0,   1923.0,     1592.0,     10.0}
    };

    for(new t = 0; t < sizeof(water_places); t++) {
        if(GetPlayerDistanceFromPoint(playerid, water_places[t][1], water_places[t][2], water_places[t][3]) <= water_places[t][0])
            return 1;
    }
    return 0;
}
Você pode usar essa função, talvez detecte para mobile.