Does anyone know why args dont work?

elseif args[1]=="create" and args[2]==nil and open_assists[source] and active_assists[source] then TriggerClientEvent("chat:addMessage",source,{color={255,0,0},multiline=false,args={"Someone is already helping your or you already have a pending assist report"}})

What I’m trying to do is create a command called request that has 3 args (request create reason) all works but the reason. How can i make a 3rd arg that lets the player input what he wants and in an if statement have it set to if reason has something it will go through.

1 Like

Print args to the console, I’m not sure but I believe args[1] is command’s name

1 Like
TriggerEvent('es:addCommand', 'request', function(source, args, user)
    local xPlayer = ESX.GetPlayerFromId(source)
    local target = tonumber(args[2])
	local found = false
	local reason = tonumber(args[2]) -- how to make this work?
    if reason=="" 

What I’m trying to do is create a command called request that has 3 args (request create reason) all works but the reason. How can i make a 3rd arg that lets the player input what he wants and in an if statement have it set to if reason has something it will go through.

1 Like

You have to join args after X positions so all arguments after X will be counted as one

2 Likes

could you give a demonstration or reference on how to do that?

table.remove( args, 1 ) -- Remove first arg which is command
table.concat( args, " " ) -- Then concatenate every args separated by a space :D

I believe you can also use the third parameter (raw) as the full argument string, maybe you need to remove some characters because the command name might be in it as well!

This is the start but the args is not correctly defined. how could this be fixed. I’m sorry for asking to many questions.

local message = table.concat( args, " " )
 if message=="" or not message

Could you print( args ) after you concatenate them?