# Installation

* Put the plt\_lumberjack & plt\_lumberjack-streams files in your resource file. Add them to your server.cfg.
* Check the config.lua. and configure to script settings how you want.
* If you are using ESX or  QB-Core frameworks; you don't have to make any changes. it is ready to work. Otherwise check [#Framework money & job functions](#framework-money-and-job-functions)
* The script has no requirements. ui and notifications itself. if you want you can use other notification system. check [#Notifications system](#notifications-system)
* If you want to do something when vehicle spawns, like giving a key to the player, changing the fuel of the vehicle or something [#Arrangement about spawned vehicles](#arrangement-about-spawned-vehicles)
* You should set the outfit values according to your own server [#Clothing System](#clothing-system). The clothes changing system can work standalone. If you want, you can use the qb-clothing or esx\_skin system.
* [#Add new tree](#add-new-tree)
* [#Add new construction](#add-new-construction)

## Framework money & job functions

{% tabs %}
{% tab title="ESX & QB-Core" %}
{% hint style="info" %}
If you are use ESX & QB-Core  frameworks you don't need to change or add anything, they already been added.
{% endhint %}

{% code title="server/server.lua" %}

```lua
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
if ESX then 
    function PltAddMoney(src,money)
        ...
    end
else
    QBCore = exports['qb-core']:GetCoreObject()
    function PltAddMoney(src,money)
        ...
    end
end
```

{% endcode %}

{% code title="client/jobs.lua" %}

```lua
RegisterNetEvent('esx:playerLoaded')
AddEventHandler('esx:playerLoaded', function(PlayerData)
	JobUpdate(PlayerData.job.name,PlayerData.job.grade)
end)
RegisterNetEvent('esx:setJob')
AddEventHandler('esx:setJob', function(job)
	JobUpdate(job.name,job.grade)
end)
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
	local QBCore = exports['qb-core']:GetCoreObject()
	while QBCore.Functions.GetPlayerData().job == nil do Citizen.Wait(1000) end
	local PlayerData = QBCore.Functions.GetPlayerData()
	JobUpdate(PlayerData.job.name,PlayerData.job.grade.level)
end)
RegisterNetEvent('QBCore:Client:OnJobUpdate')
AddEventHandler('QBCore:Client:OnJobUpdate', function(JobInfo)
	JobUpdate(JobInfo.name,JobInfo.grade.level)
end)
```

{% endcode %}
{% endtab %}

{% tab title="vRP 0.5" %}
{% hint style="info" %}
Delete the ESX and QB-Core function before,&#x20;

I added the necessary codes, but they are comment lines, activate the codes.
{% endhint %}

{% code title="fxmanifest.lua" %}

```lua
server_scripts {
	'@vrp/lib/utils.lua',
	...
}
```

{% endcode %}

{% code title="server/server.lua" %}

```lua
local Tunnel = module("vrp", "lib/Tunnel")
local Proxy = module("vrp", "lib/Proxy")
vRP = Proxy.getInterface("vRP")
function PltAddMoney(src,money)
    local user_id = vRP.getUserId(src)
    vRP.giveBankMoney(user_id,money)
end
AddEventHandler("vRP:playerSpawn",function(user_id, source, first_spawn)
  if first_spawn then
    local job = vRP.getUserGroupByType({user_id,"job"})
    TriggerClientEvent('plt_lumberjack:JobUpdate',user_id,job,false)
  end
end)
AddEventHandler("vRP:playerJoinGroup", function(user_id, group, gtype)
  if gtype == "job" then 
    TriggerClientEvent('plt_lumberjack:JobUpdate',user_id,jobName,false)
  end
end)
```

{% endcode %}
{% endtab %}

{% tab title="Other frameworks" %}
{% hint style="info" %}
Delete the ESX and QB-Core function before, add the following function to give money in your own framework.
{% endhint %}

{% code title="server/server.lua" %}

```lua
function PltAddMoney(src,money)
   -- add "money" amount of money to the player whose id is "src", for example;
   -- local xPlayer = ESX.GetPlayerFromId(src)
   -- xPlayer.addMoney(money)
end
```

{% endcode %}

{% hint style="info" %}
Job information should be updated when the player loaded and player's profession is updated, as in the example following
{% endhint %}

{% code title="from any where" %}

```lua
--following is when will trigger from CLIENT side.
TriggerEvent('plt_lumberjack:JobUpdate',jobName,jobGrade)
--following is when will trigger from Server side.
TriggerServerEvent('plt_lumberjack:JobUpdate',source,jobName,jobGrade)
```

{% endcode %}

{% hint style="info" %}
I added the event that will be triggered, you don't need to do anything about it.
{% endhint %}

{% code title="client/jobs.lua" %}

```lua
RegisterNetEvent('plt_lumberjack:JobUpdate')
AddEventHandler('plt_lumberjack:JobUpdate', function(jobName,jobGrade)
	JobUpdate(jobName,jobGrade)
end)
```

{% endcode %}
{% endtab %}
{% endtabs %}

## Clothing System

{% code title="client/clothing.lua" %}

```lua
---- Adjust the 'PLT.Clothing' table following according to the job clothes on your server.
PLT.Clothing={
	male ={
	--[[ Arms ]]		['arms'] = 67,							
	--[[ Tshirt ]] 		['tshirt_1'] = 85, 	 ['tshirt_2'] = 0,
	--[[ Torso Parts ]]	['torso_1'] = 177, 	 ['torso_2'] = 11,
	..
	},
	female={..}
}
function ChangeOutfit()
	ChangeOutfitStandalone()-- if you want to use the esx_skin or qb-clothing system; Deactivate the this function then Activate the following which you want.
	--ChangeOutfitEsx()		-- if you want to use the esx_skin system; Deactivate the ChangeOutfitStandalone() function then Activate the this function.
	--ChangeOutfitQB()		-- if you want to use the qb-clothing system; Deactivate the ChangeOutfitStandalone() function then Activate the this function.
	TriggerEvent("plt_lumberjack:ClotheChangeAnim")
end
```

{% endcode %}

## Notifications system

{% tabs %}
{% tab title="Notification System" %}
{% code title="client/other.lua" %}

```lua
function Notification(type, message, time)
	SendNUIMessage({statu="single", type = type, text = message, duration = time}) 
	--exports['mythic_ notify']:DoCustomHudText(type, message, time)
	--exports['okokNotify']:Alert("Lumberjack", message, time, type)
	--TriggerEvent('okokNotify:Alert', "Lumberjack", message, time, type)
	--TriggerEvent('QBCore:Notify', message, type, time)
end
```

{% endcode %}
{% endtab %}

{% tab title="Permenant Notification System" %}
{% code title="client/other.lua" %}

```lua
function permenantNotification(msg, thisFrame, beep, duration)
	permenantNotificationText = msg 
	--[[ 	AddTextEntry('pltLumberjackNotify', msg)
	if thisFrame then
		DisplayHelpTextThisFrame('pltLumberjackNotify', false)
	else
		if beep == nil then beep = true end
		BeginTextCommandDisplayHelp('pltLumberjackNotify')
		EndTextCommandDisplayHelp(0, false, beep, duration or -1)
	end ]]
end
```

{% endcode %}
{% endtab %}
{% endtabs %}

## Arrangement about spawned vehicles

{% code title="client/other.lua" %}

```lua
function SpawnedVehicle(vehicle, needGiveKey, vehicleModelName)
	if needGiveKey then 
		TriggerEvent("vehiclekeys:client:SetOwner", string.gsub(GetVehicleNumberPlateText(vehicle), '^%s*(.-)%s*$', '%1'))
		TriggerServerEvent('garage:addKeys', GetVehicleNumberPlateText(vehicle))
		TriggerServerEvent("plateEveryone",GetVehicleNumberPlateText(vehicle))
		if vehicleModelName == PLT.Vehicles.forklift or vehicleModelName ==  PLT.Vehicles.telehandler then 
			SetVehicleFuelLevel(vehicle, 99.9) DecorSetFloat(vehicle, "_FUEL_LEVEL", GetVehicleFuelLevel(vehicle))
		else -- here for trucks
			SetVehicleFuelLevel(vehicle, 99.9) DecorSetFloat(vehicle, "_FUEL_LEVEL", GetVehicleFuelLevel(vehicle))
		end
		--next line vehicle max car mod
		--SetVehicleMod(vehicle, 11, (GetNumVehicleMods(vehicle, tonumber(modType)) - 1), false) SetVehicleMod(vehicle, 12, (GetNumVehicleMods(vehicle, tonumber(modType)) - 1), false) SetVehicleMod(vehicle, 13, (GetNumVehicleMods(vehicle, tonumber(modType)) - 1), false) SetVehicleMod(vehicle, 15, (GetNumVehicleMods(vehicle, tonumber(modType)) - 1), false) SetVehicleMod(vehicle, 16, (GetNumVehicleMods(vehicle, tonumber(modType)) - 1), false) ToggleVehicleMod(vehicle, 18, true)
	end
end
```

{% endcode %}

## Add new tree

{% embed url="<https://www.youtube.com/watch?v=2bYtFq-_d7c>" %}

## Add new construction

{% embed url="<https://www.youtube.com/watch?v=ItyxxiygLlI>" %}
