Is player near water (fishing system) -
Natric - 22.08.2014
Hello there,
Recently, I was busy doing a fishing system, but when I reached the point to check if the player in range of water I wasn't able to do it.. so I started to search around in this forum and I didn't get a satisfied answer, I saw many functions that checks if the player is inside water only and not near it.. any idea how to create such a thing for a fishing system? thanks in advance!
Re: Is player near water (fishing system) -
Virtual1ty - 22.08.2014
Nope, there isn't any function to check 'if player is NEAR water'. I recommend you make some predefined areas where the player can fish, otherwise you have to get all the SA shores coordinates to check if he's on the beach somewhere i.e.near water.
Re: Is player near water (fishing system) -
Natric - 22.08.2014
Any other solution? something ready as I dont have time
Re: Is player near water (fishing system) -
Virtual1ty - 22.08.2014
Not really, you can use IsPlayerInRangeOfPoint if you want to check if player is in certain range from coordinates.. It will take you some time as unfortunately there's no other way but to get it yourself..
Re: Is player near water (fishing system) -
ThePhenix - 22.08.2014
Maybe, you could create some areas with streamer and then check if the player is near them.
Re: Is player near water (fishing system) -
cnoopers - 22.08.2014
you can create few zones in any zonemaker around water.
or try some with 0.0 Z position.
Re: Is player near water (fishing system) -
Hiddos - 22.08.2014
Look up the coordinates for water zones in your ../GTA San Andreas/data/water.dat (and/or water1.dat) files, that will tell you where water is occurring in San Andreas. From then on you can figure out if the player is near/above/in the water.
Re: Is player near water (fishing system) -
Pottus - 22.08.2014
Doesn't seem like anyone can think outside the box here.
pawn Code:
#include <a_samp>
#include <zcmd>
#include <mapandreas>
#define MAX_Z_FISH_THRESHOLD 4.0
#define WATER_CHECK_RADIUS 5.0
IsPlayerNearWater(playerid)
{
new Float:x, Float:y, Float:z, Float:checkx, Float:checky, Float:checkz, Float:angle;
GetPlayerPos(playerid, x, y, z);
// Make sure player is at correct Z-Height (Will not work near the dam)
if(z > 0.0 && z < MAX_Z_FISH_THRESHOLD)
{
// Check North/East/South/West for water
for(new i = 0; i < 4; i++)
{
checkx = x + (WATER_CHECK_RADIUS * floatsin(-angle, degrees));
checky = y + (WATER_CHECK_RADIUS * floatcos(-angle, degrees));
angle += 90.0;
// Find the Z
MapAndreas_FindZ_For2DCoord(checkx, checky, checkz);
// Doesn't work under bridges
if(checkz == 0.0) return 1;
}
}
return 0;
}
CMD:wcheck(playerid, arg[])
{
if(IsPlayerNearWater(playerid)) SendClientMessage(playerid, -1, "Near water!");
else SendClientMessage(playerid, -1, "Not Near water!");
return 1;
}
Re: Is player near water (fishing system) -
Natric - 22.08.2014
Thank you very much, but a quick question, do you guys prefer using the plugin of mapandreas or the include by `RyDeR`? and is it true that both use a lot of memory? please explain thanks.
Re: Is player near water (fishing system) -
Faisal_khan - 22.08.2014
I think that plugins are made for efficient results, so I will go with the plugin. Correct me if I am wrong.