From 98e936fc718b24ed27641e7b89efb57f401309a5 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Wed, 22 Jun 2022 08:29:23 -0500 Subject: [PATCH] Add fishing funcs and data --- scripts/server/fishing.js | 105 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) diff --git a/scripts/server/fishing.js b/scripts/server/fishing.js index cfcb0a70..cde74ed2 100644 --- a/scripts/server/fishing.js +++ b/scripts/server/fishing.js @@ -7,9 +7,114 @@ // TYPE: Server (JavaScript) // =========================================================================== +const VRR_FISHING_CATCH_TYPE_NONE = 1; +const VRR_FISHING_CATCH_TYPE_FISH = 1; +const VRR_FISHING_CATCH_TYPE_JUNK = 2; + +// =========================================================================== + +let fishingCollectables = [ + // Fish + ["Salmon", VRR_FISHING_CATCH_TYPE_FISH], + ["Tuna", VRR_FISHING_CATCH_TYPE_FISH], + ["Crab", VRR_FISHING_CATCH_TYPE_FISH], + ["Trout", VRR_FISHING_CATCH_TYPE_FISH], + ["Sea Bass", VRR_FISHING_CATCH_TYPE_FISH], + ["Shark", VRR_FISHING_CATCH_TYPE_FISH], + ["Turtle", VRR_FISHING_CATCH_TYPE_FISH], + ["Manta Ray", VRR_FISHING_CATCH_TYPE_FISH], + ["Cat Fish", VRR_FISHING_CATCH_TYPE_FISH], + ["Blue Marlin", VRR_FISHING_CATCH_TYPE_FISH], + + // Junk + ["Rusty Can", VRR_FISHING_CATCH_TYPE_JUNK], + ["Old Pants", VRR_FISHING_CATCH_TYPE_JUNK], + ["Old Shoes", VRR_FISHING_CATCH_TYPE_JUNK], + ["Garbage", VRR_FISHING_CATCH_TYPE_JUNK], + ["Baby Diaper", VRR_FISHING_CATCH_TYPE_JUNK], + ["Old Tire", VRR_FISHING_CATCH_TYPE_JUNK], + ["Old Car Battery", VRR_FISHING_CATCH_TYPE_JUNK], + ["Horse Hoove", VRR_FISHING_CATCH_TYPE_JUNK], + ["Soggy Log", VRR_FISHING_CATCH_TYPE_JUNK], + ["Soggy Dildo", VRR_FISHING_CATCH_TYPE_JUNK], + ["Clump of Seaweed", VRR_FISHING_CATCH_TYPE_JUNK], +]; + +// =========================================================================== + function initFishingScript() { logToConsole(LOG_INFO, "[VRR.Fishing]: Initializing fishing script ..."); logToConsole(LOG_INFO, "[VRR.Fishing]: Fishing script initialized successfully!"); } +// =========================================================================== + +function castFishingLineCommand(client) { + if (isPlayerInFishingSpot(client)) { + messagePlayerError(client, getLocaleString(client, "CantFishHere")); + return false; + } + + if (doesPlayerHaveItemOfUseTypeEquipped(client, VRR_ITEM_USETYPE_FISHINGROD)) { + messagePlayerError(client, getLocaleString(client, "NeedFishingRod")); + return false; + } + + getPlayerData(client).fishingLineCastStart = getCurrentUnixTimestamp(); + makePedPlayAnimation(getPlayerPed(client), getAnimationFromParams("batswing")); + + let messageText = getLocaleString(client, "FishingCastCommandHelp") + if (doesPlayerHaveKeyBindForCommand(client, "fish")) { + messageText = getLocaleString(client, "FishingCastKeyPressHelp") + } + + showGameMessage(client, messageText); +} + +// =========================================================================== + +function resetFishingLineCommand(client) { + if (doesPlayerHaveFishingLineCast(client)) { + messagePlayerError(client, getLocaleString(client, "FishingLineNotCast")); + return false; + } + + if (doesPlayerHaveItemOfUseTypeEquipped(client, VRR_ITEM_USETYPE_FISHINGROD)) { + messagePlayerError(client, getLocaleString(client, "CantFishHere")); + return false; + } + + makePedStopAnimation(getPlayerPed(client)); + + let messageText = getLocaleString(client, "FishingCastCommandHelp") + if (doesPlayerHaveKeyBindForCommand(client, "fish")) { + messageText = getLocaleString(client, "FishingCastKeyPressHelp") + } + + showGameMessage(client, messageText); +} + +// =========================================================================== + +function doesPlayerHaveFishingLineCast(client) { + return getPlayerData(client).fishingLineCastStart != 0; +} + +// =========================================================================== + +function isPlayerInFishingSpot(client) { + if (isPlayerOnBoat(client)) { + return true; + } + + let closestFishingLocation = getClosestFishingLocation(getPlayerPosition(client)); + if (closestFishingLocation != false) { + if (getDistance(getPlayerPosition(client), closestFishingLocation) < getGlobalConfig().fishingSpotDistance) { + return true; + } + } + + return false; +} + // =========================================================================== \ No newline at end of file