mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-09-04 16:23:21 +00:00
See the description for changes (cleanup)
- reworked /setmoney [id] [money type] [amount] - implemented /disc (/disconnect) - the give submenu does no longer appear if there's no one nearby - if you have 0 cash, bank or black money it wont appear in your f2 inventory - when selecting a item, let the item label be the title of the menu (inventory menu) - minor improvements
This commit is contained in:
+24
-20
@@ -1063,28 +1063,32 @@ ESX.ShowInventory = function()
|
||||
local playerPed = GetPlayerPed(-1)
|
||||
local elements = {}
|
||||
|
||||
table.insert(elements, {
|
||||
label = '[Cash] $' .. ESX.PlayerData.money,
|
||||
count = ESX.PlayerData.money,
|
||||
type = 'item_money',
|
||||
value = 'money',
|
||||
usable = false,
|
||||
rare = false,
|
||||
canRemove = true
|
||||
})
|
||||
|
||||
for i=1, #ESX.PlayerData.accounts, 1 do
|
||||
if ESX.PlayerData.money > 0 then
|
||||
table.insert(elements, {
|
||||
label = '[' .. ESX.PlayerData.accounts[i].label .. '] $' .. ESX.PlayerData.accounts[i].money,
|
||||
count = ESX.PlayerData.accounts[i].money,
|
||||
type = 'item_account',
|
||||
value = ESX.PlayerData.accounts[i].name,
|
||||
label = '[Cash] $' .. ESX.PlayerData.money,
|
||||
count = ESX.PlayerData.money,
|
||||
type = 'item_money',
|
||||
value = 'money',
|
||||
usable = false,
|
||||
rare = false,
|
||||
canRemove = true
|
||||
})
|
||||
end
|
||||
|
||||
for i=1, #ESX.PlayerData.accounts, 1 do
|
||||
if ESX.PlayerData.accounts[i].money > 0 then
|
||||
table.insert(elements, {
|
||||
label = '[' .. ESX.PlayerData.accounts[i].label .. '] $' .. ESX.PlayerData.accounts[i].money,
|
||||
count = ESX.PlayerData.accounts[i].money,
|
||||
type = 'item_account',
|
||||
value = ESX.PlayerData.accounts[i].name,
|
||||
usable = false,
|
||||
rare = false,
|
||||
canRemove = true
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
for i=1, #ESX.PlayerData.inventory, 1 do
|
||||
|
||||
if ESX.PlayerData.inventory[i].count > 0 then
|
||||
@@ -1132,9 +1136,9 @@ ESX.ShowInventory = function()
|
||||
elements = elements,
|
||||
},
|
||||
function(data, menu)
|
||||
|
||||
menu.close()
|
||||
|
||||
local player, distance = ESX.Game.GetClosestPlayer()
|
||||
local elements = {}
|
||||
|
||||
if data.current.usable then
|
||||
@@ -1142,7 +1146,9 @@ ESX.ShowInventory = function()
|
||||
end
|
||||
|
||||
if data.current.canRemove then
|
||||
table.insert(elements, {label = _U('give'), action = 'give', type = data.current.type, value = data.current.value})
|
||||
if player ~= -1 and distance <= 3.0 then
|
||||
table.insert(elements, {label = _U('give'), action = 'give', type = data.current.type, value = data.current.value})
|
||||
end
|
||||
table.insert(elements, {label = _U('remove'), action = 'remove', type = data.current.type, value = data.current.value})
|
||||
end
|
||||
|
||||
@@ -1155,7 +1161,7 @@ ESX.ShowInventory = function()
|
||||
ESX.UI.Menu.Open(
|
||||
'default', GetCurrentResourceName(), 'inventory_item',
|
||||
{
|
||||
title = _U('inventory'),
|
||||
title = data.current.label,
|
||||
align = 'bottom-right',
|
||||
elements = elements,
|
||||
},
|
||||
@@ -1301,14 +1307,12 @@ ESX.ShowInventory = function()
|
||||
end
|
||||
|
||||
elseif data.current.action == 'use' then
|
||||
|
||||
TriggerServerEvent('esx:useItem', data.current.value)
|
||||
|
||||
elseif data.current.action == 'return' then
|
||||
|
||||
ESX.UI.Menu.CloseAll()
|
||||
ESX.ShowInventory()
|
||||
|
||||
elseif data.current.action == 'giveammo' then
|
||||
local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer()
|
||||
local closestPed = GetPlayerPed(closestPlayer)
|
||||
|
||||
+18
-19
@@ -17,6 +17,7 @@ local IsPaused = false
|
||||
local PlayerSpawned = false
|
||||
local LastLoadout = {}
|
||||
local Pickups = {}
|
||||
local isDead = false
|
||||
|
||||
RegisterNetEvent('esx:playerLoaded')
|
||||
AddEventHandler('esx:playerLoaded', function(xPlayer)
|
||||
@@ -57,28 +58,22 @@ AddEventHandler('esx:playerLoaded', function(xPlayer)
|
||||
end)
|
||||
|
||||
AddEventHandler('playerSpawned', function()
|
||||
while not ESX.PlayerLoaded do
|
||||
Citizen.Wait(1)
|
||||
end
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
local playerPed = GetPlayerPed(-1)
|
||||
|
||||
while not ESX.PlayerLoaded do
|
||||
Citizen.Wait(1)
|
||||
end
|
||||
-- Restore position
|
||||
if ESX.PlayerData.lastPosition ~= nil then
|
||||
SetEntityCoords(playerPed, ESX.PlayerData.lastPosition.x, ESX.PlayerData.lastPosition.y, ESX.PlayerData.lastPosition.z)
|
||||
end
|
||||
|
||||
local playerPed = GetPlayerPed(-1)
|
||||
|
||||
-- Restore position
|
||||
if ESX.PlayerData.lastPosition ~= nil then
|
||||
SetEntityCoords(playerPed, ESX.PlayerData.lastPosition.x, ESX.PlayerData.lastPosition.y, ESX.PlayerData.lastPosition.z)
|
||||
end
|
||||
|
||||
-- Restore loadout
|
||||
TriggerEvent('esx:restoreLoadout')
|
||||
|
||||
LoadoutLoaded = true
|
||||
PlayerSpawned = true
|
||||
|
||||
end)
|
||||
TriggerEvent('esx:restoreLoadout') -- restore loadout
|
||||
|
||||
LoadoutLoaded = true
|
||||
PlayerSpawned = true
|
||||
isDead = false
|
||||
end)
|
||||
|
||||
AddEventHandler('baseevents:onPlayerDied', function(killerType, coords)
|
||||
@@ -89,6 +84,10 @@ AddEventHandler('baseevents:onPlayerKilled', function(killerId, data)
|
||||
TriggerEvent('esx:onPlayerDeath')
|
||||
end)
|
||||
|
||||
AddEventHandler('esx:onPlayerDeath', function()
|
||||
isDead = true
|
||||
end)
|
||||
|
||||
AddEventHandler('skinchanger:loadDefaultModel', function()
|
||||
LoadoutLoaded = false
|
||||
end)
|
||||
@@ -472,7 +471,7 @@ Citizen.CreateThread(function()
|
||||
|
||||
Citizen.Wait(10)
|
||||
|
||||
if IsControlPressed(0, Keys["F2"]) and GetLastInputMethod(2) and not ESX.UI.Menu.IsOpen('default', 'es_extended', 'inventory') and (GetGameTimer() - GUI.Time) > 150 then
|
||||
if IsControlPressed(0, Keys["F2"]) and GetLastInputMethod(2) and not isDead and not ESX.UI.Menu.IsOpen('default', 'es_extended', 'inventory') and (GetGameTimer() - GUI.Time) > 150 then
|
||||
ESX.ShowInventory()
|
||||
GUI.Time = GetGameTimer()
|
||||
end
|
||||
|
||||
+7
-3
@@ -19,12 +19,12 @@ Locales['en'] = {
|
||||
['by'] = '~s~ by ~b~',
|
||||
['imp_invalid_quantity'] = 'action impossible, invalid quantity',
|
||||
['imp_invalid_amount'] = 'action impossible, invalid amount',
|
||||
['delete_five_min'] = '~r~delete~s~ in 5 minutes',
|
||||
['delete_five_min'] = 'the item will be ~r~deleted~s~ in 5 minutes',
|
||||
['threw'] = 'you ~r~threw~s~',
|
||||
['rec_salary'] = 'you received your salary: ',
|
||||
['rec_help'] = 'you recieved your welfare check: ',
|
||||
['company_paid'] = 'Company paycheck received',
|
||||
['company_nomoney'] = 'Your company is broke!',
|
||||
['company_paid'] = 'company paycheck received',
|
||||
['company_nomoney'] = 'your company is broke!',
|
||||
['state_paid'] = 'You received a state check',
|
||||
['act_imp'] = 'action impossible',
|
||||
['in_vehicle'] = 'you can\'t give anything to someone in a vehicle',
|
||||
@@ -46,6 +46,9 @@ Locales['en'] = {
|
||||
['spawn_ped'] = 'spawn ped',
|
||||
['spawn_ped_param'] = 'example a_m_m_hillbilly_01',
|
||||
['givemoney'] = 'give money',
|
||||
['setmoney'] = 'set money for a player',
|
||||
['money_type'] = 'valid money types: cash, bank, black',
|
||||
['money_set'] = 'someone ~y~highly ranked~s~ just set ~g~$%s~s~ (%s) for you!',
|
||||
['money_amount'] = 'amount of money',
|
||||
['invalid_account'] = 'invalid account',
|
||||
['account'] = 'account',
|
||||
@@ -55,6 +58,7 @@ Locales['en'] = {
|
||||
['giveitem'] = 'give item',
|
||||
['weapon'] = 'weapon',
|
||||
['giveweapon'] = 'give weapon',
|
||||
['disconnect'] = 'disconnect from the server',
|
||||
-- Weapons
|
||||
['weapon_knife'] = 'knife',
|
||||
['weapon_nightstick'] = 'nightstick',
|
||||
|
||||
+5
-1
@@ -2,7 +2,7 @@ Locales['sv'] = {
|
||||
['inventory'] = 'Mitt förråd',
|
||||
['use'] = 'använd',
|
||||
['give'] = 'ge',
|
||||
['remove'] = 'ta bort',
|
||||
['remove'] = 'kasta',
|
||||
['return'] = 'gå tillbaka',
|
||||
['amount'] = 'belopp',
|
||||
['amount_invalid'] = 'giltigt belopp',
|
||||
@@ -40,6 +40,9 @@ Locales['sv'] = {
|
||||
['spawn_ped'] = 'spawna NPC',
|
||||
['spawn_ped_param'] = 'example a_m_m_hillbilly_01',
|
||||
['givemoney'] = 'ge pengar',
|
||||
['setmoney'] = 'bestäm mängd pengar till en valfri person',
|
||||
['money_type'] = 'giltiga typer: cash, bank, black',
|
||||
['money_set'] = 'någon ~y~högt uppsatt~s~ satte ~g~$%s~s~ (%s) för dig!',
|
||||
['money_amount'] = 'summa pengar',
|
||||
['invalid_account'] = 'ogiltigt konto',
|
||||
['account'] = 'konto',
|
||||
@@ -49,6 +52,7 @@ Locales['sv'] = {
|
||||
['giveitem'] = 'ge föremål',
|
||||
['weapon'] = 'vapen',
|
||||
['giveweapon'] = 'ge vapen',
|
||||
['disconnect'] = 'koppla från servern',
|
||||
-- Weapons
|
||||
['weapon_knife'] = 'knife',
|
||||
['weapon_nightstick'] = 'nightstick',
|
||||
|
||||
+54
-21
@@ -1,14 +1,20 @@
|
||||
TriggerEvent('es:addGroupCommand', 'tp', 'admin', function(source, args, user)
|
||||
|
||||
TriggerClientEvent("esx:teleport", source, {
|
||||
x = tonumber(args[1]),
|
||||
y = tonumber(args[2]),
|
||||
z = tonumber(args[3])
|
||||
})
|
||||
|
||||
local x = tonumber(args[1])
|
||||
local y = tonumber(args[2])
|
||||
local z = tonumber(args[3])
|
||||
|
||||
if x and y and z then
|
||||
TriggerClientEvent("esx:teleport", source, {
|
||||
x = x,
|
||||
y = y,
|
||||
z = z
|
||||
})
|
||||
else
|
||||
TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Invalid coordinates!")
|
||||
end
|
||||
end, function(source, args, user)
|
||||
TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Insufficient Permissions.")
|
||||
end)
|
||||
end, {help = "Teleport to coordinates", params = {{name = "x", help = "X coords"}, {name = "y", help = "Y coords"}, {name = "z", help = "Z coords"}}})
|
||||
|
||||
TriggerEvent('es:addGroupCommand', 'setjob', 'jobmaster', function(source, args, user)
|
||||
local xPlayer = ESX.GetPlayerFromId(args[1])
|
||||
@@ -66,21 +72,36 @@ end, function(source, args, user)
|
||||
TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Insufficient Permissions.")
|
||||
end, {help = _U('spawn_object'), params = {{name = "name"}}})
|
||||
|
||||
TriggerEvent('es:addGroupCommand', 'givemoney', 'admin', function(source, args, user)
|
||||
|
||||
local _source = source
|
||||
local xPlayer = ESX.GetPlayerFromId(args[1])
|
||||
local amount = tonumber(args[2])
|
||||
|
||||
if amount ~= nil then
|
||||
xPlayer.addMoney(amount)
|
||||
else
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('amount_invalid'))
|
||||
end
|
||||
TriggerEvent('es:addGroupCommand', 'setmoney', 'admin', function(source, args, user)
|
||||
local _source = source
|
||||
|
||||
local target = tonumber(args[1])
|
||||
local money_type = args[2]
|
||||
local money_amount = tonumber(args[3])
|
||||
|
||||
local xTarget = ESX.GetPlayerFromId(target)
|
||||
|
||||
if target and money_type and money_amount and xTarget ~= nil then
|
||||
if money_type == 'cash' then
|
||||
xTarget.setMoney(money_amount)
|
||||
elseif money_type == 'bank' then
|
||||
xTarget.setAccountMoney('bank', money_amount)
|
||||
elseif money_type == 'black' then
|
||||
xTarget.setAccountMoney('black_money', money_amount)
|
||||
else
|
||||
TriggerClientEvent('chatMessage', _source, "SYSTEM", {255, 0, 0}, "^2" .. money_type .. " ^0 is not a valid money type!")
|
||||
return
|
||||
end
|
||||
else
|
||||
TriggerClientEvent('chatMessage', _source, "SYSTEM", {255, 0, 0}, "Invalid arguments.")
|
||||
return
|
||||
end
|
||||
|
||||
print('es_extended: ' .. GetPlayerName(source) .. ' just set $' .. money_amount .. ' (' .. money_type .. ') to ' .. xTarget.name)
|
||||
TriggerClientEvent('esx:showNotification', xTarget.source, _U('money_set', money_amount, money_type))
|
||||
end, function(source, args, user)
|
||||
TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Insufficient Permissions.")
|
||||
end, {help = _U('givemoney'), params = {{name = "id", help = _U('id_param')}, {name = "amount", help = _U('money_amount')}}})
|
||||
TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Insufficient Permissions.")
|
||||
end, {help = _U('setmoney'), params = {{name = "id", help = _U('id_param')}, {name = "money type", help = _U('money_type')}, {name = "amount", help = _U('money_amount')}}})
|
||||
|
||||
TriggerEvent('es:addGroupCommand', 'giveaccountmoney', 'admin', function(source, args, user)
|
||||
|
||||
@@ -134,3 +155,15 @@ TriggerEvent('es:addGroupCommand', 'giveweapon', 'admin', function(source, args,
|
||||
end, function(source, args, user)
|
||||
TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Insufficient Permissions.")
|
||||
end, {help = _U('giveweapon'), params = {{name = "id", help = _U('id_param')}, {name = "weapon", help = _U('weapon')}}})
|
||||
|
||||
TriggerEvent('es:addGroupCommand', 'disc', 'admin', function(source, args, user)
|
||||
DropPlayer(source, 'You have been disconnected')
|
||||
end, function(source, args, user)
|
||||
TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Insufficient Permissions.")
|
||||
end, {help = _U('disconnect')})
|
||||
|
||||
TriggerEvent('es:addGroupCommand', 'disconnect', 'admin', function(source, args, user)
|
||||
DropPlayer(source, 'You have been disconnected')
|
||||
end, function(source, args, user)
|
||||
TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Insufficient Permissions.")
|
||||
end, {help = _U('disconnect')})
|
||||
Reference in New Issue
Block a user