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
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"
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.
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.