Scripting Help


Hello all, I am new to scripting for Five M. Im looking to make a /ooc script so when someone types /ooc (message) it well send through as a ooc through the console in the game and show out of character, or ooc.

~ Thanks MLG


Alright so, show us what you have tried already?
This is ‘Scripting Help’, not 'write this script for me thx.


if player types /ooc
then “Out of Character” appears


That’s some solid scripting. I mean, the logic works.

RegisterCommand("ooc", function(source, args, raw)
     msg = stringsplit(raw, " ");
     pedName = tostring(GetPlayerName(source))
     TriggerClientEvent('chatMessage', -1, "Out of Character - " .. pedName, { 255, 255, 255 }, string.sub(msg,5))
end, false)

function stringsplit(inputstr, sep)
    if sep == nil then
        sep = "%s"
    local t={} ; i=1
    for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
        t[i] = str
        i = i + 1
    return t

Made at 1:40 am, based off

If this does not work, use that one.


why not

msg = table.concat(args, " ")

Instead of having to include a stringsplit and doing a string.sub which will fuck up when the command gets renamed for some reason.


Idk, I’m just doing what I would try. Maybe that’s a better method, idk /shrug


maybe ask in server development, this is the FiveM Discussion board.