SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 04/05/2015, 08:33 AM   #1
Beckett
High-roller
 
Beckett's Avatar
 
Join Date: Feb 2012
Location: www.finalnights-rp.com
Posts: 1,794
Reputation: 104
Default Detection of is player near any source of water

I've been searching through the forums for a quite while for a function that checks if player is nearby any source of water, NOT SWIMMING.

I hope I explained it well, thanks in advance.
Beckett is offline   Reply With Quote
Old 04/05/2015, 09:14 AM   #2
Gammix
High-roller
 
Gammix's Avatar
 
Join Date: Jan 2015
Location: Canada
Posts: 1,773
Reputation: 858
Default Re: Detection of is player near any source of water

Using mapandreas, this will work:
pawn Code:
#include <mapandreas>
http://forum.sa-mp.com/showthread.php?t=275492

Use it as a stock if in include or declare it as a function in the script.
pawn Code:
stock IsPlayerNearWater(playerid)
{
    static Float:pos[3];
    GetPlayerPos(playerid, pos[0], pos[1], pos[2]);//read positions

    static Float:check_pos[3];
    static Float:angle;

    #define THRESHOLD   4.0
    #define RADIUS      5.0
    if(pos[2] > 0.0 && pos[2] < THRESHOLD)
    {
        for(new i = 0; i < 4; i++)
        {
            check_pos[0] = pos[0] + (RADIUS * floatsin(-angle, degrees));
            check_pos[1] = pos[1] + (RADIUS * floatcos(-angle, degrees));
            angle += 90.0;

            MapAndreas_FindZ_For2DCoord(check_pos[0], check_pos[1], check_pos[2]);

            if(check_pos[2] == 0.0) return true;
        }
    }
    return false;
}
__________________

Follow me on Github: Donate on Paypal:

Gammix is offline   Reply With Quote
Old 04/05/2015, 10:56 AM   #3
Beckett
High-roller
 
Beckett's Avatar
 
Join Date: Feb 2012
Location: www.finalnights-rp.com
Posts: 1,794
Reputation: 104
Default Re: Detection of is player near any source of water

I'll try this when I have the time and reply to you back, thanks for dedicating your time into this.
Beckett 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
Creating a per player plugin detection method RajatPawar Scripting Help 3 02/11/2013 04:49 PM
[Include] Player Trailer Attach/Deattach Detection SDraw Includes 4 29/03/2013 06:24 PM
Firetruck Water Detection? The_Gangstas Help Archive 3 21/12/2010 11:42 PM
Player angle and walls detection arnutisz Help Archive 5 04/02/2010 11:56 AM


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


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