mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-31 16:01:36 +00:00
- unknown commands will no longer be written out - a lot of formatting moved to i18n strings - fixes ÅÄÖ #5 - fixes #4
This commit is contained in:
+20
-50
@@ -1,53 +1,23 @@
|
||||
--[[
|
||||
|
||||
ESX RP Chat
|
||||
|
||||
--]]
|
||||
|
||||
function getIdentity(source)
|
||||
local identifier = GetPlayerIdentifiers(source)[1]
|
||||
local result = MySQL.Sync.fetchAll("SELECT * FROM users WHERE identifier = @identifier", {['@identifier'] = identifier})
|
||||
if result[1] ~= nil then
|
||||
local identity = result[1]
|
||||
|
||||
return {
|
||||
identifier = identity['identifier'],
|
||||
firstname = identity['firstname'],
|
||||
lastname = identity['lastname'],
|
||||
dateofbirth = identity['dateofbirth'],
|
||||
sex = identity['sex'],
|
||||
height = identity['height']
|
||||
}
|
||||
else
|
||||
return nil
|
||||
AddEventHandler('chatMessage', function(source, name, msg)
|
||||
local command = stringsplit(msg, " ")[1];
|
||||
|
||||
if command == "/ooc" then
|
||||
CancelEvent()
|
||||
TriggerClientEvent('esx_rpchat:sendProximityMessage', -1, source, _U('ooc_prefix', name), string.sub(msg, 5), { 128, 128, 128 })
|
||||
elseif command == "/twt" then
|
||||
CancelEvent()
|
||||
TriggerClientEvent('chatMessage', -1, _U('twt_prefix', name), { 0, 153, 204 }, string.sub(msg, 5))
|
||||
elseif command == "/me" then
|
||||
CancelEvent()
|
||||
TriggerClientEvent('esx_rpchat:sendProximityMessage', -1, source, _U('me_prefix', name), string.sub(msg, 5), { 255, 0, 0 })
|
||||
elseif command == "/news" then
|
||||
CancelEvent()
|
||||
TriggerClientEvent('chatMessage', -1, _U('news_prefix', name), { 249, 166, 0 }, string.sub(msg, 6))
|
||||
elseif string.sub(command, 1, 1) == "/" then
|
||||
CancelEvent()
|
||||
TriggerClientEvent('chatMessage', source, '', {132, 13, 37}, _U('ooc_unknown_command', command))
|
||||
end
|
||||
end
|
||||
|
||||
AddEventHandler('chatMessage', function(source, name, message)
|
||||
if string.sub(message, 1, string.len("/")) ~= "/" then
|
||||
local name = getIdentity(source)
|
||||
TriggerClientEvent("sendProximityMessage", -1, source, name.firstname, message)
|
||||
end
|
||||
CancelEvent()
|
||||
end)
|
||||
|
||||
TriggerEvent('es:addCommand', 'me', function(source, args, user)
|
||||
local name = getIdentity(source)
|
||||
TriggerClientEvent("sendProximityMessageMe", -1, source, name.firstname, table.concat(args, " "))
|
||||
end)
|
||||
|
||||
TriggerEvent('es:addCommand', 'do', function(source, args, user)
|
||||
local name = getIdentity(source)
|
||||
TriggerClientEvent("sendProximityMessageDo", -1, source, name.firstname, table.concat(args, " "))
|
||||
end)
|
||||
|
||||
TriggerEvent('es:addCommand', 'twt', function(source, args, user)
|
||||
TriggerClientEvent('chatMessage', -1, "^0[^4Twitter^0] (^5@" .. GetPlayerName(source) .. "^0)", {30, 144, 255}, table.concat(args, " "))
|
||||
end, {help = 'Send a tweet. [IC]'})
|
||||
|
||||
TriggerEvent('es:addCommand', 'ooc', function(source, args, user)
|
||||
TriggerClientEvent('chatMessage', -1, "OOC | " .. GetPlayerName(source), {128, 128, 128}, table.concat(args, " "))
|
||||
end, {help = 'Send an out of character message to the whole server.'})
|
||||
end)
|
||||
|
||||
function stringsplit(inputstr, sep)
|
||||
if sep == nil then
|
||||
@@ -59,4 +29,4 @@ function stringsplit(inputstr, sep)
|
||||
i = i + 1
|
||||
end
|
||||
return t
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user