forked from Simnation/Main
ed
This commit is contained in:
parent
b952f7107a
commit
36021d9578
4 changed files with 64 additions and 33 deletions
|
@ -1,6 +1,39 @@
|
||||||
-----------------For support, scripts, and more----------------
|
-----------------For support, scripts, and more----------------
|
||||||
--------------- https://discord.gg/wasabiscripts -------------
|
--------------- https://discord.gg/wasabiscripts -------------
|
||||||
---------------------------------------------------------------
|
---------------------------------------------------------------
|
||||||
|
|
||||||
|
-- Definiere Strings direkt in der client.lua, falls sie nicht geladen wurden
|
||||||
|
if not Strings then
|
||||||
|
Strings = {
|
||||||
|
intro_instruction = 'Drücke ~INPUT_ATTACK~ zum Auswerfen, ~INPUT_FRONTEND_RRIGHT~ zum Abbrechen.',
|
||||||
|
rope_broke = 'Kaputt.',
|
||||||
|
rope_broke_desc = 'Oha, zu fest gezogen! Das Seil ist gerissen.',
|
||||||
|
cannot_perform = 'Nope.',
|
||||||
|
cannot_perform_desc = 'Das geht gerade nicht – hier kannst du nicht magnet-fischen.',
|
||||||
|
failed = 'Oops, das war nix.',
|
||||||
|
failed_find = 'Nichts gefunden – der Magnet hat nichts angezogen.',
|
||||||
|
no_water = 'Error 404: Wasser nicht gefunden.',
|
||||||
|
no_water_desc = 'Dein Magnet braucht Wasser, um effektiv zu sein.',
|
||||||
|
no_magnet = 'Kein Magnet.',
|
||||||
|
no_magnet_desc = 'Ohne Magnet kannst du nichts anziehen.',
|
||||||
|
magnet_lost = 'Magnet verloren.',
|
||||||
|
magnet_lost_desc = 'Dein Magnet hat sich vom Seil gelöst.',
|
||||||
|
find_success = 'Fund gesichert!',
|
||||||
|
find_success_desc = 'Du hast eine/n %s gefunden!',
|
||||||
|
sell_shop_blip = 'Schrotthändler',
|
||||||
|
sell_finds = '[E] - Funde verkaufen',
|
||||||
|
kicked = "Du kannst's versuchen, aber das klappt hier nicht.",
|
||||||
|
sold_for = 'Fund verkauft.',
|
||||||
|
sold_for_desc = 'Du hast %sx %s für $%s verkauft.',
|
||||||
|
got_pull = 'Achtung, da zieht was!',
|
||||||
|
got_pull_desc = 'Der Magnet hat etwas gefunden, zieh ihn hoch!',
|
||||||
|
waiting_find = 'Geduld, der Magnet sucht noch.',
|
||||||
|
waiting_find_desc = 'Ein bisschen Geduld – gleich findest du etwas.',
|
||||||
|
cannot_carry = 'Kein Platz!',
|
||||||
|
cannot_carry_desc = 'Du schleppst schon genug – mehr passt nicht rein!'
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
local magnetFishing = false
|
local magnetFishing = false
|
||||||
|
|
||||||
if Config.sellShop.enabled then
|
if Config.sellShop.enabled then
|
||||||
|
@ -57,7 +90,7 @@ local function GetBestAvailableMagnet()
|
||||||
|
|
||||||
-- Check all magnet types
|
-- Check all magnet types
|
||||||
for _, magnet in pairs(Config.magnets.types) do
|
for _, magnet in pairs(Config.magnets.types) do
|
||||||
local hasItem = lib.callback.await('wasabi_magnet:checkItem', 100, magnet.itemName)
|
local hasItem = lib.callback.await('nordi_magnetfishing:checkItem', 100, magnet.itemName)
|
||||||
if hasItem then
|
if hasItem then
|
||||||
table.insert(availableMagnets, magnet)
|
table.insert(availableMagnets, magnet)
|
||||||
end
|
end
|
||||||
|
@ -81,20 +114,20 @@ local function StartMagnetFishingProcess(selectedMagnet, waterLoc)
|
||||||
magnetFishing = true
|
magnetFishing = true
|
||||||
|
|
||||||
-- Create magnet rope prop
|
-- Create magnet rope prop
|
||||||
local model = `prop_tool_cable01` -- Besseres Prop für ein Seil mit Magnet
|
local model = `prop_cs_rope_tie_01` -- 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, 28422), 0.0, 0.0, 0.0, 0.0, 0.0, 0.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('amb@world_human_hammering@male@base', 100) -- Für das Auswerfen
|
lib.requestAnimDict('amb@world_human_golf_player@male@idle_a', 100) -- Für das Auswerfen
|
||||||
lib.requestAnimDict('amb@world_human_hang_out_street@male_c@base', 100) -- Für das Warten
|
lib.requestAnimDict('amb@world_human_stand_fishing@idle_a', 100) -- Für das Warten
|
||||||
|
|
||||||
-- Initial animation - Auswerfen des Magneten
|
-- Initial animation - Auswerfen des Magneten
|
||||||
TaskPlayAnim(cache.ped, 'amb@world_human_hammering@male@base', 'base', 8.0, -8.0, -1, 16, 0, false, false, false)
|
TaskPlayAnim(cache.ped, 'amb@world_human_golf_player@male@idle_a', 'idle_a' , 8.0, -8.0, -1, 16, 0, false, false, false)
|
||||||
Wait(2000)
|
Wait(2000)
|
||||||
TaskPlayAnim(cache.ped, 'amb@world_human_hang_out_street@male_c@base', 'base', 8.0, -8.0, -1, 1, 0, false, false, false)
|
TaskPlayAnim(cache.ped, 'amb@world_human_stand_fishing@idle_a', 'idle_c', 8.0, -8.0, -1, 1, 0, false, false, false)
|
||||||
|
|
||||||
-- Main magnet fishing loop
|
-- Main magnet fishing loop
|
||||||
while magnetFishing do
|
while magnetFishing do
|
||||||
|
@ -186,40 +219,39 @@ local function StartMagnetFishingProcess(selectedMagnet, waterLoc)
|
||||||
RemoveAnimDict('amb@world_human_hang_out_street@male_c@base')
|
RemoveAnimDict('amb@world_human_hang_out_street@male_c@base')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
RegisterNetEvent('nordi_magnetfishing: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
|
||||||
TriggerEvent('wasabi_magnet:notify', Strings.cannot_perform, Strings.cannot_perform_desc, 'error')
|
TriggerEvent('nordi_magnetfishing:notify', Strings.cannot_perform, Strings.cannot_perform_desc, 'error')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Check if already magnet fishing
|
-- Check if already magnet fishing
|
||||||
if magnetFishing then
|
if magnetFishing then
|
||||||
TriggerEvent('wasabi_magnet:notify', 'Already Magnet Fishing', 'You are already magnet fishing', 'error')
|
TriggerEvent('nordi_magnetfishing:notify', 'Already Magnet Fishing', 'You are already magnet fishing', 'error')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Check for water
|
-- Check for water
|
||||||
local water, waterLoc = WaterCheck()
|
local water, waterLoc = WaterCheck()
|
||||||
if not water then
|
if not water then
|
||||||
TriggerEvent('wasabi_magnet:notify', Strings.no_water, Strings.no_water_desc, 'error')
|
TriggerEvent('nordi_magnetfishing:notify', Strings.no_water, Strings.no_water_desc, 'error')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Select magnet
|
-- Select magnet
|
||||||
local selectedMagnet = GetBestAvailableMagnet()
|
local selectedMagnet = GetBestAvailableMagnet()
|
||||||
if not selectedMagnet then
|
if not selectedMagnet then
|
||||||
TriggerEvent('wasabi_magnet:notify', Strings.no_magnet, Strings.no_magnet_desc, 'error')
|
TriggerEvent('nordi_magnetfishing:notify', Strings.no_magnet, Strings.no_magnet_desc, 'error')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Start magnet fishing process
|
-- Start magnet fishing process
|
||||||
TriggerEvent('wasabi_magnet:notify', 'Magnet Selected', 'Using ' .. selectedMagnet.label, 'inform')
|
TriggerEvent('nordi_magnetfishing:notify', 'Magnet Selected', 'Using ' .. selectedMagnet.label, 'inform')
|
||||||
StartMagnetFishingProcess(selectedMagnet, waterLoc)
|
StartMagnetFishingProcess(selectedMagnet, waterLoc)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterNetEvent('wasabi_magnet:interupt', function()
|
RegisterNetEvent('nordi_magnetfishing:interupt', function()
|
||||||
magnetFishing = false
|
magnetFishing = false
|
||||||
ClearPedTasks(cache.ped)
|
ClearPedTasks(cache.ped)
|
||||||
end)
|
end)
|
||||||
|
|
|
@ -28,9 +28,9 @@ CreateBlip = function(coords, sprite, colour, text, scale)
|
||||||
end
|
end
|
||||||
|
|
||||||
TryMagnetFind = function(data)
|
TryMagnetFind = function(data)
|
||||||
TriggerServerEvent('wasabi_magnet:tryFind', data)
|
TriggerServerEvent('nordi_magnetfishing:tryFind', data)
|
||||||
end
|
end
|
||||||
|
|
||||||
MagnetSellItems = function()
|
MagnetSellItems = function()
|
||||||
TriggerServerEvent('wasabi_magnet:sellFinds')
|
TriggerServerEvent('nordi_magnetfishing:sellFinds')
|
||||||
end
|
end
|
||||||
|
|
|
@ -65,11 +65,10 @@ Config.finds = {
|
||||||
{ item = 'old_gun', label = 'alte Pistole', price = {75, 150}, difficulty = {'easy'} },
|
{ item = 'old_gun', label = 'alte Pistole', price = {75, 150}, difficulty = {'easy'} },
|
||||||
{ item = 'escooter', label = 'E-Scooter', price = {300, 600}, difficulty = {'medium', 'hard'} },
|
{ item = 'escooter', label = 'E-Scooter', price = {300, 600}, difficulty = {'medium', 'hard'} },
|
||||||
{ item = 'safe', label = 'Tresor', price = {500, 1000}, difficulty = {'hard', 'hard', 'medium'} },
|
{ item = 'safe', label = 'Tresor', price = {500, 1000}, difficulty = {'hard', 'hard', 'medium'} },
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RegisterNetEvent('wasabi_magnet:notify')
|
RegisterNetEvent('nordi_magnetfishing:notify')
|
||||||
AddEventHandler('wasabi_magnet:notify', function(title, message, msgType)
|
AddEventHandler('nordi_magnetfishing:notify', function(title, message, msgType)
|
||||||
-- Place notification system info here, ex: exports['mythic_notify']:SendAlert('inform', message)
|
-- Place notification system info here, ex: exports['mythic_notify']:SendAlert('inform', message)
|
||||||
if not msgType then
|
if not msgType then
|
||||||
lib.notify({
|
lib.notify({
|
||||||
|
|
|
@ -6,7 +6,7 @@ local addCommas = function(n)
|
||||||
:gsub(",(%-?)$","%1"):reverse()
|
:gsub(",(%-?)$","%1"):reverse()
|
||||||
end
|
end
|
||||||
|
|
||||||
lib.callback.register('wasabi_magnet:checkItem', function(source, itemname)
|
lib.callback.register('nordi_magnetfishing:checkItem', function(source, itemname)
|
||||||
local item = HasItem(source, itemname)
|
local item = HasItem(source, itemname)
|
||||||
if item >= 1 then
|
if item >= 1 then
|
||||||
return true
|
return true
|
||||||
|
@ -15,7 +15,7 @@ lib.callback.register('wasabi_magnet:checkItem', function(source, itemname)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
lib.callback.register('wasabi_magnet:getFindData', function(source, magnetType)
|
lib.callback.register('nordi_magnetfishing:getFindData', function(source, magnetType)
|
||||||
-- Find the magnet data
|
-- Find the magnet data
|
||||||
local magnetData = nil
|
local magnetData = nil
|
||||||
for _, magnet in pairs(Config.magnets.types) do
|
for _, magnet in pairs(Config.magnets.types) do
|
||||||
|
@ -72,16 +72,16 @@ lib.callback.register('wasabi_magnet:getFindData', function(source, magnetType)
|
||||||
return availableFinds[math.random(#availableFinds)]
|
return availableFinds[math.random(#availableFinds)]
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterNetEvent('wasabi_magnet:ropeBroke', function()
|
RegisterNetEvent('nordi_magnetfishing:ropeBroke', function()
|
||||||
RemoveItem(source, Config.magnetRope.itemName, 1)
|
RemoveItem(source, Config.magnetRope.itemName, 1)
|
||||||
TriggerClientEvent('wasabi_magnet:interupt', source)
|
TriggerClientEvent('nordi_magnetfishing:interupt', source)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterNetEvent('wasabi_magnet:loseMagnet', function(magnetType)
|
RegisterNetEvent('nordi_magnetfishing:loseMagnet', function(magnetType)
|
||||||
RemoveItem(source, magnetType, 1)
|
RemoveItem(source, magnetType, 1)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterNetEvent('wasabi_magnet:tryFind', function(data)
|
RegisterNetEvent('nordi_magnetfishing:tryFind', function(data)
|
||||||
local xRope = HasItem(source, Config.magnetRope.itemName)
|
local xRope = HasItem(source, Config.magnetRope.itemName)
|
||||||
local xMagnet = false
|
local xMagnet = false
|
||||||
|
|
||||||
|
@ -98,23 +98,23 @@ RegisterNetEvent('wasabi_magnet:tryFind', function(data)
|
||||||
local player = GetPlayer(source)
|
local player = GetPlayer(source)
|
||||||
if player.canCarryItem(data.item, 1) then
|
if player.canCarryItem(data.item, 1) then
|
||||||
AddItem(source, data.item, 1)
|
AddItem(source, data.item, 1)
|
||||||
TriggerClientEvent('wasabi_magnet:notify', source, Strings.find_success, string.format(Strings.find_success_desc, data.label), 'success')
|
TriggerClientEvent('nordi_magnetfishing:notify', source, Strings.find_success, string.format(Strings.find_success_desc, data.label), 'success')
|
||||||
else
|
else
|
||||||
TriggerClientEvent('wasabi_magnet:notify', source, Strings.cannot_carry, Strings.cannot_carry_desc, 'error')
|
TriggerClientEvent('nordi_magnetfishing:notify', source, Strings.cannot_carry, Strings.cannot_carry_desc, 'error')
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
AddItem(source, data.item, 1)
|
AddItem(source, data.item, 1)
|
||||||
TriggerClientEvent('wasabi_magnet:notify', source, Strings.find_success, string.format(Strings.find_success_desc, data.label), 'success')
|
TriggerClientEvent('nordi_magnetfishing:notify', source, Strings.find_success, string.format(Strings.find_success_desc, data.label), 'success')
|
||||||
end
|
end
|
||||||
elseif xRope > 0 and not xMagnet then
|
elseif xRope > 0 and not xMagnet then
|
||||||
TriggerClientEvent('wasabi_magnet:interupt', source)
|
TriggerClientEvent('nordi_magnetfishing:interupt', source)
|
||||||
TriggerClientEvent('wasabi_magnet:notify', source, Strings.no_magnet, Strings.no_magnet_desc, 'error')
|
TriggerClientEvent('nordi_magnetfishing:notify', source, Strings.no_magnet, Strings.no_magnet_desc, 'error')
|
||||||
elseif xRope < 1 then
|
elseif xRope < 1 then
|
||||||
KickPlayer(source, Strings.kicked)
|
KickPlayer(source, Strings.kicked)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterNetEvent('wasabi_magnet:sellFinds', function()
|
RegisterNetEvent('nordi_magnetfishing:sellFinds', function()
|
||||||
local playerPed = GetPlayerPed(source)
|
local playerPed = GetPlayerPed(source)
|
||||||
local playerCoord = GetEntityCoords(playerPed)
|
local playerCoord = GetEntityCoords(playerPed)
|
||||||
local distance = #(playerCoord - Config.sellShop.coords)
|
local distance = #(playerCoord - Config.sellShop.coords)
|
||||||
|
@ -142,7 +142,7 @@ function SellItem(source, itemData)
|
||||||
end
|
end
|
||||||
if rewardAmount > 0 then
|
if rewardAmount > 0 then
|
||||||
AddMoney(source, 'money', rewardAmount)
|
AddMoney(source, 'money', rewardAmount)
|
||||||
TriggerClientEvent('wasabi_magnet:notify', source, Strings.sold_for,
|
TriggerClientEvent('nordi_magnetfishing:notify', source, Strings.sold_for,
|
||||||
(Strings.sold_for_desc):format(HasItem(source, itemData.item), itemData.label, addCommas(rewardAmount)), 'success')
|
(Strings.sold_for_desc):format(HasItem(source, itemData.item), itemData.label, addCommas(rewardAmount)), 'success')
|
||||||
RemoveItem(source, itemData.item, HasItem(source, itemData.item))
|
RemoveItem(source, itemData.item, HasItem(source, itemData.item))
|
||||||
end
|
end
|
||||||
|
@ -150,5 +150,5 @@ function SellItem(source, itemData)
|
||||||
end
|
end
|
||||||
|
|
||||||
RegisterUsableItem(Config.magnetRope.itemName, function(source)
|
RegisterUsableItem(Config.magnetRope.itemName, function(source)
|
||||||
TriggerClientEvent('wasabi_magnet:startMagnetFishing', source)
|
TriggerClientEvent('nordi_magnetfishing:startMagnetFishing', source)
|
||||||
end)
|
end)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue