forked from Simnation/Main
ed
This commit is contained in:
parent
deb110922c
commit
b952f7107a
3 changed files with 32 additions and 28 deletions
BIN
resources/[inventory]/inventory_images/images/scrap_metal.png
Normal file
BIN
resources/[inventory]/inventory_images/images/scrap_metal.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 242 KiB |
|
@ -10219,7 +10219,7 @@ itemsData = {
|
||||||
type = 'item',
|
type = 'item',
|
||||||
description = '',
|
description = '',
|
||||||
weight = 1000,
|
weight = 1000,
|
||||||
label = 'scrap_metal',
|
label = 'altes Metal',
|
||||||
unique = true,
|
unique = true,
|
||||||
useable = true,
|
useable = true,
|
||||||
image = 'scrap_metal.png',
|
image = 'scrap_metal.png',
|
||||||
|
|
|
@ -81,20 +81,20 @@ local function StartMagnetFishingProcess(selectedMagnet, waterLoc)
|
||||||
magnetFishing = true
|
magnetFishing = true
|
||||||
|
|
||||||
-- Create magnet rope prop
|
-- Create magnet rope prop
|
||||||
local model = `prop_fishing_rod_01` -- Using fishing rod as placeholder, ideally would be replaced with a magnet rope model
|
local model = `prop_tool_cable01` -- Besseres Prop für ein Seil mit Magnet
|
||||||
lib.requestModel(model, 100)
|
lib.requestModel(model, 100)
|
||||||
local magnetRope = CreateObject(model, GetEntityCoords(cache.ped), true, false, false)
|
local magnetRope = CreateObject(model, GetEntityCoords(cache.ped), true, false, false)
|
||||||
AttachEntityToEntity(magnetRope, cache.ped, GetPedBoneIndex(cache.ped, 18905), 0.1, 0.05, 0, 80.0, 120.0, 160.0, true, true, false, true, 1, true)
|
AttachEntityToEntity(magnetRope, cache.ped, GetPedBoneIndex(cache.ped, 28422), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, true, true, false, true, 1, true)
|
||||||
SetModelAsNoLongerNeeded(model)
|
SetModelAsNoLongerNeeded(model)
|
||||||
|
|
||||||
-- Load animations
|
-- Load animations
|
||||||
lib.requestAnimDict('mini@tennis', 100)
|
lib.requestAnimDict('amb@world_human_hammering@male@base', 100) -- Für das Auswerfen
|
||||||
lib.requestAnimDict('amb@world_human_stand_fishing@idle_a', 100)
|
lib.requestAnimDict('amb@world_human_hang_out_street@male_c@base', 100) -- Für das Warten
|
||||||
|
|
||||||
-- Initial casting animation
|
-- Initial animation - Auswerfen des Magneten
|
||||||
TaskPlayAnim(cache.ped, 'mini@tennis', 'forehand_ts_md_far', 1.0, -1.0, 1.0, 48, 0, 0, 0, 0)
|
TaskPlayAnim(cache.ped, 'amb@world_human_hammering@male@base', 'base', 8.0, -8.0, -1, 16, 0, false, false, false)
|
||||||
Wait(3000)
|
Wait(2000)
|
||||||
TaskPlayAnim(cache.ped, 'amb@world_human_stand_fishing@idle_a', 'idle_c', 1.0, -1.0, 1.0, 11, 0, 0, 0, 0)
|
TaskPlayAnim(cache.ped, 'amb@world_human_hang_out_street@male_c@base', 'base', 8.0, -8.0, -1, 1, 0, false, false, false)
|
||||||
|
|
||||||
-- Main magnet fishing loop
|
-- Main magnet fishing loop
|
||||||
while magnetFishing do
|
while magnetFishing do
|
||||||
|
@ -106,9 +106,9 @@ local function StartMagnetFishingProcess(selectedMagnet, waterLoc)
|
||||||
|
|
||||||
-- Cast magnet
|
-- Cast magnet
|
||||||
if IsDisabledControlJustReleased(0, 24) then
|
if IsDisabledControlJustReleased(0, 24) then
|
||||||
-- Casting animation
|
-- Auswerfen Animation
|
||||||
TaskPlayAnim(cache.ped, 'mini@tennis', 'forehand_ts_md_far', 1.0, -1.0, 1.0, 48, 0, 0, 0, 0)
|
TaskPlayAnim(cache.ped, 'amb@world_human_hammering@male@base', 'base', 8.0, -8.0, -1, 16, 0, false, false, false)
|
||||||
TriggerEvent('wasabi_magnet:notify', Strings.waiting_find, Strings.waiting_find_desc, 'inform')
|
TriggerEvent('nordi_magnetfishing:notify', Strings.waiting_find, Strings.waiting_find_desc, 'inform')
|
||||||
|
|
||||||
-- Wait for magnet to find something
|
-- Wait for magnet to find something
|
||||||
local waitTime = math.random(Config.timeForFind.min, Config.timeForFind.max)
|
local waitTime = math.random(Config.timeForFind.min, Config.timeForFind.max)
|
||||||
|
@ -119,59 +119,62 @@ local function StartMagnetFishingProcess(selectedMagnet, waterLoc)
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
|
||||||
TriggerEvent('wasabi_magnet:notify', Strings.got_pull, Strings.got_pull_desc, 'inform')
|
TriggerEvent('nordi_magnetfishing:notify', Strings.got_pull, Strings.got_pull_desc, 'inform')
|
||||||
Wait(1000)
|
Wait(1000)
|
||||||
|
|
||||||
-- Get find data based on selected magnet
|
-- Get find data based on selected magnet
|
||||||
local findData = lib.callback.await('wasabi_magnet:getFindData', 100, selectedMagnet.itemName)
|
local findData = lib.callback.await('nordi_magnetfishing:getFindData', 100, selectedMagnet.itemName)
|
||||||
|
|
||||||
-- Skill check to retrieve find
|
-- Skill check to retrieve find
|
||||||
if lib.skillCheck(findData.difficulty) then
|
if lib.skillCheck(findData.difficulty) then
|
||||||
|
-- Erfolgreiche Zieh-Animation
|
||||||
ClearPedTasks(cache.ped)
|
ClearPedTasks(cache.ped)
|
||||||
|
TaskPlayAnim(cache.ped, 'amb@world_human_hammering@male@base', 'base', 8.0, -8.0, -1, 16, 0, false, false, false)
|
||||||
|
Wait(1500)
|
||||||
TryMagnetFind(findData)
|
TryMagnetFind(findData)
|
||||||
TaskPlayAnim(cache.ped, 'amb@world_human_stand_fishing@idle_a', 'idle_c', 1.0, -1.0, 1.0, 11, 0, 0, 0, 0)
|
TaskPlayAnim(cache.ped, 'amb@world_human_hang_out_street@male_c@base', 'base', 8.0, -8.0, -1, 1, 0, false, false, false)
|
||||||
|
|
||||||
-- Check for magnet loss
|
-- Check for magnet loss
|
||||||
local loseChance = math.random(1,100)
|
local loseChance = math.random(1,100)
|
||||||
if loseChance <= selectedMagnet.loseChance then
|
if loseChance <= selectedMagnet.loseChance then
|
||||||
TriggerServerEvent('wasabi_magnet:loseMagnet', selectedMagnet.itemName)
|
TriggerServerEvent('nordi_magnetfishing:loseMagnet', selectedMagnet.itemName)
|
||||||
TriggerEvent('wasabi_magnet:notify', Strings.magnet_lost, Strings.magnet_lost_desc, 'error')
|
TriggerEvent('nordi_magnetfishing:notify', Strings.magnet_lost, Strings.magnet_lost_desc, 'error')
|
||||||
|
|
||||||
-- Check if we still have this magnet
|
-- Check if we still have this magnet
|
||||||
local hasMagnet = lib.callback.await('wasabi_magnet:checkItem', 100, selectedMagnet.itemName)
|
local hasMagnet = lib.callback.await('nordi_magnetfishing:checkItem', 100, selectedMagnet.itemName)
|
||||||
if not hasMagnet then
|
if not hasMagnet then
|
||||||
-- Try to get a new magnet
|
-- Try to get a new magnet
|
||||||
local newMagnet = GetBestAvailableMagnet()
|
local newMagnet = GetBestAvailableMagnet()
|
||||||
if newMagnet then
|
if newMagnet then
|
||||||
selectedMagnet = newMagnet
|
selectedMagnet = newMagnet
|
||||||
TriggerEvent('wasabi_magnet:notify', 'New Magnet', 'Using ' .. selectedMagnet.label .. ' as magnet', 'inform')
|
TriggerEvent('nordi_magnetfishing:notify', 'Neuer Magnet', 'Du verwendest jetzt ' .. selectedMagnet.label, 'inform')
|
||||||
else
|
else
|
||||||
TriggerEvent('wasabi_magnet:notify', Strings.no_magnet, Strings.no_magnet_desc, 'error')
|
TriggerEvent('nordi_magnetfishing:notify', Strings.no_magnet, Strings.no_magnet_desc, 'error')
|
||||||
magnetFishing = false
|
magnetFishing = false
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
-- Failed to retrieve find
|
-- Failed to retrieve find - Fehlgeschlagene Animation
|
||||||
local breakChance = math.random(1,100)
|
local breakChance = math.random(1,100)
|
||||||
if breakChance < Config.magnetRope.breakChance then
|
if breakChance < Config.magnetRope.breakChance then
|
||||||
TriggerServerEvent('wasabi_magnet:ropeBroke')
|
TriggerServerEvent('nordi_magnetfishing:ropeBroke')
|
||||||
TriggerEvent('wasabi_magnet:notify', Strings.rope_broke, Strings.rope_broke_desc, 'error')
|
TriggerEvent('nordi_magnetfishing:notify', Strings.rope_broke, Strings.rope_broke_desc, 'error')
|
||||||
ClearPedTasks(cache.ped)
|
ClearPedTasks(cache.ped)
|
||||||
magnetFishing = false
|
magnetFishing = false
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
TriggerEvent('wasabi_magnet:notify', Strings.failed_find, Strings.failed_find_desc, 'error')
|
TriggerEvent('nordi_magnetfishing:notify', Strings.failed_find, Strings.failed_find_desc, 'error')
|
||||||
end
|
end
|
||||||
elseif IsControlJustReleased(0, 194) then
|
elseif IsControlJustReleased(0, 194) then
|
||||||
-- Cancel magnet fishing with backspace
|
-- Cancel magnet fishing with backspace
|
||||||
ClearPedTasks(cache.ped)
|
ClearPedTasks(cache.ped)
|
||||||
TriggerEvent('wasabi_magnet:notify', 'Magnet Fishing Canceled', 'You stopped magnet fishing', 'inform')
|
TriggerEvent('nordi_magnetfishing:notify', 'Magnet Fishing abgebrochen', 'Du hast aufgehört zu angeln', 'inform')
|
||||||
break
|
break
|
||||||
elseif #(GetEntityCoords(cache.ped) - waterLoc) > 30 then
|
elseif #(GetEntityCoords(cache.ped) - waterLoc) > 30 then
|
||||||
-- Too far from water
|
-- Too far from water
|
||||||
TriggerEvent('wasabi_magnet:notify', 'Too Far', 'You moved too far from the water', 'error')
|
TriggerEvent('nordi_magnetfishing:notify', 'Zu weit weg', 'Du bist zu weit vom Wasser entfernt', 'error')
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -179,10 +182,11 @@ local function StartMagnetFishingProcess(selectedMagnet, waterLoc)
|
||||||
-- Clean up
|
-- Clean up
|
||||||
magnetFishing = false
|
magnetFishing = false
|
||||||
DeleteObject(magnetRope)
|
DeleteObject(magnetRope)
|
||||||
RemoveAnimDict('mini@tennis')
|
RemoveAnimDict('amb@world_human_hammering@male@base')
|
||||||
RemoveAnimDict('amb@world_human_stand_fishing@idle_a')
|
RemoveAnimDict('amb@world_human_hang_out_street@male_c@base')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
RegisterNetEvent('wasabi_magnet:startMagnetFishing', function()
|
RegisterNetEvent('wasabi_magnet:startMagnetFishing', function()
|
||||||
-- Check if player is in a valid state to magnet fish
|
-- Check if player is in a valid state to magnet fish
|
||||||
if IsPedInAnyVehicle(cache.ped) or IsPedSwimming(cache.ped) then
|
if IsPedInAnyVehicle(cache.ped) or IsPedSwimming(cache.ped) then
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue