if(!IsPlayerInRangeOfPoint(playerid, 2.0, 2103.9148, -103.5168, 2.2754) || !IsPlayerInVehicle(playerid, 451))
{
SendClientMessage(playerid, COLOR_LIGHTRED, "Error{FFFFFF}: You are not at a fishing spot.");
return 1;
}
if(!IsPlayerInRangeOfPoint(playerid, 2.0, 2103.9148, -103.5168, 2.2754) && !IsPlayerInVehicle(playerid, 451))
{
SendClientMessage(playerid, COLOR_LIGHTRED, "Error{FFFFFF}: You are not at a fishing spot.");
return 1;
}
Change the or ("||") to and ("&&"):
pawn Код:
|
Sorry but I'm pretty sure I'm right? (It may be late and I may be a tired but if you're NOT at the specified point and NOT in the specified vehicle, it will return the error message? - From another point, if you're at the point and not in the vehicle it will skip the error message?)
You could always try it and see if it works... |
CMD:fish(playerid, params[])
{
new string[128], query[500], pname[24], vehid;
vehid = GetPlayerVehicleID(playerid);
GetPlayerName(playerid, pname, 24);
if(!IsPlayerLoggedIn(playerid))
{
SendClientMessage(playerid, COLOR_LIGHTRED, "Error{FFFFFF}: You are not logged in.");
return 1;
}
if(PlayerInfo[playerid][pFishPermit] < 1)
{
SendClientMessage(playerid, COLOR_LIGHTRED, "Error{FFFFFF}: You do not have a fishing permit.");
return 1;
}
if(PlayerInfo[playerid][pFishingRod] < 1)
{
SendClientMessage(playerid, COLOR_LIGHTRED, "Error{FFFFFF}: You do not have a fishing rod.");
return 1;
}
if(PlayerInfo[playerid][pBait] < 1)
{
SendClientMessage(playerid, COLOR_LIGHTRED, "Error{FFFFFF}: You do not have any bait.");
return 1;
}
if(PlayerInfo[playerid][pFishes] == 5)
{
SendClientMessage(playerid, COLOR_LIGHTRED, "Error{FFFFFF}: You cannot hold any more fish in your inventory.");
return 1;
}
if(PlayerInfo[playerid][pRodDurab] == 1)
{
format(string, sizeof(string), "* %s's rod has worn out and snapped into two pieces.", Name(playerid));
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
PlayerInfo[playerid][pFishingRod] = 0;
PlayerInfo[playerid][pRodDurab] = 0;
format(query, sizeof(query), "UPDATE playerdata SET FishingRod=%d, RodDurab=%d WHERE Username='%s'",
PlayerInfo[playerid][pFishingRod],
PlayerInfo[playerid][pRodDurab],
pname);
mysql_query(query);
return 1;
}
if(IsPlayerInRangeOfPoint(playerid, 2.0, 2103.9148, -103.5168, 2.2754) || IsPlayerInVehicle(playerid, 453)) //< Fishing Boat
{
TogglePlayerControllable(playerid, 0);
PlayerInfo[playerid][pRodDurab] -= 1;
PlayerInfo[playerid][pBait] -= 1;
format(query, sizeof(query), "UPDATE playerdata SET RodDurab=%d, Bait=%d WHERE Username='%s'",
PlayerInfo[playerid][pRodDurab],
PlayerInfo[playerid][pBait],
pname);
mysql_query(query);
format(string, sizeof(string), "* %s casts their rod out into the sea.", Name(playerid));
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
SetTimerEx("FishingTime", 15000, false, "i", playerid);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_LIGHTRED, "Error{FFFFFF}: You are not at a fishing spot.");
return 1;
}
}
if(!IsPlayerInRangeOfPoint(playerid, 2.0, 2103.9148, -103.5168, 2.27) && GetVehicleModel(GetPlayerVehicleID(playerid)) != 451)
{
return SendClientMessage(playerid, COLOR_LIGHTRED, "Error{FFFFFF}: You are not at a fishing spot.");
}
new g_iLastVehicle[MAX_PLAYERS]; // Top of script
forward OnPlayerEnterVehicle(playerid, vehicleid, ispassenger); public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) // Add to your existing callback, not overwrite.
return g_iLastVehicle[playerid] = vehicleid;
CMD:fish(playerid, params[])
{
new string[128], query[500], pname[24], vehid;
vehid = GetPlayerVehicleID(playerid);
GetPlayerName(playerid, pname, 24);
if(!IsPlayerLoggedIn(playerid))
{
SendClientMessage(playerid, COLOR_LIGHTRED, "Error{FFFFFF}: You are not logged in.");
return 1;
}
if(PlayerInfo[playerid][pFishPermit] < 1)
{
SendClientMessage(playerid, COLOR_LIGHTRED, "Error{FFFFFF}: You do not have a fishing permit.");
return 1;
}
if(PlayerInfo[playerid][pFishingRod] < 1)
{
SendClientMessage(playerid, COLOR_LIGHTRED, "Error{FFFFFF}: You do not have a fishing rod.");
return 1;
}
if(PlayerInfo[playerid][pBait] < 1)
{
SendClientMessage(playerid, COLOR_LIGHTRED, "Error{FFFFFF}: You do not have any bait.");
return 1;
}
if(PlayerInfo[playerid][pFishes] == 5)
{
SendClientMessage(playerid, COLOR_LIGHTRED, "Error{FFFFFF}: You cannot hold any more fish in your inventory.");
return 1;
}
if(PlayerInfo[playerid][pRodDurab] == 1)
{
format(string, sizeof(string), "* %s's rod has worn out and snapped into two pieces.", Name(playerid));
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
PlayerInfo[playerid][pFishingRod] = 0;
PlayerInfo[playerid][pRodDurab] = 0;
format(query, sizeof(query), "UPDATE playerdata SET FishingRod=%d, RodDurab=%d WHERE Username='%s'",
PlayerInfo[playerid][pFishingRod],
PlayerInfo[playerid][pRodDurab],
pname);
mysql_query(query);
return 1;
}
new Float:vehx, Float:vehy, Float:vehz;
GetVehiclePos(g_iLastVehicle[playerid], vehx, vehy, vehz);
if(IsPlayerInRangeOfPoint(playerid, 2.0, 2103.9148, -103.5168, 2.2754) || GetPlayerVehicleID(playerid) == 453 || IsPlayerInRangeOfPoint(playerid, 5.0, vehx, vehy, vehz) //< Fishing Boat
{
TogglePlayerControllable(playerid, 0);
PlayerInfo[playerid][pRodDurab] -= 1;
PlayerInfo[playerid][pBait] -= 1;
format(query, sizeof(query), "UPDATE playerdata SET RodDurab=%d, Bait=%d WHERE Username='%s'",
PlayerInfo[playerid][pRodDurab],
PlayerInfo[playerid][pBait],
pname);
mysql_query(query);
format(string, sizeof(string), "* %s casts their rod out into the sea.", Name(playerid));
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
SetTimerEx("FishingTime", 15000, false, "i", playerid);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_LIGHTRED, "Error{FFFFFF}: You are not at a fishing spot.");
return 1;
}
}
forward GetClosestVehicleFromPlayer(playerid); public GetClosestVehicleFromPlayer(playerid) {
new Float:iDistance = 99999999.0;
new iVehicleID = -1;
new Float:p_fPos[3];
GetPlayerPos(playerid, p_fPos[0], p_fPos[1], p_fPos[2]);
for(new i = 1; i < MAX_VEHICLES; i++) {
new Float:iTempDistance = GetVehicleDistanceFromPoint(i, p_fPos[0], p_fPos[1], p_fPos[2]);
if(iTempDistance < iDistance) {
iDistance = iTempDistance;
iVehicleID = i;
}
}
return iVehicleID;
}
CMD:fish(playerid, params[])
{
new string[128], query[500], pname[24], vehid;
vehid = GetPlayerVehicleID(playerid);
GetPlayerName(playerid, pname, 24);
if(!IsPlayerLoggedIn(playerid))
{
SendClientMessage(playerid, COLOR_LIGHTRED, "Error{FFFFFF}: You are not logged in.");
return 1;
}
if(PlayerInfo[playerid][pFishPermit] < 1)
{
SendClientMessage(playerid, COLOR_LIGHTRED, "Error{FFFFFF}: You do not have a fishing permit.");
return 1;
}
if(PlayerInfo[playerid][pFishingRod] < 1)
{
SendClientMessage(playerid, COLOR_LIGHTRED, "Error{FFFFFF}: You do not have a fishing rod.");
return 1;
}
if(PlayerInfo[playerid][pBait] < 1)
{
SendClientMessage(playerid, COLOR_LIGHTRED, "Error{FFFFFF}: You do not have any bait.");
return 1;
}
if(PlayerInfo[playerid][pFishes] == 5)
{
SendClientMessage(playerid, COLOR_LIGHTRED, "Error{FFFFFF}: You cannot hold any more fish in your inventory.");
return 1;
}
if(PlayerInfo[playerid][pRodDurab] == 1)
{
format(string, sizeof(string), "* %s's rod has worn out and snapped into two pieces.", Name(playerid));
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
PlayerInfo[playerid][pFishingRod] = 0;
PlayerInfo[playerid][pRodDurab] = 0;
format(query, sizeof(query), "UPDATE playerdata SET FishingRod=%d, RodDurab=%d WHERE Username='%s'",
PlayerInfo[playerid][pFishingRod],
PlayerInfo[playerid][pRodDurab],
pname);
mysql_query(query);
return 1;
}
if(IsPlayerInRangeOfPoint(playerid, 2.0, 2103.9148, -103.5168, 2.2754) || GetPlayerVehicleID(playerid) == 453 || GetClosestVehicleFromPlayer(playerid) == 453) //< Fishing Boat
{
TogglePlayerControllable(playerid, 0);
PlayerInfo[playerid][pRodDurab] -= 1;
PlayerInfo[playerid][pBait] -= 1;
format(query, sizeof(query), "UPDATE playerdata SET RodDurab=%d, Bait=%d WHERE Username='%s'",
PlayerInfo[playerid][pRodDurab],
PlayerInfo[playerid][pBait],
pname);
mysql_query(query);
format(string, sizeof(string), "* %s casts their rod out into the sea.", Name(playerid));
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
SetTimerEx("FishingTime", 15000, false, "i", playerid);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_LIGHTRED, "Error{FFFFFF}: You are not at a fishing spot.");
return 1;
}
}