client.lua
local Keys = {
["1"] = 185, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["E"] = 38, ["X"] = 73
}
local fishing = false
local lastInput = 0
local pause = false
local pausetimer = 0
local correct = 0
local veh = nil
local bait = "none"
local SellWait = false
for _, v in ipairs(Config_Fishing.Sell) do
local blip = AddBlipForCoord(v.pos)
SetBlipSprite (blip, v.blip)
SetBlipDisplay(blip, 4)
SetBlipScale (blip, 0.8)
SetBlipColour (blip, v.colour)
SetBlipAsShortRange(blip, true)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString(v.sellText)
EndTextCommandSetBlipName(blip)
end
Citizen.CreateThread(function()
while true do
Delay = 1000
local ped = PlayerPedId()
local pedCoords = GetEntityCoords(ped)
-- Sell markers
for k, v in ipairs(Config_Fishing.Sell) do
if #(pedCoords - v.pos) < 100.0 then
Delay = 0
DrawMarker(1, v.pos, 0.0, 0.0, 0.0, 0, 0.0, 0.0, 3.0, 3.0, 1.0, 0, 255, 0, 100, false, true, 2, false, false, false, false)
end
if #(pedCoords - v.pos) < 3.0 and not SellWait then
Delay = 0
DrawMarker(1, v.pos, 0.0, 0.0, 0.0, 0, 0.0, 0.0, 3.0, 3.0, 1.0, 0, 255, 0, 100, false, true, 2, false, false, false, false)
TriggerServerEvent('fishing:startSelling', v.type)
SellWait = true
end
end
Citizen.Wait(Delay)
end
end)
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if SellWait then
Citizen.Wait(4000)
SellWait = false
end
end
end)
function DisplayHelpText(str)
SetTextComponentFormat("STRING")
AddTextComponentString(str)
DisplayHelpTextFromStringLabel(0, 0, 1, -1)
end
Citizen.CreateThread(function()
while true do
Wait(1200)
if pause and fishing then
pausetimer = pausetimer + 1
end
end
end)
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if fishing then
if IsControlJustReleased(0, Keys[tostring(1)]) then
input = 1
end
-- Stops the player from cancelling the task by getting out a weapon
if IsPedUsingScenario(PlayerPedId(), "WORLD_HUMAN_STAND_FISHING") then
BlockWeaponWheelThisFrame()
end
if IsControlJustReleased(0, Keys['X']) then
fishing = false
ESX.ShowNotification("Slutade fiska")
TriggerEvent("fishing:break")
end
if fishing then
playerPed = PlayerPedId()
local pos = GetEntityCoords(playerPed)
if GetWaterHeight(pos.x, pos.y, pos.z-2, pos.z-3.0) then
-- Nothing
else
fishing = false
ESX.ShowNotification("Slutade fiska")
end
if IsEntityDead(playerPed) or IsEntityInWater(playerPed) then
ESX.ShowNotification("Slutade fiska")
end
end
if pausetimer > 3 then
input = 99
end
if pause and input ~= 0 then
pause = false
if input == correct then
TriggerServerEvent('fishing:catch', bait)
else
ESX.ShowNotification("Fisken tog sig fri")
end
end
end
end
end)
Citizen.CreateThread(function()
while true do
local wait = math.random(Config_Fishing.FishTime.a , Config_Fishing.FishTime.b)
Citizen.Wait(wait)
if fishing then
pause = true
correct = 1
ESX.ShowNotification("Fisken tar betet\nTryck 'F' för att fånga den")
input = 0
pausetimer = 0
end
end
end)
RegisterNetEvent('fishing:message')
AddEventHandler('fishing:message', function(message)
ESX.ShowNotification(message)
end)
RegisterNetEvent('fishing:break')
AddEventHandler('fishing:break', function()
fishing = false
ClearPedTasks(PlayerPedId())
end)
RegisterNetEvent('sharktiger:spawnPed')
AddEventHandler('sharktiger:spawnPed', function()
RequestTheModel("A_C_SharkTiger")
local pos = GetEntityCoords(PlayerPedId())
local ped = CreatePed(29, 'A_C_SharkTiger', pos.x, pos.y, pos.z, 90.0, true, false)
SetEntityHealth(ped, 0)
DecorSetInt(ped, "propHack", 74)
SetModelAsNoLongerNeeded('A_C_SharkTiger')
Wait(10000)
DeletePed(ped)
end)
RegisterNetEvent('killerwhale:spawnPed')
AddEventHandler('killerwhale:spawnPed', function()
RequestTheModel("A_C_KillerWhale")
local pos = GetEntityCoords(PlayerPedId())
local ped = CreatePed(29, 'A_C_KillerWhale', pos.x, pos.y, pos.z, 90.0, true, false)
SetEntityHealth(ped, 0)
DecorSetInt(ped, "propHack", 74)
SetModelAsNoLongerNeeded('A_C_KillerWhale')
Wait(10000)
DeletePed(ped)
end)
RegisterNetEvent('stingray:spawnPed')
AddEventHandler('stingray:spawnPed', function()
RequestTheModel("A_C_stingray")
local pos = GetEntityCoords(PlayerPedId())
local ped = CreatePed(29, 'A_C_stingray', pos.x, pos.y, pos.z, 90.0, true, false)
SetEntityHealth(ped, 0)
DecorSetInt(ped, "propHack", 74)
SetModelAsNoLongerNeeded('A_C_stingray')
Wait(10000)
DeletePed(ped)
end)
RegisterNetEvent('sharkhammer:spawnPed')
AddEventHandler('sharkhammer:spawnPed', function()
RequestTheModel("A_C_sharkhammer")
local pos = GetEntityCoords(PlayerPedId())
local ped = CreatePed(29, 'A_C_sharkhammer', pos.x, pos.y, pos.z, 90.0, true, false)
SetEntityHealth(ped, 0)
DecorSetInt(ped, "propHack", 74)
SetModelAsNoLongerNeeded('A_C_sharkhammer')
Wait(10000)
DeletePed(ped)
end)
RegisterNetEvent('dolphin:spawnPed')
AddEventHandler('dolphin:spawnPed', function()
RequestTheModel("A_C_dolphin")
local pos = GetEntityCoords(PlayerPedId())
local ped = CreatePed(29, 'A_C_dolphin', pos.x, pos.y, pos.z, 90.0, true, false)
SetEntityHealth(ped, 0)
DecorSetInt(ped, "propHack", 74)
SetModelAsNoLongerNeeded('A_C_dolphin')
Wait(10000)
DeletePed(ped)
end)
RegisterNetEvent('fish:spawnPed')
AddEventHandler('fish:spawnPed', function()
RequestTheModel("a_c_fish")
local pos = GetEntityCoords(PlayerPedId())
local ped = CreatePed(29, 'a_c_fish', pos.x, pos.y, pos.z, 90.0, true, false)
SetEntityHealth(ped, 0)
DecorSetInt(ped, "propHack", 74)
SetModelAsNoLongerNeeded('a_c_fish')
Wait(10000)
DeletePed(ped)
end)
RegisterNetEvent('fishing:setbait')
AddEventHandler('fishing:setbait', function(bool)
bait = bool
end)
RegisterNetEvent('fishing:fishstart')
AddEventHandler('fishing:fishstart', function()
playerPed = PlayerPedId()
local pos = GetEntityCoords(PlayerPedId())
if IsPedInAnyVehicle(playerPed) then
ESX.ShowNotification("Du kan inte fiska från ett fordon")
else
if GetWaterHeight(pos.x, pos.y, pos.z-2, pos.z-3.0) then
ESX.ShowNotification("Du började fiska\nTryck 'X' för att sluta fiska")
TaskStartScenarioInPlace(PlayerPedId(), "WORLD_HUMAN_STAND_FISHING", 0, true)
fishing = true
print("fishing has started")
else
ESX.ShowNotification("Du måste gå längre bort från stranden")
end
end
end, false)
function RequestTheModel(model)
RequestModel(model)
while not HasModelLoaded(model) do
Citizen.Wait(0)
end
end
RegisterCommand("fish", function(source)
TaskStartScenarioInPlace(PlayerPedId(), "WORLD_HUMAN_STAND_FISHING", 0, true)
fishing = true
end)
config.lua
Config_Fishing = {}
---------------------------------------------------------------
--=====How long should it take for player to catch a fish=======--
---------------------------------------------------------------
--Time in miliseconds
Config_Fishing.FishTime = {a = 20000, b = 44000}
--------------------------------------------------------
--=====Locations where players can sell stuff========--
--------------------------------------------------------
Config_Fishing.Sell = {
{
pos = vec3(-639.58, -1224.0, 10.00),
type = "legal",
sellText = "Fiskhandlare",
blip = 573,
colour = 27
},
{
pos = vec3(-317.21 , -2778.76, 4.0),
type = "illegal",
sellText = "Svart fiskhandel",
blip = 573,
colour = 1
}
}
--------------------------------------------------------
--=====Locations where players can rent boats========--
--------------------------------------------------------
gör en server.lua