-
Notifications
You must be signed in to change notification settings - Fork 3
Optimize the script, remove MySQL queries and client script #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
a75ff34
8d2c6bc
6517164
d6b7e93
b63b588
0d4dafb
32c783d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,9 @@ | ||
| # starterpack | ||
| Simple /starterpack script for ESX Framework [FIVEM] | ||
| Simple starterpack script for ESX Framework [FIVEM] | ||
|
|
||
|
|
||
| It’s simple script for /starterpack. | ||
| If you write on chat /starterpack you can get start items or organization items for start. | ||
| It’s a simple starterpack script. | ||
| When creating a new character you will automatically get some starter items which is set in the config. | ||
| You can use this one times per character. | ||
| Items you can change in server.lua. | ||
| Script based on es_extended 1.2.0. | ||
| Sorry for my English!! | ||
| Script based on es_extended Legacy, but is working for ESX 1.1 and 1.2 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| Config = { | ||
| StarterItems = { | ||
| {databasename = 'bread', count = 1}, | ||
| {databasename = 'water', count = 2}, | ||
| }, | ||
|
|
||
| OldESX = false, | ||
| Config.NotificationSystem = 'ESX', -- or mythic_notify | ||
| Config.Webhook = 'WEBHOOK HERE' | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| fx_version 'cerulean' | ||
| game 'gta5' | ||
|
|
||
| shared_script '@es_extended/imports.lua' -- Remove if using older ESX | ||
|
|
||
| server_scripts { | ||
| 'config.lua', | ||
| 'server/server.lua' | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| if Config.OldESX then | ||
| ESX = nil | ||
| TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) | ||
| end | ||
|
|
||
| RegisterNetEvent('esx:playerLoaded') -- When a player loads in, we can store some basic information about them locally | ||
| AddEventHandler('esx:playerLoaded', function(playerId, xPlayer, isNew) | ||
| ESX.Players[playerId] = xPlayer.job.name | ||
| local zPlayer = ESX.GetPlayerFromId(playerId) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you really need to define this here as You use xPlayer to trigger a notification below this. |
||
| if isNew then | ||
| for k, v in pairs(Config.StarterItems) do | ||
| zPlayer.addInventoryItem(v.databasename, v.count) | ||
| sendToDiscord('Starteritems','Player ' ..GetPlayerName(playerId).. ', '..zPlayer.identifier..' picked up' ,3999999) | ||
| if Config.NotificationSystem == 'ESX' then | ||
| xPlayer.showNotification('You received some starter items') | ||
| elseif Config.NotificationSystem == 'mythic_notify' then | ||
| TriggerClientEvent('mythic_notify:client:SendAlert', playerId, { type = 'inform', text = 'You received some starter items!', length = 2500, style = { ['background-color'] = '##', ['color'] = '#FFFFFF' } }) | ||
| end | ||
| end | ||
| end | ||
| end) | ||
|
|
||
| function sendToDiscord (name,message,color) | ||
| local DiscordWebHook = Config.Webhook | ||
| local embeds = { | ||
| { | ||
| ["title"]=message, | ||
| ["type"]="rich", | ||
| ["color"] =color, | ||
| ["footer"]= { | ||
| ["text"]= "starterpack by polacy", | ||
| }, | ||
| } | ||
| } | ||
|
|
||
| if message == nil or message == '' then return FALSE end | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's no need to return a bool here as you're doing nothing with it. Best to toss an error print then to just return. |
||
| PerformHttpRequest(DiscordWebHook, function(err, text, headers) end, 'POST', json.encode({ username = name,embeds = embeds}), { ['Content-Type'] = 'application/json' }) | ||
| end | ||
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idk why this is here ether.