Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local alamo_tug_fish = {
- "fish_salmon",
- "fish_mackerel",
- "fish_trout",
- }
- local tugging_locations = {
- {id = "AS_01", name = "Alamo Sea", x = 2088.3854980469, y = 4279.0024414063, z = 30.0, capacity = 100, current = 0, size = 250.0, bonuses = {}, itemset = alamo_tug_fish},
- }
- local WITHIN_ZONE = false
- local CURRENT_ZONE = nil
- function GiveFishFromSet(location, min, max)
- local itemset = location.itemset
- local item = itemset[math.random(#itemset)]
- local amount = math.random(min, max)
- if amount > 0 then
- -- Code to give items
- TriggerEvent("gd_utils:notify", "Got " .. amount .. "x " .. item)
- end
- end
- -- Main Loop
- Citizen.CreateThread(function()
- while true do
- Wait(0)
- local ped = GetPlayerPed(-1)
- WITHIN_ZONE = false
- CURRENT_ZONE = nil
- if IsVehicleModel(GetVehiclePedIsIn(ped, false), "TUG") then
- local pos = GetEntityCoords(ped, false)
- for _, location in next, tugging_locations do
- if not location.world_blip then
- local blip = AddBlipForCoord(location.x, location.y, location.z)
- SetBlipSprite(blip, 400)
- SetBlipColour(blip, 25)
- SetBlipAsShortRange(blip, true)
- exports['omni_common']:SetBlipName(blip, "Net Fishing Zone")
- location.world_blip = blip
- end
- if not WITHIN_ZONE then
- -- Check if we are within the fishing area
- local dist = #(vector3(location.x, location.y, location.z) - pos)
- if dist < location.size + 150.0 then
- -- Within a fishing area
- DrawMarker(1, location.x, location.y, location.z, 0, 0, 0, 0, 0, 0, location.size * 2, location.size * 2, 2.0, 255, 255, 255, 255)
- -- Make the radius blip if no present
- if not location.blip then
- local blip = AddBlipForRadius(location.x, location.y, location.z, location.size)
- SetBlipAlpha(blip, 150)
- SetBlipColour(blip, 25)
- location.blip = blip
- end
- -- Check if we are within the zone itself
- if dist < location.size then
- -- Within the fishing zone
- -- Mark as current zone (for fishing generator and bonus generator)
- WITHIN_ZONE = true
- CURRENT_ZONE = location
- -- Check and draw bonuses
- for _bonus_id, bonus in next, location.bonuses do
- -- Create bonus blip if not present
- if not bonus.blip then
- local blip = AddBlipForCoord(bonus.x, bonus.y, location.z)
- exports['omni_common']:SetBlipName(blip, "Net Fishing Bonus")
- bonus.blip = blip
- end
- -- Draw Marker on water (fancy!!)
- local _, h = GetWaterHeight(bonus.x, bonus.y, 100.0)
- DrawMarker(1, bonus.x, bonus.y, h, 0, 0, 0, 0, 0, 0, bonus.size * 2, bonus.size * 2, 2.0, 255, 255, 255, 255)
- -- Check distance
- local dist = #(vector3(bonus.x, bonus.y, location.z) - pos)
- if dist < bonus.size then
- RemoveBlip(bonus.blip)
- bonus.blip = nil
- GiveFishFromSet(location, 3, 8)
- table.remove(location.bonuses, _bonus_id)
- end
- end
- end
- else
- -- Not within a fishing area
- -- Remove area blip
- if location.blip then
- RemoveBlip(location.blip)
- location.blip = nil
- end
- -- Remove bonus blips
- for _, bonus in next, location.bonuses do
- if bonus.blip then
- RemoveBlip(bonus.blip)
- bonus.blip = nil
- end
- end
- end
- end
- end
- else
- -- Not in a tug
- -- Remove blips
- for _, location in next, tugging_locations do
- if location.world_blip then
- RemoveBlip(location.world_blip)
- location.world_blip = nil
- end
- if location.blip then
- RemoveBlip(location.blip)
- location.blip = nil
- end
- for _, bonus in next, location.bonuses do
- if bonus.blip then
- RemoveBlip(bonus.blip)
- bonus.blip = nil
- end
- end
- end
- end
- end
- end)
- -- Fish Generator Loop
- local last_pos = vector3(0.0, 0.0, 0.0)
- Citizen.CreateThread(function()
- while true do
- Wait(2500)
- local ped = GetPlayerPed(-1)
- if WITHIN_ZONE then
- local pos = GetEntityCoords(ped, false)
- local dist = #(pos - last_pos)
- if dist > 55.0 then
- last_pos = pos
- -- Make me a fish
- -- INSERT CODE TO GIVE FISHES
- GiveFishFromSet(CURRENT_ZONE, -2, 2)
- end
- end
- end
- end)
- -- Bonus Generator Loop
- local bonus_wait_time = 35 * 1000
- Citizen.CreateThread(function()
- while true do
- if WITHIN_ZONE then
- local zone = CURRENT_ZONE
- local bonus = {}
- -- Make sure the position is never outside the zone
- local function gen()
- bonus.x = zone.x + math.random(-zone.size, zone.size)
- bonus.y = zone.y + math.random(-zone.size, zone.size)
- local dist = #(vector3(bonus.x, bonus.y, 0.0) - vector3(zone.x, zone.y, 0.0))
- if dist > zone.size then
- gen()
- end
- end
- gen()
- bonus.size = 8.0
- table.insert(zone.bonuses, bonus)
- if #zone.bonuses > 5 then
- if zone.bonuses[1].blip then
- RemoveBlip(zone.bonuses[1].blip)
- end
- table.remove(zone.bonuses, 1)
- end
- end
- Wait(bonus_wait_time)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement