Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions README.md
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
10 changes: 10 additions & 0 deletions config.lua
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'
}
9 changes: 9 additions & 0 deletions fxmanifest.lua
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'
}
38 changes: 38 additions & 0 deletions 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
Copy link
Copy Markdown

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.

local zPlayer = ESX.GetPlayerFromId(playerId)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you really need to define this here as xPlayer is passed via this event: (playerId, xPlayer, isNew)

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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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
24 changes: 0 additions & 24 deletions starterpack/client.lua

This file was deleted.

18 changes: 0 additions & 18 deletions starterpack/fxmanifest.lua

This file was deleted.

73 changes: 0 additions & 73 deletions starterpack/server.lua

This file was deleted.

3 changes: 0 additions & 3 deletions starterpack/sql.sql

This file was deleted.