Fix /ooc & add /me

This commit is contained in:
Kakarot
2021-11-01 00:44:38 -06:00
parent 5c68989836
commit 8a19f0163d
3 changed files with 67 additions and 8 deletions
+33
View File
@@ -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)
+33 -5
View File
@@ -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')
+1 -3
View File
@@ -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)