Greetings,
Saw someone selling similar script and it got me triggered so… here I am, releasing this within 24h mark as promised.
What is this?
- This is a simple script allowing you as server owner to give your players something “fun” to do for some rewards.
- Basically you place xmas tree props in your server (via config) and let your players claim rewards from them once each restart / script restart.
Features
-
Draw3DText, even more simple if you want to utilize target system. Up 2 u in that case
-
Unlimited locations & rewards
-
Optional reward-logging (You must setup it yourself, it’s implemented on the server file but commented out)
-
Includes default loot table and raredrop table with random chance ( supports items, money and weapons by default )
-
Player can claim each tree only once
-
Config option to limit the amount of gifts trees can hold ( default 10 gifts/claims each tree )
-
Config option to enable/disable blips if you want people to hunt for these trees
-
Currently uses steam name to check if player has already claimed tree, maybe change to something like xPlayer.identifier instead? Up 2 you
-
Trees reset each server restart
-
Randomized drops for players, on both default and rare drop tables.
-
Handles the prop spawning, all you have to do yourself is setup the locations and loot tables
-
Also included some admin command snippets for clearing props / vehicles / peds. Has nothing to do with the script itself but just something I might aswell share should someone need it
-
Easy to modify for your needs. Loot table structure supports multiple drops etc.
Config example
Config = {}
--Every player can only claim one gift each tree
Config.maxGifts = 10 --Max gift amount each tree, put ridiculous amount if you want no restriction.
--Enable or disable blips for trees
Config.EnableBlips = true
Config.BlipName = 'Christmas Presents'
--Setup as many trees as you want
Config.Trees = {
{pos = vector3(242.05, -879.18, 30.49)},
{pos = vector3(233.09, -875.96, 30.49)},
}
--Setup your default loots
Config.LootTable = {
[1] = {
{itemtype = 'item', item = 'bread', amount = 1},
},
[2] = {
{itemtype = 'money', item = 'money', amount = math.random(1,100)},
},
[3] = {
{itemtype = 'weapon', item = 'WEAPON_PISTOL', amount = 1},
}, --Amount is for ammo when itemtype == weapon
}
--Setup your rare loots
--Check serverside math.randoms and edit to your likings, i defaulted it to 20% chance. Basic maths
Config.RareLootTable = {
[1] = {
{itemtype = 'item', item = 'bread', amount = 1},
},
[2] = {
{itemtype = 'money', item = 'money', amount = math.random(1,100)},
},
[3] = {
{itemtype = 'weapon', item = 'WEAPON_PISTOL', amount = 1},
}, --Amount is for ammo when itemtype == weapon
}
Requirements
- ESX
- Some common sense / basic lua coding skills
Misc
-
No support is given, script is in itself simple and it has been well commented. If errors come up they are most likely something very simple to change (xPlayer natives etc) and you should be capable of yourself to fix those issues
-
Script has not been tested on live environment as of now, so problems may occur regarding prop spawn. I doubt since they are not networked entities and should only spawn locally upon playerload.
Anyways, happy holidays and hopefully ya’ll enjoy this bit.
QBCore version is not tested at all and most likely will not function properly. Good luck.
- Does not have notifications so implement them by yourself
- AddItem functions probably are wrong too. Should be fairly easy to fix for someone who is even a little familiar with QBCore. Doesn’t really use that much framework specific functions.
Hotfix for ESX
Paste this into es_extended/client/functions
You might have to rename this function, because most likely you have this function already in your functions.lua
ESX.Game.GetClosestObject = function(filter, coords)
local objects = ESX.Game.GetObjects()
local closestDistance, closestObject = -1, -1
local filter, coords = filter, coords
if type(filter) == 'string' then
if filter ~= '' then
filter = {filter}
end
end
if coords then
coords = vector3(coords.x, coords.y, coords.z)
else
local playerPed = PlayerPedId()
coords = GetEntityCoords(playerPed)
end
for i=1, #objects, 1 do
local foundObject = false
if filter == nil or (type(filter) == 'table' and #filter == 0) then
foundObject = true
else
local objectModel = GetEntityModel(objects[i])
for j=1, #filter, 1 do
if objectModel == GetHashKey(filter[j]) then
foundObject = true
break
end
end
end
if foundObject then
local objectCoords = GetEntityCoords(objects[i])
local distance = #(objectCoords - coords)
if closestDistance == -1 or closestDistance > distance then
closestObject = objects[i]
closestDistance = distance
end
end
end
return closestObject, closestDistance
end