if (strcmp("/fish", cmdtext, true, 10) == 0)
{
if(IsPlayerConnected(playerid))
}
if((IsPlayerNearWater(playerid)) || IsPlayerInWater(playerid))
}
if(Fishes[playerid][pWeight1] > 0 && Fishes[playerid][pWeight2] > 0 && Fishes[playerid][pWeight3] > 0 && Fishes[playerid][pWeight4] > 0 && Fishes[playerid][pWeight5] > 0)
{
SendClientMessage(playerid, COLOR_GREY, " You've already caught five fish, sell / eat / release them before catching more!");
return 1;
}
if(Fishing[playerid] == 0)
{
//Fishing[playerid] = 1;
SetTimerEx("FishTimer", 5000, false, "i", playerid);
SendClientMessage(playerid,0xFFFFFFFF, "You threw the line in the water.");
}
else
{
SendClientMessage(playerid,COLOR_GREY, "You already Fishing !");
}
return 1;
}
return SendClientMessage(playerid,COLOR_GREY, "You aren't at the water!");
}
return 1;
}
#define MAX_Z_FISH_THRESHOLD 15.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; //return 0;
}
stock IsWaterInFrontOfPlayer(playerid, Float: range = 1.0)
{
new Float:fPX, Float:fPY, Float:fPZ,
Float:fVX, Float:fVY, Float:fVZ,
Float:object_x, Float:object_y, Float:object_z;
GetPlayerCameraPos(playerid, fPX, fPY, fPZ);
GetPlayerCameraFrontVector(playerid, fVX, fVY, fVZ);
object_x = fPX + floatmul(fVX, range);
object_y = fPY + floatmul(fVY, range);
MapAndreas_FindZ_For2DCoord(object_x, object_y, object_z);
if(object_z <= 0.0) return true;
return false;
}
Try with MapAndreas plugin:
pawn Код:
|
if((IsWaterInFrontOfPlayer(playerid)) || IsPlayerInWater(playerid))
if (strcmp("/fish", cmdtext, true, 10) == 0)
{
if(IsPlayerConnected(playerid)){
if(IsPointInWaterFrontOfPlayer(playerid,2.0)) //<--- detection range
{
if(Fishes[playerid][pWeight1] > 0 && Fishes[playerid][pWeight2] > 0 && Fishes[playerid][pWeight3] > 0 && Fishes[playerid][pWeight4] > 0 && Fishes[playerid][pWeight5] > 0)
{
SendClientMessage(playerid, COLOR_GREY, " You've already caught five fish, sell / eat / release them before catching more!");
return 1;
}
if(Fishing[playerid] == 0)
{
//Fishing[playerid] = 1;
SetTimerEx("FishTimer", 5000, false, "i", playerid);
SendClientMessage(playerid,0xFFFFFFFF, "You threw the line in the water.");
}
else
{
SendClientMessage(playerid,COLOR_GREY, "You already Fishing !");
}
return 1;
} else {
return SendClientMessage(playerid,COLOR_GREY, "You aren't at the water!");
}
}
return 1;
}
Command:
PHP код:
https://sampforum.blast.hk/showthread.php?pid=3591517#pid3591517 Tested, you can also change the range, now is 2.0 |
This is so wierd, neither this is working
i can still fish everywhere |
No, you can fish only with water. Initiated the Mapandreas ?
MapAndreas_Init(MAP_ANDREAS_MODE_FULL); //ongamemodeinit |
MapAndreas_Init(MAP_ANDREAS_MODE_FULL);
stock IsWaterInFrontOfPlayer(playerid, Float: range = 5.0)
{
new Float:fPX, Float:fPY, Float:fPZ,
Float:fVX, Float:fVY, Float:fVZ,
Float:object_x, Float:object_y, Float:object_z;
GetPlayerCameraPos(playerid, fPX, fPY, fPZ);
GetPlayerCameraFrontVector(playerid, fVX, fVY, fVZ);
object_x = fPX + floatmul(fVX, range);
object_y = fPY + floatmul(fVY, range);
MapAndreas_FindZ_For2DCoord(object_x, object_y, object_z);
if(object_z <= 0.0) return true;
return false;
}
if (strcmp("/fish", cmdtext, true, 10) == 0)
{
if(IsPlayerConnected(playerid)){
if(IsWaterInFrontOfPlayer(playerid,5.0)) //<--- detection range
{
if(Fishes[playerid][pWeight1] > 0 && Fishes[playerid][pWeight2] > 0 && Fishes[playerid][pWeight3] > 0 && Fishes[playerid][pWeight4] > 0 && Fishes[playerid][pWeight5] > 0)
{
SendClientMessage(playerid, COLOR_GREY, " You've already caught five fish, sell / eat / release them before catching more!");
return 1;
}
if(Fishing[playerid] == 0)
{
//Fishing[playerid] = 1;
SetTimerEx("FishTimer", 5000, false, "i", playerid);
SendClientMessage(playerid,0xFFFFFFFF, "You threw the line in the water.");
}
else
{
SendClientMessage(playerid,COLOR_GREY, "You already Fishing !");
}
return 1;
} else {
return SendClientMessage(playerid,COLOR_GREY, "You aren't at the water!");
}
}
return 1;
}