/everything [RegisterCommand]

Since I see a lot of / chat cmds are still using the stringsplit I thought I should just post a more updated code for the same purpose.

RegisterCommand('nameThatYouWant', function(source, args, rawCommand)
    local name = GetPlayerName(source) --Gets the player name, so the name of the player who did the cmds
    local message = table.concat(args, ' ') -- this makes the string undefined
        TriggerClientEvent('chatMessage', -1, 'Twitter' ..name, {255,0,0}, message) --I used twitter as an example
end) --If you add true or false like this: end, false or true) you are telling it to either do not use ace perms or do

I hope this was helpful :slight_smile:

3 Likes

Isn’t this already explained here: http://docs.fivem.net/scripting/#expanding-on-this?

Doesnt really make sense

well, all i mean is that the string isnt set, so what ever you want to type comes in the table.concat(args, ’ ')

you are literally just making it put a space inbetween every arg, its pretty much the same as doing this manually:

args[1].." "..args[2].." "..args[3]

i was just showing the basic way to do it without using the stringsplit, but if its so bad, then you guys can take it down

Im not saying its bad, its probably one of the best ways to go about this, its just your comment on it seems a bit inaccurate