Portal SAMP
[Pedido] IsVehicleInWater(vehicleid) - 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: [Pedido] IsVehicleInWater(vehicleid) (/showthread.php?tid=1223)



IsVehicleInWater(vehicleid) - MateusCandido - 27/05/2021

Alguém possuí a função IsVehicleInWater pronta por gentileza?
Era uma função que usava o MapAndreas e cálculos para verificar se o veiculo estava dentro da água.
Ja vi ela no forum samp, mas como caiu, não consigo mais encontra-la :/


RE: IsVehicleInWater(vehicleid) - xbruno1000x - 27/05/2021

Código:
IsPlayerInWater(playerid)
{
    new Float:Z;// não mude para static
    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;
}

Tente adaptar essa função


RE: IsVehicleInWater(vehicleid) - MateusCandido - 31/05/2021

(27/05/2021 21:59)xbruno1000x Escreveu:
Código:
IsPlayerInWater(playerid)
{
    new Float:Z;// não mude para static
    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;
}

Tente adaptar essa função

Entendi, esses water places são os locais com água do jogo?


RE: IsVehicleInWater(vehicleid) - xbruno1000x - 31/05/2021

(31/05/2021 12:33)MateusCandido Escreveu:
(27/05/2021 21:59)xbruno1000x Escreveu:
Código:
IsPlayerInWater(playerid)
{
    new Float:Z;// não mude para static
    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;
}

Tente adaptar essa função

Entendi, esses water places são os locais com água do jogo?

Isso mesmo, eu o importei de um anti-flying hack antigo. Antigamente o flying hack utilizava a animação de nadar, então essa stock era usada para detectar se ele estava fazendo a anim em um local com água.


RE: IsVehicleInWater(vehicleid) - MateusCandido - 01/06/2021

(31/05/2021 14:02)xbruno1000x Escreveu:
(31/05/2021 12:33)MateusCandido Escreveu:
(27/05/2021 21:59)xbruno1000x Escreveu:
Código:
IsPlayerInWater(playerid)
{
    new Float:Z;// não mude para static
    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;
}

Tente adaptar essa função

Entendi, esses water places são os locais com água do jogo?

Isso mesmo, eu o importei de um anti-flying hack antigo. Antigamente o flying hack utilizava a animação de nadar, então essa stock era usada para detectar se ele estava fazendo a anim em um local com água.
entendi, sabe me dizer como eu faço para adicionar mais locais nessas coordenadas? Tem algum macete pra pegar a área toda ou é só pegar a coordenada pelo /save mesmo?


RE: IsVehicleInWater(vehicleid) - xbruno1000x - 01/06/2021

(01/06/2021 12:14)MateusCandido Escreveu: entendi, sabe me dizer como eu faço para adicionar mais locais nessas coordenadas? Tem algum macete pra pegar a área toda ou é só pegar a coordenada pelo /save mesmo?

Com o criador de gangzones abaixo você pode pegar facilmente qualquer área do GTA SA.
https://dev.prineside.com/gtasa_gangzone_editor/