diff --git a/client/events.lua b/client/events.lua index 9bfed48..8570684 100644 --- a/client/events.lua +++ b/client/events.lua @@ -101,3 +101,36 @@ end) RegisterNetEvent('QBCore:Client:UseItem', function(item) TriggerServerEvent('QBCore:Server:UseItem', item) end) + +-- Me command + +local function Draw3DText(coords, str) + local onScreen, worldX, worldY = World3dToScreen2d(coords.x, coords.y, coords.z) + local camCoords = GetGameplayCamCoord() + local scale = 200 / (GetGameplayCamFov() * #(camCoords - coords)) + if onScreen then + SetTextScale(1.0, 0.5 * scale) + SetTextFont(4) + SetTextColour(255, 255, 255, 255) + SetTextEdge(2, 0, 0, 0, 150) + SetTextProportional(1) + SetTextOutline() + SetTextCentre(1) + SetTextEntry("STRING") + AddTextComponentString(str) + DrawText(worldX, worldY) + end +end + +RegisterNetEvent('QBCore:Command:ShowMe3D', function(senderId, msg) + local sender = GetPlayerFromServerId(senderId) + CreateThread(function() + local displayTime = 5000 + GetGameTimer() + while displayTime > GetGameTimer() do + local targetPed = GetPlayerPed(sender) + local tCoords = GetEntityCoords(targetPed) + Draw3DText(tCoords, msg) + Wait(0) + end + end) +end) \ No newline at end of file diff --git a/server/commands.lua b/server/commands.lua index 4454484..1b637c0 100644 --- a/server/commands.lua +++ b/server/commands.lua @@ -188,15 +188,43 @@ QBCore.Commands.Add('ooc', 'OOC Chat Message', {}, false, function(source, args) local Player = QBCore.Functions.GetPlayer(src) for k, v in pairs(Players) do if v == src then - TriggerClientEvent('chat:addMessage', v, 'OOC ' .. GetPlayerName(src), 'normal', message) - elseif #(GetEntityCoords(GetPlayerPed(src)) - - GetEntityCoords(GetPlayerPed(v))) < 20.0 then - TriggerClientEvent('chat:addMessage', v, 'OOC ' .. GetPlayerName(src), 'normal', message) + TriggerClientEvent('chat:addMessage', v, { + color = { 0, 0, 255}, + multiline = true, + args = {'OOC | '.. GetPlayerName(src), message} + }) + elseif #(GetEntityCoords(GetPlayerPed(src)) - GetEntityCoords(GetPlayerPed(v))) < 20.0 then + TriggerClientEvent('chat:addMessage', v, { + color = { 0, 0, 255}, + multiline = true, + args = {'OOC | '.. GetPlayerName(src), message} + }) elseif QBCore.Functions.HasPermission(v, 'admin') then if QBCore.Functions.IsOptin(v) then - TriggerClientEvent('chat:addMessage', v, 'Proximity OOC ' .. GetPlayerName(src), 'normal', message) + TriggerClientEvent('chat:addMessage', v, { + color = { 0, 0, 255}, + multiline = true, + args = {'OOC | '.. GetPlayerName(src), message} + }) TriggerEvent('qb-log:server:CreateLog', 'ooc', 'OOC', 'white', '**' .. GetPlayerName(src) .. '** (CitizenID: ' .. Player.PlayerData.citizenid .. ' | ID: ' .. src .. ') **Message:** ' .. message, false) end end end +end, 'user') + +-- Me command + +QBCore.Commands.Add('me', 'Show local message', {name = 'message', help = 'Message to respond with'}, false, function(source, args) + local src = source + local ped = GetPlayerPed(src) + local pCoords = GetEntityCoords(ped) + local msg = table.concat(args, ' ') + if msg == '' then return end + for k,v in pairs(QBCore.Functions.GetPlayers()) do + local target = GetPlayerPed(v) + local tCoords = GetEntityCoords(target) + if #(pCoords - tCoords) < 20 then + TriggerClientEvent('QBCore:Command:ShowMe3D', v, src, msg) + end + end end, 'user') \ No newline at end of file diff --git a/server/functions.lua b/server/functions.lua index bd064be..be0509b 100644 --- a/server/functions.lua +++ b/server/functions.lua @@ -248,10 +248,8 @@ function QBCore.Functions.IsOptin(source) local src = source local license = QBCore.Functions.GetIdentifier(src, 'license') if QBCore.Functions.HasPermission(src, 'admin') then - retval = QBCore.Config.Server.PermissionList[license].optin - return retval + return QBCore.Config.Server.PermissionList[license].optin end - return false end function QBCore.Functions.ToggleOptin(source)