Wert New Year Lottery
You can access the setup information you need about this product
Last updated
You can access the setup information you need about this product
Last updated
1 - Upload the script folder to the location of your resources
2 - Check config and editable file settings. If you are using different systems, you can make the necessary adjustments in these files, such as for , ox_lib
, etc.
3 - Load newyearlotteryticket.sql file in ur database.
4 - Load item settings in ur item list
5 - Installation successful, have a good funs
There are many ox settings available in the files, if you want, you can configure them.
The script comes with default settings. There are many settings in the configuration file, and you can customize all of them to your personal preferences. Below are the configuration files, feel free to check them out.
If you are using the ox inventory and you have turned on the configure setting, please add these codes to the ox_inventory/modules/items/client location.
Item('newyearlotteryticket', function(data, slot)
TriggerEvent('wert-newyearlotteryticket:client:use-ticket-item', slot)
end)
['newyearlotteryticket'] = {
label = "New Year Lottery Ticket",
weight = 100,
stack = false,
},
Config = {}
Config.DebugPoly = false
Config.OxLib = true
Config.OxInventory = true
Config.UseTarget = true
Config.UseWertDialog = false -- # If u have wert dialog npc's use wert dialog system for interaction
Config.InteractionKey = 38 -- # (No target interaction key) https://docs.fivem.net/docs/game-references/controls/
Config.BigPrize = 1000000 -- # The money that the person who wins the lottery will receive
Config.WinPrizeAccount = 'bank' -- # Which account will the winnings be deposited into ?
Config.TicketItem = 'newyearlotteryticket'
Config.TicketPrice = 1000 -- # A Ticket price (Currently 1000$)
Config.PaymentMethod = 'cash' -- # 'cash' or 'bank' | If u want edit detailed codes in editable_server
-- # Decide how many tickets a player can buy
Config.PlayerTicketBuyControl = {
active = true, -- If u want disable this feature set false! | true or false | boolean
maxTicket = 10, -- A player can buy a maximum of 10 tickets! If u want set another value change this value! | number
}
-- # Use ticket animation and prop settings
Config.UseTicketProperties = {
active = true, -- Active animation and prop system | true or false | boolean
animDict = 'cellphone@',
animClip = 'cellphone_call_to_text',
flag = 50,
-- Prop (Note : If u dont want use prop set nil like model = nil)
model = `tr_prop_tr_swipe_card_01a`,
position = {x = 0.0, y = 0.0, z = 0.0},
rotation = {x = 50.0, y = 320.0, z = 50.0},
bone = 28422
}
-- # Locations where tickets can be purchased. If u want add more ticket seller like defaults ...
Config.SellPoints = {
{
model = `s_m_m_mariachi_01`,
dialogModel = "s_m_m_mariachi_01", -- If u open wert-dialog intergation setting above, u need set string version for model
coord = vector4(178.85, -976.31, 29.09, 146.08),
animation = {
-- TaskPlayAnim settings
dict = nil,
clip = nil,
flag = 1,
-- Scenario
scenario = nil, -- If u want scenario select value
},
distance = 1.5,
blip = {
active = true,
sprite = 781,
scale = 0.8,
color = 3,
label = 'New Year Lottery Ticket Seller',
},
},
{
model = `s_m_m_mariachi_01`,
dialogModel = "s_m_m_mariachi_01", -- If u open wert-dialog intergation setting above, u need set string version for model
coord = vector4(174.96, -973.12, 29.09, 138.34),
animation = {
-- TaskPlayAnim settings
dict = nil,
clip = nil,
flag = 1,
-- Scenario
scenario = nil, -- If u want scenario select value
},
distance = 1.5,
blip = {
active = true,
sprite = 781,
scale = 0.8,
color = 3,
label = 'New Year Lottery Ticket Seller',
},
},
}
-- # Npc buy ticket animation (The animation setting for the seller seller npc's when someone buys a ticket)
Config.SellerNpcAnimation = {
active = true, -- Active or deactive | true or false | boolean
-- TaskPlayAnim settings
dict = "mp_common",
clip = "givetake1_a",
flag = 33,
-- Scenario
scenario = nil, -- If u want scenario select value
}
-- # Buy ticket progressbar time
Config.BuyTicketProgressTime = 5000
-- # For the player buy ticket animation
Config.BuyTicketAnimation = {
active = true,
-- TaskPlayAnim settings
dict = "mp_common",
clip = "givetake1_a",
flag = 33,
-- Scenario
scenario = nil, -- If u want scenario select value
}
-- # Close Ticket Ui Key
Config.CloseTicketUI = {
key = 'BACK',
description = 'Close new year ticket ui',
removeSuggestion = 'chat:removeSuggestion', -- Ur chat event, this one default for fivem. If u change anything for this u can edit or if u don't want remove set nil
}
-- # Disable keys when ui open settings
Config.DisableKeys = {
-- When ticket ui open disable this keys until close ui
-- If u want add like this :
--[[ -- https://docs.fivem.net/docs/game-references/controls/
1,
2,
3,
]]
}
-- # Draw position and settings
Config.DrawSettings = {
-- Ped settings
pedCoord = vector4(226.24, -892.48, 29.69, 328.32),
pedModel = `cs_milton`,
-- Desk settings
deskCoord = vector4(226.79, -891.65, 29.69, 327.99),
deskModel = `h4_prop_office_desk_01`,
deskRotation = {x = 0.0, y = 0.0, z = -35.0},
-- Blip settings
blip = {
active = true,
coord = vector3(226.24, -892.48, 29.69),
sprite = 135,
scale = 1.0,
color = 3,
label = 'New Year Lottery Draw Area!'
},
-- Bag Settings
bags = {
{ -- 1. Bag
model = `p_sec_case_02_s`,
coord = vector4(225.80, -890.9, 30.5, 327.99),
rotation = {x = 0.0, y = 0.0, z = -35.0},
},
{ -- 2. Bag
model = `p_sec_case_02_s`,
coord = vector4(226.17, -891.17, 30.5, 327.99),
rotation = {x = 0.0, y = 0.0, z = -35.0},
},
{ -- 3. Bag
model = `p_sec_case_02_s`,
coord = vector4(226.57, -891.43, 30.5, 327.99),
rotation = {x = 0.0, y = 0.0, z = -35.0},
},
{ -- 4. Bag
model = `p_sec_case_02_s`,
coord = vector4(226.97, -891.72, 30.5, 327.99),
rotation = {x = 0.0, y = 0.0, z = -35.0},
},
{ -- 5. Bag
model = `p_sec_case_02_s`,
coord = vector4(227.36, -892.0, 30.5, 327.99),
rotation = {x = 0.0, y = 0.0, z = -35.0},
},
{ -- 6. Bag
model = `p_sec_case_02_s`,
coord = vector4(227.76, -892.27, 30.5, 327.99),
rotation = {x = 0.0, y = 0.0, z = -35.0},
},
},
-- Ball settings
mixingBallTime = 3000,
takeBallTime = 3000,
takeBallAnimation = {
dict = 'mini@repair',
clip = 'fixing_a_ped',
flag = 16
},
waitForNextBallTime = 3000,
ballNumberPositionFix = {
6,
5,
4,
3,
2,
1,
},
ballTextRenderDistance = 20.0,
pedTextRenderDistance = 20.0,
-- Firework settings
useFirework = true,
fireworkDict = 'proj_xmas_firework',
fireworkList = {
'scr_firework_xmas_ring_burst_rgw',
'scr_firework_xmas_burst_rgw',
'scr_firework_xmas_repeat_burst_rgw',
'scr_firework_xmas_spiral_burst_rgw',
'scr_xmas_firework_sparkle_spawn'
},
fireworkDelay = 1000,
fireworkPositions = {
vector3(228.81, -893.4, 30.69),
vector3(224.75, -889.84, 30.69),
},
fireworkHeight = 6.0, -- 42.5,
clearAfterFinishComponentsTime = 60000,
}
-- # Start draw command
Config.DrawCommand = {
active = true, -- true or false | boolean | Do u want active command ?
name = 'drawNewYearLottery', -- Command
description = 'Start the Christmas lottery!', -- Command description
group = 'god', -- Which permission can use command ?
}
-- # Timer for start draw
Config.DrawStartTimer = {
-- Should a countdown be started for the players after the draw command is used ?
active = true, -- true or false | boolean |
second = 60, -- Second value | number
sound = {
active = false, -- Should the sound play when the draw timer starts ?
file = './sounds/draw.mp3', -- Sound file extansion
volume = 0.3, -- Sound audio 0.0 ~ 1.0
}
}
-- # Set draw position waypoint
Config.SetDrawPositionWayPoint = true -- Mark the location on the gps automatically when the draw starts
-- # Send notification when the draw starts
Config.DrawStartNotification = true
-- # Reset draw and winner old datas
Config.ResetSystemCommand = {
active = true, -- true or false | boolean | Do u want active command ?
name = 'resetNewYearLotteryDatas', -- Command
description = 'Reset new year lottery ticket datas!', -- Command description
group = 'god', -- Which permission can use command ?
}
-- # Exchange ticket | Check if there is a prize belonging to your ticket and get your prize
Config.ExchangeTicket = {
{
model = `cs_bankman`,
dialogModel = "s_m_m_mariachi_01",
coord = vector4(247.59, 210.04, 105.29, 346.09),
animation = {
-- TaskPlayAnim settings
dict = nil,
clip = nil,
flag = 1,
-- Scenario
scenario = nil, -- If u want scenario select value
},
distance = 2.5,
blip = {
active = true,
sprite = 764,
scale = 0.8,
color = 3,
label = 'New Year Lottery Ticket Controller',
},
},
}
local ESX = exports["es_extended"]:getSharedObject()
-- # Functions
function CustomNotifVariation(text, style, time)
if Config.OxLib then
lib.notify({title = 'Notification', description = text, type = style})
else
ESX.ShowNotification(text, style or "info", time or 5000)
end
end
function AddSellerTarget(entity, data)
exports.ox_target:addLocalEntity(entity, data.options)
-- # If u want use qb-taret use this export!
-- exports["qb-target"]:AddTargetEntity(entity, data)
end
function ShowTextUI(text)
if Config.OxLib then
lib.showTextUI(text, {position = 'left-center'})
else
-- If u want use another text ui system edit here!
end
end
function HideTextUI()
if Config.OxLib then
lib.hideTextUI()
else
-- If u want use another text ui system edit here!
end
end
function CustomProgressbar(data, cb)
if Config.OxLib then
if lib.progressBar({
duration = data.time,
label = data.label,
useWhileDead = false,
canCancel = true,
disable = {
move = data.move,
combat = data.combat,
mouse = data.mouse,
car = data.car,
},
anim = data.anim,
prop = data.prop,
}) then
cb('true')
else
cb('false')
end
else
-- If u want use custom another progressbar edit here!
--[[ if data.anim then
data.anim.animDict = data.anim.dict
data.anim.anim = data.anim.clip
data.anim.flags = data.anim.flag
end
if data.prop then
data.prop.coords = data.prop.pos
data.prop.rotation = data.prop.rot
end
QBCore.Functions.Progressbar(data.id, data.label, data.time, false, true, {
disableMovement = data.move,
disableCarMovement = data.car,
disableMouse = data.mouse,
disableCombat = data.combat,
}, data.anim or {}, data.prop or {}, {}, function()
cb('true')
end, function()
cb('false')
end) ]]
end
end
function DrawStartNotification()
CustomNotifVariation(LANG.drawStartNotification, 'success', 5000)
end
-- # Events
RegisterNetEvent('wert-newyearlotteryticket:client:custom-notify', function(text, style, time)
CustomNotifVariation(text, style, time)
end)
local ESX = exports["es_extended"]:getSharedObject()
local BuyTicketWebhook = '' -- Discord webhook adress
local DrawLotteryWebhook = '' -- Draw lottery ticket webhook adress
local ResetAllDataWebhook = '' -- Reset data webhook adress
local PlayerReedemPrize = '' -- Reedem prize webhook adress
-- # Functions
function CheckPlayerTicketPayment(src)
local ply = ESX.GetPlayerFromId(src)
if not ply then
TriggerClientEvent('wert-newyearlotteryticket:client:custom-notify', src, LANG.error.tryAgain, 'error')
return false
end
local price = Config.TicketPrice
local money = ply.getAccount(Config.PaymentMethod).money
money = tonumber(money)
if not money then money = 0 end
if (money - price) < 0 then
local needMoney = price - money
local text = LANG.error.moneyError
TriggerClientEvent('wert-newyearlotteryticket:client:custom-notify', src, ChangeLangText(text, price, needMoney), 'error')
return false
end
ply.removeAccountMoney(Config.PaymentMethod, tonumber(price))
return true
end
function TicketPaymentCancelled(src)
local ply = ESX.GetPlayerFromId(src)
if not ply then return end
local price = Config.TicketPrice
ply.addAccountMoney(Config.PaymentMethod, tonumber(price))
end
function BuyTicketDiscordLog(src, ticketNumber, ticketSerial)
local fullname = GetPlayerName(src)
local citizenid = 'Undefined'
local ply = ESX.GetPlayerFromId(src)
if ply then
fullname = ply.getName()
citizenid = ply.getIdentifier()
end
local logMessage = 'Player Name : ' .. fullname ..
'\n Player ID : ' .. src ..
'\n Player Citizen : ' .. citizenid ..
'\n Ticket Number : ' .. ticketNumber ..
'\n Ticket Serial : ' .. ticketSerial
exports['wert-newyearlotteryticket']:discordLog(BuyTicketWebhook, 'Player Bought New Year Ticket', logMessage)
end
function AddTicketItem(src, ticketNumber, ticketSerial)
local ply = ESX.GetPlayerFromId(src)
if not ply then return false end
local info = { newYearTicket = {ticketNumber = ticketNumber, ticketSerial = ticketSerial} }
if Config.OxInventory then
exports.ox_inventory:AddItem(src, 'bread', Config.TicketItem, 1, info, nil)
else
-- If u want use custom another inventory edit here!
end
return true
end
function DrawLotteryDiscordLog(src, ticketNumber, ticketSerial, ticketOwner)
local fullname = GetPlayerName(src)
local citizenid = 'Undefined'
local ply = ESX.GetPlayerFromId(src)
if ply then
fullname = ply.getName()
citizenid = ply.getIdentifier()
end
local logMessage = 'Player Name : ' .. fullname ..
'\n Player ID : ' .. src ..
'\n Player Citizen : ' .. citizenid ..
'\n Winner Ticket Number : ' .. ticketNumber ..
'\n Winner Ticket Serial : ' .. ticketSerial ..
'\n The Citizen Of The Person Buying' .. ticketOwner
exports['wert-newyearlotteryticket']:discordLog(DrawLotteryWebhook, "The lottery draw has been started!", logMessage)
end
function ResetAllDatasDiscordLog(src)
local fullname = GetPlayerName(src)
local citizenid = 'Undefined'
local ply = ESX.GetPlayerFromId(src)
if ply then
fullname = ply.getName()
citizenid = ply.getIdentifier()
end
local logMessage = 'Player Name : ' .. fullname ..
'\n Player ID : ' .. src ..
'\n Player Citizen : ' .. citizenid
exports['wert-newyearlotteryticket']:discordLog(ResetAllDataWebhook, "Someone reset all data!", logMessage)
end
function CheckTicketItemInInventory(src)
local ply = ESX.GetPlayerFromId(src)
if not ply then return false end
if Config.OxInventory then
local item = exports.ox_inventory:GetItem(src, Config.TicketItem, nil, false)
if not item then return false end
if item.count <= 0 then return false end
else
-- If u want use custom another inventory edit here!
end
return true
end
function CheckWinnerTicketInMyInventory(src, data)
local ply = ESX.GetPlayerFromId(src)
if not ply then return false end
local foundAValid = false
local foundWinnerTicket = nil
if Config.OxInventory then
local items = exports.ox_inventory:GetInventoryItems(src)
for slot, item in pairs(playerItems) do
if item and item.name == Config.TicketItem and item.metadata and item.metadata.newYearTicket and item.count > 0 then
local myNumber = item.metadata.newYearTicket.ticketNumber
local mySerial = item.metadata.newYearTicket.ticketSerial
if myNumber and mySerial then
foundAValid = true
if data.ticketNumber == myNumber and data.ticketSerial == mySerial then
foundWinnerTicket = tonumber(slot)
break
end
end
end
end
else
-- If u want use custom another inventory edit here!
end
if not foundAValid then
TriggerClientEvent('wert-newyearlotteryticket:client:custom-notify', src, LANG.error.invalidTicketErr, 'error')
return false
end
if foundAValid and not foundWinnerTicket then
TriggerClientEvent('wert-newyearlotteryticket:client:custom-notify', src, LANG.error.notWinnerTicketErr, 'error')
return false
end
if foundAValid and foundWinnerTicket then return foundWinnerTicket end
TriggerClientEvent('wert-newyearlotteryticket:client:custom-notify', src, LANG.error.invalidTicketErr, 'error')
return false
end
function PlayerWinLottery(src, checkWinnerItem, data)
local ply = ESX.GetPlayerFromId(src)
if not ply then return false end
if not checkWinnerItem then
TriggerClientEvent('wert-newyearlotteryticket:client:custom-notify', src, LANG.error.invalidTicketErr, 'error')
return false
end
checkWinnerItem = tonumber(checkWinnerItem)
local success = false
if Config.OxInventory then
success = exports.ox_inventory:RemoveItem(src, Config.TicketItem, 1, nil, checkWinnerItem)
else
-- If u want use custom another inventory edit here!
end
if success then
TriggerEvent('wert-newyearlotteryticket:server:winner-take-reward', src)
local price = tonumber(Config.BigPrize)
ply.addAccountMoney(Config.WinPrizeAccount, price)
local fullname = ply.getName()
local logMessage = 'Player Name : ' .. fullname ..
'\n Player ID : ' .. src ..
'\n Player Citizen : ' .. ply.getIdentifier() ..
'\n Ticket Number : ' .. data.ticketNumber or 'unkown' ..
'\n Ticket Serial : ' .. data.ticketSerial or 'unkown' ..
'\n Prize : ' .. price .. '$'
exports['wert-newyearlotteryticket']:discordLog(PlayerReedemPrize, "Player reedem lottery win prize!", logMessage)
TriggerClientEvent('wert-newyearlotteryticket:client:custom-notify', src, LANG.success.win)
return true
else
TriggerClientEvent('wert-newyearlotteryticket:client:custom-notify', src, LANG.error.failedRemoveTicketForWinnner, 'error')
return false
end
end
-- # Commands
if Config.DrawCommand.active then
ESX.RegisterCommand({Config.DrawCommand.name}, Config.DrawCommand.group, function(xPlayer, args, showError)
exports['wert-newyearlotteryticket']:StartDrawLottery(xPlayer.source)
end, false, {help = Config.DrawCommand.description})
end
if Config.ResetSystemCommand.active then
ESX.RegisterCommand({Config.ResetSystemCommand.name}, Config.ResetSystemCommand.group, function(xPlayer, args, showError)
exports['wert-newyearlotteryticket']:ResetAllDatas(xPlayer.source)
end, false, {help = Config.ResetSystemCommand.description})
end
LANG = {
interaction = {
buyTarget = 'Buy Ticket',
buyNoTarget = '[E] Buy Ticket',
dialogLabel = 'New Year Winter Lottery Seller!',
dialogLabelTwo = 'New Year Winter Lottery Seller!',
dialogQuestion = "Hello, how can I help you ? Would you like to buy a New Year's ticket ?",
dialogBuyButton = "I Want Buy A New Year's Ticket (1000$)",
dialogExit = "I'm Busy. [EXIT]",
exchangeTarget = "Did My Christmas Ticket Win Anything ?",
exchangeDialogLabel = 'Christmas Lottery Ticket Control Officer!',
exchangeDialogLabelTwo = 'Christmas Lottery Ticket Control Officer!',
exchangeDialogQuestion = "Hello, how can I help you ? Do you want to check your Christmas ticket ?",
exchangeDialogControlButton = "I want to check if there is a prize on my Christmas ticket ...",
exchangeDialogExit = "I'm Busy. [EXIT]",
exchangeNoTarget = '[E] Check The Christmas ticket',
},
error = {
moneyError = "You don't have enough money to buy Christmas tickets! The ticket price is %s$. You need another %s$ to buy tickets!",
notRegisteredSeller = "I'm not working right now because of a problem, please notify the authorities!",
sellerPedBusy = "I'm selling tickets to a different person right now, please wait!",
cancelled = 'Cancelled!',
invalidTicket = 'Invalid Ticket! This ticket not available for use, not valid!',
tryAgain = 'Please try again!',
maxTicketLimit = "You can't buy any more tickets! You have filled out your right to purchase!",
drawAlreadyStarted = "The draw has already been started or made before!",
notFoundedAnyTicket = "There are no tickets purchased! There is no draw, please make sure the tickets are sold!",
drawAlreadyStartedBuyError = "The time for the draw has come or gone! We are no longer selling tickets, we will wait again for the next drawing!",
duplicateTicket = "This ticket is not available for sale, please try to buy a new ticket... (Taken by a different person)",
ticketItemNotFound = "You don't have any Christmas tickets in your inventory!",
drawNotCompleted = "The New Year's lottery draw has not been held yet! After the draw is completed, you can bring your tickets to me for verification.",
invalidTicketErr = "You don't have a valid ticket on you! You didn't win any prizes!",
notWinnerTicketErr = "The tickets you have did not win any prize! Better luck next time!",
failedRemoveTicketForWinnner = "The ticket could not be checked! Please try again!",
},
success = {
bought = "You paid %s$ to buy a New Year's ticket! Good luck! Don't forget to check your ticket ...",
allDatasReseted = 'All Lottery Datas Deleted And Reseted!',
win = 'Congrats! You have won the grand prize, the prize has been credited to your bank account!',
},
buyTicket_ProgressbarLabel = 'Ticket are being purchased ...',
interface = {
serialNo = "SERIAL NO : %s",
moneyIcon = '$',
ticketNumberIcon = 'S F',
closeStatus = 'Close with BACKSPACE',
timerText = "The big Christmas draw will start at the location indicated on the GPS when the time expire!",
selectCardInformationHeader = 'INFORMATION',
selectCardInformationDescription = "Hello, here are the cards! You can choose and buy the card that you feel lucky with. Good luck, I hope you win...",
selectCardRefreshHeader = "CHANGE CARDS",
selectCardRefreshDescription = "Shall I shuffle the cards and show them again ? Do you want different numbered cards ?",
selectCardChangeButton = "CHANGE CARDS",
},
mixingBalls = 'Mixing Balls ...',
takingBall = 'The Ball Is Being Selected ...',
drawStartNotification = "The draw is starting ! The lottery area is marked on the map, go there now!",
}
function ChangeLangText(text, ...)
return string.format(text, ...)
end