esx_itembytime
This script is made it for fivem. basically this give an item to all connected players an a certain amount of time configurable in the files.
INSTALLATION
Drag and drop. You also need to have es_extended.
add to server.cfg
config the item, time and message in the files
Config = {}
local second = 1000
local minute = 60 * second
Config.ItemByTimeInterval = 60 * minute
Config.Item = "ticket"
Config.ItemMessage = '~g~Has recibido un ticket para ~r~Navidad'
Config.ConsoleNotification = 'Item by time gived'
This would be good if it was using cron at a time or times every day instead of having to use a command everytime the server is restarted. Nice post though. It has potential.
I don’t really see the use of this script, it isn’t a certain amount of time since the script itself isn’t removing the item. Basically it is just a giveitem to all poorly written
Heres the code improved but its still one of the most useless scripts I’ve seen
TriggerEvent('es:addGroupCommand', 'itembytime', 'superadmin', function(source, args, user)
local players = ESX.GetPlayers()
local item = 'bread' -----------item
local message = 'hehe xd' -------------message
local amount = 1 ------ the amount of the item given
for i=1, #players, 1 do
local xPlayer = ESX.GetPlayerFromId(players[i])
xPlayer.addInventoryItem(item, amount)
TriggerClientEvent('esx:showNotification', xPlayer.source, message)
end
end)
this isnt a script to give one specific item to all with a command, this is an script to give that item to all conected players every hour (if you set one hour in the config) its like a first attempt to make a event ticket shop, or in our case, a event for christmas each ticket is a opportunity to win a single unique car
Its a nice online time reward system,but its downside is that it will give you an item every (time set) of the server last restart,that means if we set time cycle to one hour and i login 59 minutes after server restart,i will receive the item despite the fact that i am only 1 minute online,right?
How about change it to a client script that measures time of each player and give him an item with a server trigger every (time set).
Like the afk kick script.
In this way each client will trigger a server event every time and will give the player an item for his/her online time ,not server time.
I will try it and check resource timings in case of lagging.
Thank you for sharing mate.
Config.ItemMessage = ‘~g~Has recibido un ticket para ~r~Navidad’
Config.ConsoleNotification = ‘Item by time gived’
server.lua
function AddItemToInventoryByTime(d,h,m)
local players = ESX.GetPlayers()
for i=1, #players, 1 do
local xPlayer = ESX.GetPlayerFromId(players[i])
xPlayer.addInventoryItem(Config.Item, 1)
xPlayer.addMoney(Config.money)
TriggerClientEvent(‘esx:showNotification’, xPlayer.source, Config.ItemMessage)
print(Config.ConsoleNotification)
end
end