Scripting Help


#1

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


#2

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


#3

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


#4

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


#5
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.


#6

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.


#7

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


#8

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