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.

2 Likes

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

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

1 Like
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"
    end
    local t={} ; i=1
    for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
        t[i] = str
        i = i + 1
    end
    return t
end

Made at 1:40 am, based off https://github.com/fuzzymannerz/ooc/blob/master/server.lua

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.

2 Likes

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.