SA-MP Forums

Go Back   SA-MP Forums > Non-English > Languages > Português/Portuguese

Reply
 
Thread Tools Display Modes
Old 16/09/2019, 10:54 AM   #1
gmstrikker
Huge Clucker
 
Join Date: Aug 2013
Posts: 313
Reputation: 0
Default Detectar se tá na água

Como vocês fazem pra detectar se o player está perto da água?

Tentei:
Code:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if(newkeys == KEY_NO) {
                if(!IsPlayerInWater(playerid)) {
                    printf("nao ta na agua");
                }
                else if(IsPlayerInWater(playerid)) {
                    printf("ta na agua");
                }
    }
}

Code:
stock IsPlayerInWater(playerid)
{
        new Float:null[2], Float:MaxZ;
        GetPlayerPos(playerid, null[0], null[1], MaxZ);
        /* Las Venturas */
        if(IsPlayerInArea(playerid, 2044.6, 1206.358, 2192.984, 1376.552) && MaxZ < 0xA)
                return 1;
        else if(IsPlayerInArea(playerid, 2048.504, 1063.239, 2185.174, 1202.49) && MaxZ < 0xA)
                return 1;
        else if(IsPlayerInArea(playerid, 2204.698, 1426.837, 2204.698, 1430.705) && MaxZ < 0xA)
                return 1;
        else if(IsPlayerInArea(playerid, 2032.885, 1852.325, 2114.887, 1991.575) && MaxZ < 0xC)
                return 1;
        else if(IsPlayerInArea(playerid, 2517.086, 2316.493, 2606.897, 2420.93) && MaxZ < 0x16)
                return 1;
        else if(IsPlayerInArea(playerid, 2554.5996, 1548.6178, 2507.7683, 1588.9154) && MaxZ < 0xF)
                return 1;
        /* San Fierro */
        else if(IsPlayerInArea(playerid, -2043.628, -980.9415, -1973.561, -724.0283) && MaxZ < 0x20)
                return 1;
        else if(IsPlayerInArea(playerid, -2753.912, -522.3632, -2665.071, -380.3444) && MaxZ < 0x05)
                return 1;
        /* Los Santos */
        else if(IsPlayerInArea(playerid, 1219.864, -2435.881, 1292.118, -2325.344) && MaxZ < 0xF)
                return 1;
        else if(IsPlayerInArea(playerid, 1923.388, -1223.924, 2010.854, -1168.656) && MaxZ < 0x16)
                return 1;
        else if(IsPlayerInArea(playerid, 1269.301, -837.0452, 1314.935, -781.7769) && MaxZ < 0x5A)
                return 1;
        else if(IsPlayerInArea(playerid, 1087.3953, -682.6734, 1102.3138, -663.0043) && MaxZ < 0x71)
                return 1;
        else if(IsPlayerInArea(playerid, 1268.6118, -784.2910, 1291.8774, -764.6104) && MaxZ < 0x43D)
                return 1;
        /* Bounds */
        else if(MaxZ < 0xF)
                return 1;
        return 0;
}
Usando isso tá semppre printando tá na água, mesmo eu apertando N em indlewood :S
gmstrikker is offline   Reply With Quote
Old 16/09/2019, 11:22 AM   #2
Delete_
High-roller
 
Delete_'s Avatar
 
Join Date: Mar 2011
Location: Gurupi - TO
Posts: 1,738
Reputation: 110
Default Re: Detectar se tá na água

PHP Code:
stock IsPlayerInWater(playerid)
{
    new 
anim GetPlayerAnimationIndex(playerid);
    if(
anim >= 1538 && anim <= 1542 || anim == 1544 || anim == 1250 || anim == 1062)
    {
        return 
1;
    }
    return 
0;
}

if(
IsPlayerInWater(playerid)) return SCM(playeridCOLOR_WHITE"Você está na agua!"); 
__________________
Araguaia Roleplay
Delete_ is offline   Reply With Quote
Old 16/09/2019, 12:35 PM   #3
gmstrikker
Huge Clucker
 
Join Date: Aug 2013
Posts: 313
Reputation: 0
Default Re: Detectar se tá na água

Quote:
Originally Posted by Delete_ View Post
PHP Code:
stock IsPlayerInWater(playerid)
{
    new 
anim GetPlayerAnimationIndex(playerid);
    if(
anim >= 1538 && anim <= 1542 || anim == 1544 || anim == 1250 || anim == 1062)
    {
        return 
1;
    }
    return 
0;
}

if(
IsPlayerInWater(playerid)) return SCM(playeridCOLOR_WHITE"Você está na agua!"); 
Tenho uma função como essa, pra checar se o player tá nadando né?
O problema é que eu queria fazer um sistema de pesca com o player com o pé na água, mas sem estar nadando, saca?
gmstrikker is offline   Reply With Quote
Old 16/09/2019, 12:46 PM   #4
NWDMadara
Huge Clucker
 
NWDMadara's Avatar
 
Join Date: Mar 2018
Posts: 449
Reputation: 11
Default Re: Detectar se tá na água

Quote:
Originally Posted by gmstrikker View Post
Tenho uma função como essa, pra checar se o player tá nadando né?
O problema é que eu queria fazer um sistema de pesca com o player com o pé na água, mas sem estar nadando, saca?
Naruto?

