20.07.2016, 17:50
Well, when i am alone on the server, everything works fine.. But when we are 2, or more online
then if i try to /fish, it just come with the message after one second "You pulled your line out of the water"
and it will keep doing that.. I really hope anyone can help me. rep+
This is the timer that will stop fishing if you leave the water
This is the near water stock..
Please tell me if you need more info
then if i try to /fish, it just come with the message after one second "You pulled your line out of the water"
and it will keep doing that.. I really hope anyone can help me. rep+
This is the timer that will stop fishing if you leave the water
pawn Код:
forward CheckFish();
public CheckFish()
{
for(new i=0; i<MAX_PLAYERS; i++)
{
if(!IsPlayerNearWater(i))
{
if(Fishing[i] == 1)
{
SendClientMessage(i, COLOR_GREY, "You pulled your line out of the water.");
Fishing[i] = 0;
RemovePlayerAttachedObject(i,0);
KillTimer(fishtimer[i]);
}
}
}
return 1;
}
pawn Код:
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 20.0
#define RADIUS 4.0
if(pos[2] > -20.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;
}