Jump to content

split problem


Recommended Posts

I want to make if player types a command like /givecar 255 255 255 to add arguments but not only for givecar but for all command even if command does not have arguments

if (string.find(guiGetText(chatLabel), "/")) then 
            local cleanCommand = string.gsub(guiGetText(chatLabel), "/", "") 
            local param1, param2, param3, param4 = false 
                if string.find(guiGetText(chatLabel), " ") then 
                param1, param2, param3, param4 = split(cleanCommand, " ") 
                end 
                triggerServerEvent("executeCommand", localPlayer, cleanCommand, param1, param2, param3, param4) 

Execute like this:

executeCommandHandler(command, source, p1, p2, p3, p4) 

Link to comment
if ( string.find ( guiGetText ( chatLabel ), "/" ) ) then 
    local cleanCommand = string.gsub ( guiGetText ( chatLabel ), "/", "" ) 
    local params = { } 
    if string.find ( guiGetText ( chatLabel ), " " ) then 
        params = split ( cleanCommand, " " ) 
    end 
    triggerServerEvent ( "executeCommand", localPlayer, cleanCommand, unpack ( params ) ) 

Try that.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...