From 4279cc03f7424fd48142cc865f372cb1afb3c21b Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Sat, 29 Dec 2018 14:07:04 +0100 Subject: [PATCH] added /clearinventory /clearloadout --- locales/br.lua | 5 +++++ locales/cs.lua | 5 +++++ locales/de.lua | 5 +++++ locales/en.lua | 17 +++++++++------ locales/fi.lua | 5 +++++ locales/fr.lua | 5 +++++ locales/pl.lua | 5 +++++ locales/sv.lua | 5 +++++ server/commands.lua | 51 ++++++++++++++++++++++++++++++++++++++++++--- 9 files changed, 94 insertions(+), 9 deletions(-) diff --git a/locales/br.lua b/locales/br.lua index e19797f8..9ef7555e 100644 --- a/locales/br.lua +++ b/locales/br.lua @@ -46,6 +46,7 @@ Locales['br'] = { ['act_imp'] = 'acao impossivel', ['in_vehicle'] = 'voce nao pode dar nada para alguem no veiculo', ['cannot_pickup_room'] = 'voce nao tem espaço suficiente no seu inventario para pegar ~y~%s~s~!', + -- Commands ['setjob'] = 'atribuir um trabalho a um usuario', ['id_param'] = 'o ID do jogador', @@ -77,9 +78,13 @@ Locales['br'] = { ['disconnect'] = 'disconnect from the server', ['chat_clear'] = 'clear the chat', ['chat_clear_all'] = 'clear the chat for everyone', + ['command_clearinventory'] = 'clear all items from inventory', + ['command_clearloadout'] = 'remove all weapons from loadout', + ['command_playerid_param'] = 'specify playerId or leave blank for yourself', -- Locale settings ['locale_digit_grouping_symbol'] = ' ', ['locale_currency'] = '$%s', + -- Weapons ['weapon_knife'] = 'faca', ['weapon_nightstick'] = 'cacetete', diff --git a/locales/cs.lua b/locales/cs.lua index eacd5cae..0b3b3e07 100644 --- a/locales/cs.lua +++ b/locales/cs.lua @@ -46,6 +46,7 @@ Locales['cs'] = { ['act_imp'] = 'akce není možná', ['in_vehicle'] = 'nemůže nic dát osobě ve vozidle', ['cannot_pickup_room'] = 've vašem inventáři není dostatek místa pro ~y~%s~s~!', + -- Commands ['setjob'] = 'přiřadit práci hráči', ['id_param'] = 'iD hráče', @@ -77,9 +78,13 @@ Locales['cs'] = { ['disconnect'] = 'odpojit od serveru', ['chat_clear'] = 'vyčistit chat', ['chat_clear_all'] = 'vyčistit chat pro všechny', + ['command_clearinventory'] = 'clear all items from inventory', + ['command_clearloadout'] = 'remove all weapons from loadout', + ['command_playerid_param'] = 'specify playerId or leave blank for yourself', -- Locale settings ['locale_digit_grouping_symbol'] = ' ', ['locale_currency'] = '$%s', + -- Weapons ['weapon_knife'] = 'knife', ['weapon_nightstick'] = 'nightstick', diff --git a/locales/de.lua b/locales/de.lua index 5bc6fd29..1aa9b2ed 100644 --- a/locales/de.lua +++ b/locales/de.lua @@ -46,6 +46,7 @@ Locales['de'] = { ['act_imp'] = 'Aktion nicht möglich', ['in_vehicle'] = 'you can\'t give anything to someone in a vehicle', ['cannot_pickup_room'] = 'you do not have enough space in your inventory to pick up ~y~%s~s~!', + -- Commands ['setjob'] = 'assign a job to a user', ['id_param'] = 'the ID of the player', @@ -77,9 +78,13 @@ Locales['de'] = { ['disconnect'] = 'disconnect from the server', ['chat_clear'] = 'clear the chat', ['chat_clear_all'] = 'clear the chat for everyone', + ['command_clearinventory'] = 'clear all items from inventory', + ['command_clearloadout'] = 'remove all weapons from loadout', + ['command_playerid_param'] = 'specify playerId or leave blank for yourself', -- Locale settings ['locale_digit_grouping_symbol'] = ' ', ['locale_currency'] = '$%s', + -- Weapons ['weapon_knife'] = 'Messer', ['weapon_nightstick'] = 'Schlagstock', diff --git a/locales/en.lua b/locales/en.lua index 996b1976..1ccf6f37 100644 --- a/locales/en.lua +++ b/locales/en.lua @@ -46,6 +46,7 @@ Locales['en'] = { ['act_imp'] = 'action impossible', ['in_vehicle'] = 'you can\'t give anything to someone in a vehicle', ['cannot_pickup_room'] = 'you do not have enough space in your inventory to pick up ~y~%s~s~!', + -- Commands ['setjob'] = 'assign a job to a user', ['id_param'] = 'the ID of the player', @@ -77,9 +78,13 @@ Locales['en'] = { ['disconnect'] = 'disconnect from the server', ['chat_clear'] = 'clear the chat', ['chat_clear_all'] = 'clear the chat for everyone', + ['command_clearinventory'] = 'clear all items from inventory', + ['command_clearloadout'] = 'remove all weapons from loadout', + ['command_playerid_param'] = 'specify playerId or leave blank for yourself', -- Locale settings ['locale_digit_grouping_symbol'] = ',', ['locale_currency'] = '$%s', + -- Weapons ['weapon_knife'] = 'knife', ['weapon_nightstick'] = 'nightstick', @@ -89,16 +94,16 @@ Locales['en'] = { ['weapon_crowbar'] = 'crow bar', ['weapon_pistol'] = 'pistol', ['weapon_combatpistol'] = 'combat pistol', - ['weapon_appistol'] = 'ap pistol', + ['weapon_appistol'] = 'AP pistol', ['weapon_pistol50'] = 'pistol .50', - ['weapon_microsmg'] = 'micro smg', - ['weapon_smg'] = 'smg', - ['weapon_assaultsmg'] = 'assault smg', + ['weapon_microsmg'] = 'micro SMG', + ['weapon_smg'] = 'SMG', + ['weapon_assaultsmg'] = 'assault SMG', ['weapon_assaultrifle'] = 'assault rifle', ['weapon_carbinerifle'] = 'carbine rifle', ['weapon_advancedrifle'] = 'advanced rifle', - ['weapon_mg'] = 'mg', - ['weapon_combatmg'] = 'combat mg', + ['weapon_mg'] = 'MG', + ['weapon_combatmg'] = 'combat MG', ['weapon_pumpshotgun'] = 'pump shotgun', ['weapon_sawnoffshotgun'] = 'sawed off shotgun', ['weapon_assaultshotgun'] = 'assault shotgun', diff --git a/locales/fi.lua b/locales/fi.lua index 255d6dd9..08adfa48 100644 --- a/locales/fi.lua +++ b/locales/fi.lua @@ -46,6 +46,7 @@ Locales['fi'] = { ['act_imp'] = 'toiminto mahdoton', ['in_vehicle'] = 'et voi antaa ajoneuvossa olevalle mitään.', ['cannot_pickup_room'] = 'sinulla ei ole tilaa repussa nostaaksesi ~y~%s~s~!', + -- Commands ['setjob'] = 'määritä työ käyttäjälle', ['id_param'] = 'käyttäjän ID', @@ -77,9 +78,13 @@ Locales['fi'] = { ['disconnect'] = 'poistu serveriltä', ['chat_clear'] = 'tyhjennä chatti', ['chat_clear_all'] = 'tyhjennä chatti kaikilta', + ['command_clearinventory'] = 'clear all items from inventory', + ['command_clearloadout'] = 'remove all weapons from loadout', + ['command_playerid_param'] = 'specify playerId or leave blank for yourself', -- Locale settings ['locale_digit_grouping_symbol'] = ' ', ['locale_currency'] = '$%s', + -- Weapons ['weapon_knife'] = 'veitsi', ['weapon_nightstick'] = 'pamppu', diff --git a/locales/fr.lua b/locales/fr.lua index 2af83b00..b49d9cb5 100644 --- a/locales/fr.lua +++ b/locales/fr.lua @@ -46,6 +46,7 @@ Locales['fr'] = { ['act_imp'] = 'action impossible', ['in_vehicle'] = 'Vous ne pouvez rien donner à quelqu\'un dans un véhicule', ['cannot_pickup_room'] = 'vous n\'avez plus de place pour ~y~%s~s~!', + -- Commands ['setjob'] = 'assigner job', ['id_param'] = 'identification du joueur', @@ -77,9 +78,13 @@ Locales['fr'] = { ['disconnect'] = 'disconnect from the server', ['chat_clear'] = 'clear the chat', ['chat_clear_all'] = 'clear the chat for everyone', + ['command_clearinventory'] = 'clear all items from inventory', + ['command_clearloadout'] = 'remove all weapons from loadout', + ['command_playerid_param'] = 'specify playerId or leave blank for yourself', -- Locale settings ['locale_digit_grouping_symbol'] = ' ', ['locale_currency'] = '$%s', + -- Weapons ['weapon_knife'] = 'couteau', ['weapon_nightstick'] = 'matraque', diff --git a/locales/pl.lua b/locales/pl.lua index 8d925fd2..c898ca26 100644 --- a/locales/pl.lua +++ b/locales/pl.lua @@ -46,6 +46,7 @@ Locales['pl'] = { ['act_imp'] = 'działanie niemożliwe', ['in_vehicle'] = 'nie możesz przekazywać przedmiotów w pojeździe', ['cannot_pickup_room'] = 'nie masz wystarczająco dużo miejsca w ekwipunku, aby podnieść ~y~%s~s~!', + -- Commands ['setjob'] = 'przydziel prace użytkownikowi', ['id_param'] = 'iD użyszkodnika', @@ -77,9 +78,13 @@ Locales['pl'] = { ['disconnect'] = 'odłącz się od serwera', ['chat_clear'] = 'clear the chat', ['chat_clear_all'] = 'clear the chat for everyone', + ['command_clearinventory'] = 'clear all items from inventory', + ['command_clearloadout'] = 'remove all weapons from loadout', + ['command_playerid_param'] = 'specify playerId or leave blank for yourself', -- Locale settings ['locale_digit_grouping_symbol'] = ' ', ['locale_currency'] = '$%s', + -- Weapons ['weapon_knife'] = 'nóż', ['weapon_nightstick'] = 'pałka', diff --git a/locales/sv.lua b/locales/sv.lua index faa1f04c..647dd50b 100644 --- a/locales/sv.lua +++ b/locales/sv.lua @@ -46,6 +46,7 @@ Locales['sv'] = { ['act_imp'] = 'åtgärd omöjlig', ['in_vehicle'] = 'du kan inte ge saker till en som sitter i ett fordon!', ['cannot_pickup_room'] = 'du har inte plats för att plocka upp ~y~%s~s~!', + -- Commands ['setjob'] = 'tilldela ett jobb till en användare', ['id_param'] = 'spelarens ID', @@ -77,9 +78,13 @@ Locales['sv'] = { ['disconnect'] = 'koppla från servern', ['chat_clear'] = 'töm chatten', ['chat_clear_all'] = 'töm chatten för alla', + ['command_clearinventory'] = 'clear all items from inventory', + ['command_clearloadout'] = 'remove all weapons from loadout', + ['command_playerid_param'] = 'specify playerId or leave blank for yourself', -- Locale settings ['locale_digit_grouping_symbol'] = ' ', ['locale_currency'] = '%s SEK', + -- Weapons ['weapon_knife'] = 'kniv', ['weapon_nightstick'] = 'batong', diff --git a/server/commands.lua b/server/commands.lua index 3de2797e..0b585460 100644 --- a/server/commands.lua +++ b/server/commands.lua @@ -19,13 +19,14 @@ end, {help = "Teleport to coordinates", params = {{name = "x", help = "X coords" TriggerEvent('es:addGroupCommand', 'setjob', 'jobmaster', function(source, args, user) if tonumber(args[1]) and args[2] and tonumber(args[3]) then local xPlayer = ESX.GetPlayerFromId(args[1]) - if xPlayer ~= nil then + + if xPlayer then xPlayer.setJob(args[2], tonumber(args[3])) else - TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Player not online.") + TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'Player not online.' } }) end else - TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Invalid usage.") + TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'Invalid usage.' } }) end end, function(source, args, user) TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'Insufficient Permissions.' } }) @@ -200,3 +201,47 @@ TriggerEvent('es:addGroupCommand', 'clearall', 'admin', function(source, args, u end, function(source, args, user) TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'Insufficient Permissions.' } }) end, {help = _U('chat_clear_all')}) + +TriggerEvent('es:addGroupCommand', 'clearinventory', 'admin', function(source, args, user) + local xPlayer + + if args[1] then + xPlayer = ESX.GetPlayerFromId(args[1]) + else + xPlayer = ESX.GetPlayerFromId(source) + end + + if not xPlayer then + TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'Player not online.' } }) + return + end + + for i=1, #xPlayer.inventory, 1 do + if xPlayer.inventory[i].count > 0 then + xPlayer.setInventoryItem(xPlayer.inventory[i].name, 0) + end + end +end, function(source, args, user) + TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'Insufficient Permissions.' } }) +end, {help = _U('command_clearinventory'), params = {{name = "playerId", help = _U('command_playerid_param')}}}) + +TriggerEvent('es:addGroupCommand', 'clearloadout', 'admin', function(source, args, user) + local xPlayer + + if args[1] then + xPlayer = ESX.GetPlayerFromId(args[1]) + else + xPlayer = ESX.GetPlayerFromId(source) + end + + if not xPlayer then + TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'Player not online.' } }) + return + end + + for i=1, #xPlayer.loadout, 1 do + xPlayer.removeWeapon(xPlayer.loadout[i].name) + end +end, function(source, args, user) + TriggerClientEvent('chat:addMessage', source, { args = { '^1SYSTEM', 'Insufficient Permissions.' } }) +end, {help = _U('command_clearloadout'), params = {{name = "playerId", help = _U('command_playerid_param')}}})