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;
}
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;
}
forward CheckFish();
public CheckFish()
{
foreach(new i: Player)// this loop will fix it
{
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;
}
IsPlayerNearWater(playerid) { new Float:x, Float: y, Float: z, Float: a, Float: cX, Float: cY, Float: cZ; GetPlayerPos(playerid, x, y, z); while (a <= 360.0) { cX = x + (4.0 * floatsin(-a, degrees)); cY = y + (4.0 * floatcos(-a, degrees)); a += 90.0; MapAndreas_FindZ_For2DCoord(cX, cY, cZ); if(cZ == 0.0) return true; } return false; }
for (new i, j = GetPlayerPoolSize(); i <= j; i++)
for (new i, j = GetPlayerPoolSize(); i <= j; i++)
for(new i=0; i<=MAX_PLAYERS; i++)
Yes. If it doesn't work, it means the problem is in your timer, so show how you call it.
|
new Caught;
new Level = PlayerInfo[playerid][pFishSkill];
if(Level >= 0 && Level < 50) { Caught = random(20)-7; }
else if(Level >= 50 && Level < 100) { Caught = random(50)-20; }
else if(Level >= 100 && Level < 200) { Caught = random(100)-50; }
else if(Level >= 200 && Level < 400) { Caught = random(140)-60; }
else if(Level >= 400 && Level < 500) { Caught = random(170)-60; }
if(luck <= 70)
{
new string[85];
HidePlayerFishText(playerid);
PlayerInfo[playerid][pFishes] += 1;
PlayerInfo[playerid][pFishSkill] += 1;
format(fstring, sizeof(fstring), "%s", FishNames[rand]);
strmid(Fishes[playerid][pFish], fstring, 0, strlen(fstring), 255);
Fishes[playerid][pWeight4] = Caught;
format(string, sizeof(string), "* %s reels in a %s weighing %d lbs!", RemoveUnderScore(playerid), Fishes[playerid][pFish], Caught);
ProxDetector(30.0, playerid, string, COLOR_RED,COLOR_RED,COLOR_RED,COLOR_RED,COLOR_RED);
RemovePlayerAttachedObject(playerid,0);
KillTimer(fishtimer[playerid]);
FishCaught[playerid] = 0;
Fishing[playerid] = 0;
Fishes[playerid][pLastWeight] = Caught;
Fishes[playerid][pLastFish] = 4;
Fishes[playerid][pFid4] = rand;
Fishes[playerid][pFishID] = rand;
if(Caught > PlayerInfo[playerid][pBiggestFish])
{
format(string, sizeof(string), "* You've beaten your old record of %d pounds! Your new biggest fish is: %d pounds.", PlayerInfo[playerid][pBiggestFish], Caught);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
PlayerInfo[playerid][pBiggestFish] = Caught;
}
return 1;
}
IsPlayerNearWater(playerid) {
const
Float: THRESHOLD = 20.0,
Float: RADIUS = 4.0;
new
Float: x,
Float: y,
Float: z;
if(GetPlayerPos(playerid, x, y, z) && (-THRESHOLD < z < THRESHOLD)) {
MapAndreas_FindZ_For2DCoord(x, y + RADIUS, z);
if(z == 0.0) return true;
MapAndreas_FindZ_For2DCoord(x + RADIUS, y, z);
if(z == 0.0) return true;
MapAndreas_FindZ_For2DCoord(x, y - RADIUS, z);
if(z == 0.0) return true;
MapAndreas_FindZ_For2DCoord(x - RADIUS, y, z);
if(z == 0.0) return true;
}
return false;
}