Hello, im trying to create a script, where the ooc chat is sent to players near me.
AddEventHandler('chatMessage', function(source, name, msg)
sm = stringsplit(msg, " ");
if string.find(sm[1], "/") then return end
CancelEvent()
local playerPed = PlayerPedId()
local playerPos = GetEntityCoords(playerPed)
local targetPos = GetEntityCoords(ped)
local dist = #(playerPos - targetPos)
if dist <= 20 then
TriggerClientEvent('chat:addMessage', -1, {
color = { 255, 255, 255 },
multiline = true,
--args = { text}
template = '<div style="padding: 0.35vw; margin: 0; background-color: rgba(0, 0, 0, 0.6); border-radius: 5px;"><i class="fas fa-user-crown"></i> {0} </div>',
args = { "> ^5ooc^7 | " .. name .. " [" .. source .. "] : " .. string.sub(msg,1) }
})
end
end)
function stringsplit(inputstr, sep)
if sep == nil then
sep = "%s"
end
local t={} ; i=1
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
t[i] = str
i = i + 1
end
return t
end
This is the whole script, but the problem is that i get an error:
Anyone have an idea how to make this work? Thank you!