Se o jogador não faz nenhuma animação, pegue as coordenadas do local e verifique se o jogador está na mesma, incluindo a altura.
NWDMadara is offline   Reply With Quote
Old 16/09/2019, 05:53 PM   #5
COYTER
Little Clucker
 
COYTER's Avatar
 
Join Date: Aug 2019
Location: Chéquia
Posts: 8
Reputation: 0
Default Re: Detectar se tá na água

You can take a look here. I just didn't get your idea on Float: Null. In short, you have this way below. It is very effective, use as an example and see what you did wrong

https://forum.sa-mp.com/showpost.php...56&postcount=3
COYTER is offline   Reply With Quote
Old 16/09/2019, 10:47 PM   #6
gmstrikker
Huge Clucker
 
Join Date: Aug 2013
Posts: 313
Reputation: 0
Default Re: Detectar se tá na água

Quote:
Originally Posted by COYTER View Post
You can take a look here. I just didn't get your idea on Float: Null. In short, you have this way below. It is very effective, use as an example and see what you did wrong

https://forum.sa-mp.com/showpost.php...56&postcount=3
Even using this:
Code:
static stock IsPlayerInWater( playerid ) //Credits to Synchro for his coords function.
{
    static 
        Float:fX, 
        Float:fY, 
        Float:fZ
    ;
    GetPlayerPos( playerid, fX, fY, fZ );

    if((fX >= 2044.6 && fX <= 2192.984 && fY >= 1206.358 && fY <= 1376.552) && fZ < 0xA) return true;
    else if((fX >= 2048.504 && fX <= 2185.174 && fY >= 1063.239 && fY <= 1202.49) && fZ < 0xA) return true;
    else if((fX >= 2204.698 && fX <= 2204.698 && fY >= 1426.837 && fY <= 1430.705) && fZ < 0xA) return true;
    else if((fX >= 2032.885 && fX <= 2114.887 && fY >= 1852.325 && fY <= 1991.575) && fZ < 0xC) return true;
    else if((fX >= 2517.086 && fX <= 2606.897 && fY >= 2316.493 && fY <= 2420.93) && fZ < 0x16) return true;
    else if((fX >= 2554.5996 && fX <= 2507.7683 && fY >= 1548.6178 && fY <= 1588.9154) && fZ < 0xF) return true;
    else if((fX >= -2043.628 && fX <= -1973.561 && fY >= -980.9415 && fY <= -724.0283) && fZ < 0x20) return true;
    else if((fX >= -2753.912 && fX <= -2665.071 && fY >= -522.3632 && fY <= -380.3444) && fZ < 0x05) return true;
    else if((fX >= 1219.864 && fX <= 1292.118 && fY >= -2435.881 && fY <= -2325.344) && fZ < 0xF) return true;
    else if((fX >= 1923.388 && fX <= 2010.854 && fY >= -1223.924 && fY <= -1168.656) && fZ < 0x16) return true;
    else if((fX >= 1269.301 && fX <= 1314.935 && fY >= -837.0452 && fY <= -781.7769) && fZ < 0x5A) return true;
    else if((fX >= 1087.3953 && fX <= 1102.3138 && fY >= -682.6734 && fY <= -663.0043) && fZ < 0x71) return true;
    else if((fX >= 1268.6118 && fX <= 1291.8774 && fY >= -784.2910 && fY <= -764.6104) && fZ < 0x43D) return true;
    else if(fZ < 0xF) return true;
    else return false;
}

Code:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if(newkeys == KEY_NO) {
                if(!IsPlayerInWater(playerid)) {
                    printf("nao ta na agua");
                }
                else if(IsPlayerInWater(playerid)) {
                    printf("ta na agua");
                }
    }
}
It is printing ta na agua in everywhere...
Idlewood, Gaton, place where there is no water...
gmstrikker is offline   Reply With Quote
Old 17/09/2019, 10:11 AM   #7
gmstrikker
Huge Clucker
 
Join Date: Aug 2013
Posts: 313
Reputation: 0
Default Re: Detectar se tá na água

Quote:
Originally Posted by COYTER View Post
You can take a look here. I just didn't get your idea on Float: Null. In short, you have this way below. It is very effective, use as an example and see what you did wrong

https://forum.sa-mp.com/showpost.php...56&postcount=3
KKKK
não é naruto nem jesus, só isso aqui:
https://www.wikihow.com/images/thumb...eas-Step-1.jpg
gmstrikker is offline   Reply With Quote
Old 17/09/2019, 11:03 AM   #8
Delete_
High-roller
 
Delete_'s Avatar
 
Join Date: Mar 2011
Location: Gurupi - TO
Posts: 1,738
Reputation: 110
Default Re: Detectar se tá na água

Quote:
Originally Posted by gmstrikker View Post
KKKK
não é naruto nem jesus, só isso aqui:
https://www.wikihow.com/images/thumb...eas-Step-1.jpg
https://wiki.sa-mp.com/wiki/IsPlayerInRangeOfPoint_FR
__________________
Araguaia Roleplay
Delete_ is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Ajuda] Água VictorMM Português/Portuguese 4 29/12/2017 11:55 AM
[Ajuda] Água Slipk Português/Portuguese 2 25/10/2014 10:29 PM
[Ajuda]Como Detectar Àgua DrTHE Português/Portuguese 3 14/01/2012 03:57 AM
[DUV]agua Xapita_Halls Português/Portuguese 6 29/11/2010 07:04 PM


All times are GMT. The time now is 08:35 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.