1111123
local TE = 0local TE2 = 0
local TE3 = 0
local TE4 = 0
local MissionStarted = false
local MissionStoped = true
local CheckPressedKey = false
local AxeOnHand = false
local Vehicle = nil
local HaveBox = false
local BoxInVehicle = false
local ProcessUnderSecondPart = false
local DrawOn = false
local DrawTextNum = 0
local Draw1 = false
local UnderCutting = false
local BreakShit = false
local BreakShit2 = false
function DrawText3D(msg, coords)
AddTextEntry('esxFloatingHelpNotification', msg)
SetFloatingHelpTextWorldPosition(1, coords)
SetFloatingHelpTextStyle(1, 1, 2, -1, 3, 0)
BeginTextCommandDisplayHelp('esxFloatingHelpNotification')
EndTextCommandDisplayHelp(2, false, false, -1)
end
Citizen.CreateThread(function()
if Config.NPC == true then
for k,v in pairs(Config.Peds) do
RequestModel(v.Hash)
while not HasModelLoaded(v.Hash) do
Wait(1)
end
CreateSellPed = CreatePed(1, v.Hash, v.x, v.y, v.z - 1, v.h, false, false)
SetBlockingOfNonTemporaryEvents(CreateSellPed, true)
SetPedDiesWhenInjured(CreateSellPed, false)
SetPedCanPlayAmbientAnims(CreateSellPed, true)
SetPedCanRagdollFromPlayerImpact(CreateSellPed, false)
SetEntityInvincible(CreateSellPed, true)
FreezeEntityPosition(CreateSellPed, true)
TaskStartScenarioInPlace(CreateSellPed, v.Anim, 0, true);
end
end
end)
Citizen.CreateThread(function()
if Config.BlipsEnable == true then
for k,v in pairs(Config.Blips) do
v.blip = AddBlipForCoord(v.Coords, v.Coords, v.Coords) --> Cordinate <--
SetBlipSprite(v.blip, v.ID) --> Form <--
SetBlipAsShortRange(v.blip, true)
BeginTextCommandSetBlipName("STRING")
SetBlipColour(v.blip, v.Color) --> Color <--
SetBlipScale(v.blip, v.Scale) --> Size <--
AddTextComponentString(v.Name) --> Name <--
EndTextCommandSetBlipName(v.blip)
end
end
end)
function playAnim(animDict, animName, duration)
RequestAnimDict(animDict)
while not HasAnimDictLoaded(animDict) do Citizen.Wait(0) end
TaskPlayAnim(PlayerPedId(), animDict, animName, 1.0, -1.0, duration, 49, 1, false, false, false)
RemoveAnimDict(animDict)
end
function Notification(msg)
SetNotificationTextEntry("STRING")
AddTextComponentString(msg)
DrawNotification(false, false)
end
function CancelAll()
if Vehicle ~= nil then
if plate == GetVehicleNumberPlateText(GetVehiclePedIsIn(PlayerPedId(), true)) then
DeleteEntity(Vehicle)
DeleteVehicle(Vehicle)
Vehicle = nil
MissionStoped = true
MissionStarted = false
CheckPressedKey = false
BoxInVehicle = false
HaveBox = false
AxeOnHand = false
DetachEntity(GiveAxeToHand, 1, true)
DeleteEntity(GiveAxeToHand)
DeleteObject(GiveAxeToHand)
SetCurrentPedWeapon(PlayerPedId(), GetHashKey('WEAPON_UNARMED'))
ClearPedTasks(PlayerPedId())
DeleteObject(AddPropToPlayer)
DeleteObject(GiveAxeToHand)
DrawOn = false
DrawTextNum = 0
TE = 0
TE2 = 0
TE3 = 0
TE4 = 0
UnderCutting = false
TreeHitFinished = false
TreeHitFinished2 = false
TreeHitFinished3 = false
TreeHitFinished4 = false
ProcessUnderSecondPart = false
Draw1 = false
BreakShit = false
BreakShit2 = false
else
Notification("上车,然后下车,然后再试一次。要归还车辆,我们首先需要知道它是否是您的。")
end
end
end
RegisterNetEvent('oph3z-lumberjack:Notify')
AddEventHandler('oph3z-lumberjack:Notify', function(Notify)
Notification(Notify)
end)
RegisterNetEvent('oph3z-lumberjack:StartMission')
AddEventHandler('oph3z-lumberjack:StartMission', function()
Notification('你去上班,买了一把斧子和一辆车。 GPS 上标记了您的工作地点。当心!')
MissionStarted = true
CheckPressedKey = true
MissionStoped = false
SetNewWaypoint(-684.80, 5354.48)
local modelHash = GetHashKey(Config.CarModel)
RequestModel(modelHash)
while not HasModelLoaded(modelHash) do
Wait(0)
end
Vehicle = CreateVehicle(modelHash, Config.CarSpawnCoords, 68.84, 1, 0) -- 68.84 = heading
plate = GetVehicleNumberPlateText(Vehicle)
SetVehicleFuelLevel(Vehicle, 100.0)
SetVehicleDirtLevel(Vehicle, 0.0)
end)
Citizen.CreateThread(function()
while true do
local sleep = 2000
local PlayerCoords = GetEntityCoords(PlayerPedId())
local Distance = GetDistanceBetweenCoords(PlayerCoords, Config.MissionCoords.x, Config.MissionCoords.y, Config.MissionCoords.z, true)
if Distance < 6 then
if not CheckPressedKey then
sleep = 3
DrawText3D('~INPUT_PICKUP~ - 开始任务', vector3(Config.MissionCoords.x, Config.MissionCoords.y, Config.MissionCoords.z + 0.0))
else
sleep = 3
DrawText3D('~INPUT_PICKUP~ - 停止任务', vector3(Config.MissionCoords.x, Config.MissionCoords.y, Config.MissionCoords.z + 0.0))
end
if not CheckPressedKey and IsControlJustReleased(0, 38) then
TriggerServerEvent('oph3z-lumberjack:CheckMoney')
elseif CheckPressedKey and IsControlJustReleased(0, 38) then
CancelAll()
end
end
Citizen.Wait(sleep)
end
end)
Citizen.CreateThread(function()
while true do
local sleep = 2000
local PlayerCoords = GetEntityCoords(PlayerPedId())
if MissionStarted == true then
local Distance = GetDistanceBetweenCoords(PlayerCoords, Config.TreeZone.x, Config.TreeZone.y, Config.TreeZone.z, true)
if Distance < 40 then
sleep = 3
CreateTree1()
CreateTree2()
CreateTree3()
CreateTree4()
end
elseif MissionStoped == true then
DeleteObject(Tree1)
DeleteObject(Tree2)
DeleteObject(Tree3)
DeleteObject(Tree4)
end
Citizen.Wait(sleep)
end
end)
Citizen.CreateThread(function()
while true do
Citizen.Wait(1000)
local PlayerCoords = GetEntityCoords(PlayerPedId())
local Distance = GetDistanceBetweenCoords(PlayerCoords, Config.VehicleRange.x, Config.VehicleRange.y, Config.VehicleRange.z, true)
if Distance > Config.VehicleOutRange and IsPedInVehicle(PlayerPedId(), Vehicle, true) and not IsEntityDead(PlayerPedId()) and MissionStarted then
Notification("你不能去任何你想去的地方,它是一辆商务车,它不适合你旅行!")
SetPedCoordsKeepVehicle(PlayerPedId(), Config.CarSpawnCoords.x, Config.CarSpawnCoords.y, Config.CarSpawnCoords.z)
else
if Distance > Config.NormalRange and not IsPedInVehicle(PlayerPedId(), Vehicle, true) and not IsEntityDead(PlayerPedId()) and MissionStarted then
CancelAll()
Notification("你的工作被夺走了,你的车被毁了,因为你走得太远了")
end
end
end
end)
-- Trees
Citizen.CreateThread(function()
while true do
local sleep = 2000
local Player = PlayerPedId()
local PlayerCoords = GetEntityCoords(Player)
local FirstTreeCoords = GetDistanceBetweenCoords(PlayerCoords, Config.FirstTreeDrawCoords.x, Config.FirstTreeDrawCoords.y, Config.FirstTreeDrawCoords.z, true)
local DrawTextCoord = GetDistanceBetweenCoords(PlayerCoords, Config.FirstTreeSecondDraw.x, Config.FirstTreeSecondDraw.y, Config.FirstTreeSecondDraw.z, true)
if TE == 0 and FirstTreeCoords < 2 and MissionStarted then
sleep = 3
DrawText3D('0%', vector3(Config.FirstTreeDrawCoords.x, Config.FirstTreeDrawCoords.y, Config.FirstTreeDrawCoords.z + 0.2))
elseif TE == 1 and FirstTreeCoords < 2 and MissionStarted then
sleep = 3
DrawText3D('25%', vector3(Config.FirstTreeDrawCoords.x, Config.FirstTreeDrawCoords.y, Config.FirstTreeDrawCoords.z + 0.2))
elseif TE == 2 and FirstTreeCoords < 2 and MissionStarted then
sleep = 3
DrawText3D('50%', vector3(Config.FirstTreeDrawCoords.x, Config.FirstTreeDrawCoords.y, Config.FirstTreeDrawCoords.z + 0.2))
elseif TE == 3 and FirstTreeCoords < 2 and MissionStarted then
sleep = 3
DrawText3D('75%', vector3(Config.FirstTreeDrawCoords.x, Config.FirstTreeDrawCoords.y, Config.FirstTreeDrawCoords.z + 0.2))
elseif DrawTextCoord < 5 and ProcessUnderSecondPart and not DrawOn then
sleep = 3
DrawText3D('~INPUT_PICKUP~ - 切割', vector3(Config.FirstTreeSecondDraw.x, Config.FirstTreeSecondDraw.y, Config.FirstTreeSecondDraw.z + 0.2))
elseif DrawTextCoord < 5 and ProcessUnderSecondPart and DrawOn and not Draw1 then
sleep = 3
DrawText3D(DrawTextNum.. '%', vector3(Config.FirstTreeSecondDraw.x, Config.FirstTreeSecondDraw.y, Config.FirstTreeSecondDraw.z + 0.2))
end
if FirstTreeCoords < 5 and IsControlJustReleased(1, 346) and not UnderCutting then
if AxeOnHand then
playAnim("amb@world_human_hammering@male@base", "base", 3000)
TaskPlayAnim(Player, "amb@world_human_hammering@male@base", "base", 1.0, -1.0, 1000, 49, 1, false, false, false)
Citizen.Wait(3000)
ClearPedTasksImmediately(Player)
TE = TE + 1
end
if TE == 4 then
TreeHitFinished = true
UnderCutting = true
end
end
if ProcessUnderSecondPart then
if DrawTextCoord < 5 then
if IsControlJustReleased(0, 38) then
if AxeOnHand then
DrawOn = true
playAnim("mini@repair", "fixing_a_ped", 50000)
end
end
end
end
local SecondTreeDrawCoords = GetDistanceBetweenCoords(PlayerCoords, Config.SecondTreeDrawCoords.x, Config.SecondTreeDrawCoords.y, Config.SecondTreeDrawCoords.z, true)
local DrawTextCoord = GetDistanceBetweenCoords(PlayerCoords, Config.SecondTreeSecondDraw.x, Config.SecondTreeSecondDraw.y, Config.SecondTreeSecondDraw.z, true)
if TE2 == 0 and SecondTreeDrawCoords < 2 and MissionStarted then
sleep = 3
DrawText3D('0%', vector3(Config.SecondTreeDrawCoords.x, Config.SecondTreeDrawCoords.y, Config.SecondTreeDrawCoords.z + 0.2))
elseif TE2 == 1 and SecondTreeDrawCoords < 2 and MissionStarted then
sleep = 3
DrawText3D('25%', vector3(Config.SecondTreeDrawCoords.x, Config.SecondTreeDrawCoords.y, Config.SecondTreeDrawCoords.z + 0.2))
elseif TE2 == 2 and SecondTreeDrawCoords < 2 and MissionStarted then
sleep = 3
DrawText3D('50%', vector3(Config.SecondTreeDrawCoords.x, Config.SecondTreeDrawCoords.y, Config.SecondTreeDrawCoords.z + 0.2))
elseif TE2 == 3 and SecondTreeDrawCoords < 2 and MissionStarted then
sleep = 3
DrawText3D('75%', vector3(Config.SecondTreeDrawCoords.x, Config.SecondTreeDrawCoords.y, Config.SecondTreeDrawCoords.z + 0.2))
elseif DrawTextCoord < 5 and ProcessUnderSecondPart and not DrawOn then
sleep = 3
DrawText3D('~INPUT_PICKUP~ - 切割', vector3(Config.SecondTreeSecondDraw.x, Config.SecondTreeSecondDraw.y, Config.SecondTreeSecondDraw.z + 0.2))
elseif DrawTextCoord < 5 and ProcessUnderSecondPart and DrawOn and not Draw1 then
sleep = 3
DrawText3D(DrawTextNum.. '%', vector3(Config.SecondTreeSecondDraw.x, Config.SecondTreeSecondDraw.y, Config.SecondTreeSecondDraw.z + 0.2))
end
if SecondTreeDrawCoords < 5 and IsControlJustReleased(1, 346) and not UnderCutting then
if AxeOnHand then
playAnim("amb@world_human_hammering@male@base", "base", 3000)
TaskPlayAnim(Player, "amb@world_human_hammering@male@base", "base", 1.0, -1.0, 1000, 49, 1, false, false, false)
Citizen.Wait(3000)
ClearPedTasksImmediately(Player)
TE2 = TE2 + 1
end
if TE2 == 4 then
TreeHitFinished2 = true
UnderCutting = true
end
end
if ProcessUnderSecondPart then
if DrawTextCoord < 5 then
if IsControlJustReleased(0, 38) then
if AxeOnHand then
DrawOn = true
playAnim("mini@repair", "fixing_a_ped", 50000)
end
end
end
end
local SecondTreeDrawCoords = GetDistanceBetweenCoords(PlayerCoords, Config.ThirdTreeDrawCoords.x, Config.ThirdTreeDrawCoords.y, Config.ThirdTreeDrawCoords.z, true)
local DrawTextCoord = GetDistanceBetweenCoords(PlayerCoords, Config.ThirdTreeSecondDraw.x, Config.ThirdTreeSecondDraw.y, Config.ThirdTreeSecondDraw.z, true)
if TE3 == 0 and SecondTreeDrawCoords < 2 and MissionStarted then
sleep = 3
DrawText3D('0%', vector3(Config.ThirdTreeDrawCoords.x, Config.ThirdTreeDrawCoords.y, Config.ThirdTreeDrawCoords.z + 0.2))
elseif TE3 == 1 and SecondTreeDrawCoords < 2 and MissionStarted then
sleep = 3
DrawText3D('25%', vector3(Config.ThirdTreeDrawCoords.x, Config.ThirdTreeDrawCoords.y, Config.ThirdTreeDrawCoords.z + 0.2))
elseif TE3 == 2 and SecondTreeDrawCoords < 2 and MissionStarted then
sleep = 3
DrawText3D('50%', vector3(Config.ThirdTreeDrawCoords.x, Config.ThirdTreeDrawCoords.y, Config.ThirdTreeDrawCoords.z + 0.2))
elseif TE3 == 3 and SecondTreeDrawCoords < 2 and MissionStarted then
sleep = 3
DrawText3D('75%', vector3(Config.ThirdTreeDrawCoords.x, Config.ThirdTreeDrawCoords.y, Config.ThirdTreeDrawCoords.z + 0.2))
elseif DrawTextCoord < 5 and ProcessUnderSecondPart and not DrawOn then
sleep = 3
DrawText3D('~INPUT_PICKUP~ - Cutt', vector3(Config.ThirdTreeSecondDraw.x, Config.ThirdTreeSecondDraw.y, Config.ThirdTreeSecondDraw.z + 0.2))
elseif DrawTextCoord < 5 and ProcessUnderSecondPart and DrawOn and not Draw1 then
sleep = 3
DrawText3D(DrawTextNum.. '%', vector3(Config.ThirdTreeSecondDraw.x, Config.ThirdTreeSecondDraw.y, Config.ThirdTreeSecondDraw.z + 0.2))
end
if SecondTreeDrawCoords < 5 and IsControlJustReleased(1, 346) and not UnderCutting then
if AxeOnHand then
playAnim("amb@world_human_hammering@male@base", "base", 3000)
TaskPlayAnim(Player, "amb@world_human_hammering@male@base", "base", 1.0, -1.0, 1000, 49, 1, false, false, false)
Citizen.Wait(3000)
ClearPedTasksImmediately(Player)
TE3 = TE3 + 1
end
if TE3 == 4 then
TreeHitFinished3 = true
UnderCutting = true
end
end
if ProcessUnderSecondPart then
if DrawTextCoord < 5 then
if IsControlJustReleased(0, 38) then
if AxeOnHand then
DrawOn = true
playAnim("mini@repair", "fixing_a_ped", 50000)
end
end
end
end
local SecondTreeDrawCoords = GetDistanceBetweenCoords(PlayerCoords, Config.FourthTreeDrawCoords.x, Config.FourthTreeDrawCoords.y, Config.FourthTreeDrawCoords.z, true)
local DrawTextCoord = GetDistanceBetweenCoords(PlayerCoords, Config.FourthTreeSecondDraw.x, Config.FourthTreeSecondDraw.y, Config.FourthTreeSecondDraw.z, true)
if TE4 == 0 and SecondTreeDrawCoords < 2 and MissionStarted then
sleep = 3
DrawText3D('0%', vector3(Config.FourthTreeDrawCoords.x, Config.FourthTreeDrawCoords.y, Config.FourthTreeDrawCoords.z + 0.2))
elseif TE4 == 1 and SecondTreeDrawCoords < 2 and MissionStarted then
sleep = 3
DrawText3D('25%', vector3(Config.FourthTreeDrawCoords.x, Config.FourthTreeDrawCoords.y, Config.FourthTreeDrawCoords.z + 0.2))
elseif TE4 == 2 and SecondTreeDrawCoords < 2 and MissionStarted then
sleep = 3
DrawText3D('50%', vector3(Config.FourthTreeDrawCoords.x, Config.FourthTreeDrawCoords.y, Config.FourthTreeDrawCoords.z + 0.2))
elseif TE4 == 3 and SecondTreeDrawCoords < 2 and MissionStarted then
sleep = 3
DrawText3D('75%', vector3(Config.FourthTreeDrawCoords.x, Config.FourthTreeDrawCoords.y, Config.FourthTreeDrawCoords.z + 0.2))
elseif DrawTextCoord < 5 and ProcessUnderSecondPart and not DrawOn then
sleep = 3
DrawText3D('~INPUT_PICKUP~ - 切割', vector3(Config.FourthTreeSecondDraw.x, Config.FourthTreeSecondDraw.y, Config.FourthTreeSecondDraw.z + 0.2))
elseif DrawTextCoord < 5 and ProcessUnderSecondPart and DrawOn and not Draw1 then
sleep = 3
DrawText3D(DrawTextNum.. '%', vector3(Config.FourthTreeSecondDraw.x, Config.FourthTreeSecondDraw.y, Config.FourthTreeSecondDraw.z + 0.2))
end
if SecondTreeDrawCoords < 5 and IsControlJustReleased(1, 346) and not UnderCutting then
if AxeOnHand then
playAnim("amb@world_human_hammering@male@base", "base", 3000)
TaskPlayAnim(Player, "amb@world_human_hammering@male@base", "base", 1.0, -1.0, 1000, 49, 1, false, false, false)
Citizen.Wait(3000)
ClearPedTasksImmediately(Player)
TE4 = TE4 + 1
end
if TE4 == 4 then
TreeHitFinished4 = true
UnderCutting = true
end
end
if ProcessUnderSecondPart then
if DrawTextCoord < 5 then
if IsControlJustReleased(0, 38) then
if AxeOnHand then
DrawOn = true
playAnim("mini@repair", "fixing_a_ped", 50000)
end
end
end
end
Citizen.Wait(sleep)
end
end)
Citizen.CreateThread(function ()
while true do
Citizen.Wait(100)
local Player = PlayerPedId()
local PlayerCoords = GetEntityCoords(Player)
if DrawOn and not BreakShit2 then
DrawTextNum = DrawTextNum + 1
end
if DrawTextNum == 100 and not BreakShit2 then
Draw1 = true
ClearPedTasksImmediately(Player)
AddPropToPlayer = CreateObject(GetHashKey(Config.ModelForLastFart),PlayerCoords.x, PlayerCoords.y,PlayerCoords.z, true, true, true)
AttachEntityToEntity(AddPropToPlayer, Player, GetPedBoneIndex(PlayerPedId(),28422), 0.0, -0.03, 0.0, 5.0, 0.0, 0.0, 1, 1, 0, 1, 0, 1)
playAnim("anim@heists@box_carry@")
if not IsEntityPlayingAnim(PlayerPedId(), "anim@heists@box_carry@", "idle", 3) then
TaskPlayAnim(PlayerPedId(), "anim@heists@box_carry@", "idle", 8.0, 8.0, -1, 50, 0, false, false, false)
end
HaveBox = true
AxeOnHand = false
DeleteObject(GiveAxeToHand)
BreakShit2 = true
end
end
end)
Citizen.CreateThread(function()
while true do
Citizen.Wait(15)
if TreeHitFinished and not BreakShit then
SetEntityRotation(Tree1, GetEntityRotation(Tree1).x, GetEntityRotation(Tree1).y+0.3, GetEntityRotation(Tree1).z)
if GetEntityRotation(Tree1).y == 90.0 then
ProcessUnderSecondPart = true
BreakShit = true
end
elseif TreeHitFinished2 and not BreakShit then
SetEntityRotation(Tree2, GetEntityRotation(Tree2).x, GetEntityRotation(Tree2).y-0.3, GetEntityRotation(Tree2).z)
if GetEntityRotation(Tree2).y == -90.0 then
ProcessUnderSecondPart = true
BreakShit = true
end
elseif TreeHitFinished3 and not BreakShit then
SetEntityRotation(Tree3, GetEntityRotation(Tree3).x, GetEntityRotation(Tree3).y+0.3, GetEntityRotation(Tree3).z)
if GetEntityRotation(Tree3).y == 90.0 then
ProcessUnderSecondPart = true
BreakShit = true
end
elseif TreeHitFinished4 and not BreakShit then
SetEntityRotation(Tree4, GetEntityRotation(Tree4).x, GetEntityRotation(Tree4).y+0.3, GetEntityRotation(Tree4).z)
if GetEntityRotation(Tree4).y == 90.0 then
ProcessUnderSecondPart = true
BreakShit = true
end
end
end
end)
Citizen.CreateThread(function()
while true do
local sleep = 2000
local Player = PlayerPedId()
local PlayerCoords = GetEntityCoords(Player)
local Distance = GetDistanceBetweenCoords(PlayerCoords, Config.FirstTreeCoords.x, Config.FirstTreeCoords.y, Config.FirstTreeCoords.z, true)
if Distance < 40 then
sleep = 3
if MissionStarted then
if AxeOnHand == false then
if IsControlJustReleased(0, 44) then
GiveAxeToHand = CreateObject(GetHashKey("prop_ld_fireaxe"), 0, 0, 0, true, true, true)
AttachEntityToEntity(GiveAxeToHand, PlayerPedId(), GetPedBoneIndex(PlayerPedId(), 57005), 0.09, 0.03, -0.02, -78.0, 180.0, 28.0, false, false, false, false, 1, true)
SetCurrentPedWeapon(PlayerPedId(), GetHashKey('WEAPON_UNARMED'))
AxeOnHand = true
TriggerEvent('oph3z-lumberjack:DontHitWhileAxeOnHand')
end
elseif AxeOnHand == true then
if IsControlJustReleased(0, 44) then
AxeOnHand = false
DetachEntity(GiveAxeToHand, 1, true)
DeleteEntity(GiveAxeToHand)
DeleteObject(GiveAxeToHand)
SetCurrentPedWeapon(PlayerPedId(), GetHashKey('WEAPON_UNARMED'))
TriggerEvent('oph3z-lumberjack:DontHitWhileAxeOnHand')
end
end
end
end
Citizen.Wait(sleep)
end
end)
Citizen.CreateThread(function()
while true do
local sleep = 2000
local Player = PlayerPedId()
local PlayerCoords = GetEntityCoords(Player)
local Distance = GetDistanceBetweenCoords(PlayerCoords, Config.SellCoords.x, Config.SellCoords.y, Config.SellCoords.z, true)
if Distance < 5 and HaveBox then
sleep = 3
DrawText3D('~INPUT_PICKUP~ - 卖树', vector3(Config.SellCoords.x, Config.SellCoords.y, Config.SellCoords.z + 0.2))
if IsControlJustReleased(0, 38) then
RequestAnimDict("pickup_object")
while not HasAnimDictLoaded("pickup_object") do
Citizen.Wait(7)
end
TaskPlayAnim(PlayerPedId(), "pickup_object" ,"pickup_low" ,8.0, -8.0, -1, 1, 0, false, false, false )
Citizen.Wait(2000)
TriggerServerEvent('oph3z-lumberjack:AddMoney')
Notification('你得到了: ' ..Config.WoodPrice.. '$')
ClearPedTasks(PlayerPedId())
DeleteObject(AddPropToPlayer)
DeleteObject(GiveAxeToHand)
HaveBox = false
DrawOn = false
DrawTextNum = 0
TE = 0
TE2 = 0
TE3 = 0
TE4 = 0
UnderCutting = false
TreeHitFinished = false
TreeHitFinished2 = false
TreeHitFinished3 = false
TreeHitFinished4 = false
ProcessUnderSecondPart = false
Draw1 = false
BreakShit = false
BreakShit2 = false
DeleteObject(Tree1)
DeleteObject(Tree2)
DeleteObject(Tree3)
DeleteObject(Tree4)
Citizen.Wait(1000)
CreateTree1()
CreateTree2()
CreateTree3()
CreateTree4()
end
end
Citizen.Wait(sleep)
end
end)
Citizen.CreateThread(function()
while true do
local sleep = 2000
local Player = PlayerPedId()
local PlayerCoords = GetEntityCoords(Player)
local GetVehicleCoords = GetEntityCoords(Vehicle)
local VehicleAndPlayerCoords = GetDistanceBetweenCoords(PlayerCoords, GetVehicleCoords.x, GetVehicleCoords.y, GetVehicleCoords.z, true)
local PartsCoords = GetWorldPositionOfEntityBone(Vehicle, GetEntityBoneIndexByName(Vehicle, "boot"))
local SellCoords = GetDistanceBetweenCoords(PlayerCoords, Config.SellCoords.x, Config.SellCoords.y, Config.SellCoords.z, true)
if VehicleAndPlayerCoords < 10 and HaveBox and not IsPedInAnyVehicle(Player, false) then
sleep = 3
DrawMarker(2, PartsCoords.x, PartsCoords.y, PartsCoords.z+0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.3, 0.3, 0.3, 255, 255, 255, 255, 0, 0, 0, 1, 0, 0, 0)
if VehicleAndPlayerCoords < 5 and HaveBox and not IsPedInAnyVehicle(Player, false) and not BoxInVehicle then
sleep = 3
DrawText3D('~INPUT_PICKUP~ - 将树木放入车内', vector3(PartsCoords.x, PartsCoords.y, PartsCoords.z+0.5 + 0.2))
if IsControlJustReleased(0, 38) and HaveBox and not BoxInVehicle then
AddWoodsInTheVehicle = CreateObject(GetHashKey(Config.ModelForLastFart), PartsCoords.x, PartsCoords.y+1.5, PartsCoords.z+5.8, true, true, true)
AttachEntityToEntity(AddWoodsInTheVehicle, Vehicle, GetEntityBoneIndexByName(Vehicle, "boot"), 0.0, 0.5, 0.10, 255.0, -15.0, -1.0, false, false, false, false, 2, true)
DeleteObject(AddPropToPlayer)
BoxInVehicle = true
HaveBox = false
ClearPedTasksImmediately(Player)
SetNewWaypoint(-839.74, 5402.85)
end
end
end
if VehicleAndPlayerCoords < 5 and SellCoords > 20 and not IsPedInAnyVehicle(Player, false) and BoxInVehicle then
sleep = 3
DrawText3D('后备箱已满,先卖掉', vector3(PartsCoords.x, PartsCoords.y, PartsCoords.z+0.5 + 0.5))
elseif SellCoords < 20 and VehicleAndPlayerCoords < 5 and not IsPedInAnyVehicle(Player, false) and BoxInVehicle then
sleep = 3
DrawText3D('~INPUT_PICKUP~ - 拿树', vector3(PartsCoords.x, PartsCoords.y, PartsCoords.z+0.5 + 0.5))
if IsControlJustReleased(0, 38) then
--AddPropToPlayer = CreateObject(GetHashKey(Config.ModelForLastFart),PlayerCoords.x, PlayerCoords.y,PlayerCoords.z, true, true, true)
--AttachEntityToEntity(AddPropToPlayer, Player, GetPedBoneIndex(Player, 60309), 0.13, 0.0, -0.16, 250.0, -40.0, 0.0, false, true, false, false, 2, true)
AddPropToPlayer = CreateObject(GetHashKey(Config.ModelForLastFart),PlayerCoords.x, PlayerCoords.y,PlayerCoords.z, true, true, true)
AttachEntityToEntity(AddPropToPlayer, Player, GetPedBoneIndex(PlayerPedId(),28422), 0.0, -0.03, 0.0, 5.0, 0.0, 0.0, 1, 1, 0, 1, 0, 1)
playAnim("anim@heists@box_carry@")
if not IsEntityPlayingAnim(PlayerPedId(), "anim@heists@box_carry@", "idle", 3) then
TaskPlayAnim(PlayerPedId(), "anim@heists@box_carry@", "idle", 8.0, 8.0, -1, 50, 0, false, false, false)
end
HaveBox = true
AxeOnHand = false
DeleteObject(AddWoodsInTheVehicle)
BoxInVehicle = false
end
end
Citizen.Wait(sleep)
end
end)
RegisterNetEvent('oph3z-lumberjack:DontHitWhileAxeOnHand') -- Disables left click while holding a axe
AddEventHandler('oph3z-lumberjack:DontHitWhileAxeOnHand', function()
Citizen.CreateThread(function()
while AxeOnHand do
Citizen.Wait(0)
DisablePlayerFiring(PlayerPedId(), true)
end
end)
end)
RegisterNetEvent('oph3z-lumberjack:CreateVehicle')
AddEventHandler('oph3z-lumberjack:CreateVehicle', function()
if Vehicle == nil then
local modelHash = GetHashKey(Config.CarModel)
RequestModel(modelHash)
local isLoaded = HasModelLoaded(modelHash)
while isLoaded == false do
Citizen.Wait(50)
end
Vehicle = CreateVehicle(modelHash, Config.CarSpawnCoords, 68.84, 1, 0) -- 68.84 = heading
plate = GetVehicleNumberPlateText(Vehicle)
SetVehicleFuelLevel(Vehicle, 100.0)
Notification('您的车辆已创建!')
else
Notification('您已经有一辆车!')
end
end)
function CreateTree1()
Citizen.CreateThread(function()
RequestModel(Config.TreeModel)
while not HasModelLoaded(Config.TreeModel) do
Citizen.Wait(2000)
end
if not HasModelLoaded(Config.TreeModel) then
SetModelAsNoLongerNeeded(Config.TreeModel)
elseif not DoesEntityExist(Tree1) then
Tree1 = CreateObject(Config.TreeModel, Config.FirstTreeCoords.x, Config.FirstTreeCoords.y, Config.FirstTreeCoords.z, true, false, 1)
FreezeEntityPosition(Tree1, true)
end
end)
end
function CreateTree2()
Citizen.CreateThread(function()
RequestModel(Config.TreeModel)
while not HasModelLoaded(Config.TreeModel) do
Citizen.Wait(2000)
end
if not HasModelLoaded(Config.TreeModel) then
SetModelAsNoLongerNeeded(Config.TreeModel)
elseif not DoesEntityExist(Tree2) then
Tree2 = CreateObject(Config.TreeModel, Config.SecondTreeCoords.x, Config.SecondTreeCoords.y, Config.SecondTreeCoords.z, true, false, 1)
FreezeEntityPosition(Tree2, true)
end
end)
end
function CreateTree3()
Citizen.CreateThread(function()
RequestModel(Config.TreeModel)
while not HasModelLoaded(Config.TreeModel) do
Citizen.Wait(2000)
end
if not HasModelLoaded(Config.TreeModel) then
SetModelAsNoLongerNeeded(Config.TreeModel)
elseif not DoesEntityExist(Tree3) then
Tree3 = CreateObject(Config.TreeModel, Config.ThirdTreeCoords.x, Config.ThirdTreeCoords.y, Config.ThirdTreeCoords.z, true, false, 1)
FreezeEntityPosition(Tree3, true)
end
end)
end
function CreateTree4()
Citizen.CreateThread(function()
RequestModel(Config.TreeModel)
while not HasModelLoaded(Config.TreeModel) do
Citizen.Wait(2000)
end
if not HasModelLoaded(Config.TreeModel) then
SetModelAsNoLongerNeeded(Config.TreeModel)
elseif not DoesEntityExist(Tree4) then
Tree4 = CreateObject(Config.TreeModel, Config.FourthTreeCoords.x, Config.FourthTreeCoords.y, Config.FourthTreeCoords.z, true, false, 1)
FreezeEntityPosition(Tree4, true)
end
end)
end
更新为esx legacy最新版
这段代码是用Lua语言编写的,主要用于Citizen.CreateThread创建线程,用于在FiveM中实现特定的游戏功能,比如NPC生成、地图标记功能和物品交互等。这是服务器端脚本,因为它包含了对游戏世界的改变、玩家的操作进行监听等功能。
其中包括了模型的加载、创建Ped角色、添加地图标记、玩家之间的互动等操作,代码中还涉及到特定动作的执行、文字信息的展示、动画的播放以及物体的创建与绑定等操作。
由于代码较长,建议你逐段阅读并结合实际项目需求进行分析和修改。同时关于这些代码的细节操作和具体实现,还需要根据实际情况进行调试和修改。
页:
[1]