From fef84bf75b055fd27b32651e5f0eac249973d814 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Fri, 3 Mar 2023 03:05:48 -0600 Subject: [PATCH] Some fishing stuff (unfinished) --- scripts/server/fishing.js | 41 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/scripts/server/fishing.js b/scripts/server/fishing.js index 550d8b64..a0cd8cf4 100644 --- a/scripts/server/fishing.js +++ b/scripts/server/fishing.js @@ -22,6 +22,29 @@ const V_FISHING_LINE_STATE_HOOKED = 5; // =========================================================================== +class FishingLocationData { + constructor(dbAssoc = false) { + this.databaseId = 0; + this.serverId = 0; + this.index = -1; + this.position = toVector3(0.0, 0.0, 0.0); + this.enabled = false; + this.whoAdded = 0; + this.whenAdded = 0; + + if (dbAssoc) { + this.databaseId = toInteger(dbAssoc["fish_loc_id"]); + this.serverId = toInteger(dbAssoc["fish_loc_server"]); + this.enabled = intToBool(dbAssoc["fish_loc_enabled"]); + this.position = toVector3(toFloat(dbAssoc["fish_loc_pos_x"]), toFloat(dbAssoc["fish_loc_pos_y"]), toFloat(dbAssoc["fish_loc_pos_z"])); + this.whoAdded = toInteger(dbAssoc["fish_loc_who_added"]); + this.whenAdded = toInteger(dbAssoc["fish_loc_when_added"]); + } + } +}; + +// =========================================================================== + let fishingCollectables = [ // Fish ["Salmon", V_FISHING_CATCH_TYPE_FISH], @@ -63,7 +86,11 @@ let fishingAnimations = { [V_GAME_GTA_SA]: { "fishingLineCasting": "none", "fishingLineReeling": "none", - } + }, + //[V_GAME_MAFIA_ONE]: { + // "fishingLineCasting": "none", + // "fishingLineReeling": "none", + //} }; // =========================================================================== @@ -205,4 +232,16 @@ function isPlayerFishing(client) { return (getPlayerData(client).fishingLineState != V_FISHING_LINE_STATE_NONE); } +// =========================================================================== + +function getClosestFishingLocation(position) { + let closest = 0; + for (let i in getServerData().fishingLocations) { + if (getDistance(position, getServerData().fishingLocations[i].position) < getDistance(position, getServerData().fishingLocations[closest].position)) + closest = i; + } + + return closest; +} + // =========================================================================== \ No newline at end of file