Passing info from lua to javascript


#1

what do I do on the javascript side to make args[1] work?

RegisterCommand('cash', function(source, args, rawCommand)
    SendNUIMessage({
        test = args[1]
    })
end)

i am trying to set it so when someone does /cash 100 it will say 100 in here https://gyazo.com/3c8f2c22d70fe3d757991b0af2487b22

(NOT ESX, DONT SPAM)


#2

So when you’re passing that NUIMessage, the Javascript should be something like

variable ABC123Whatever = event.data.test

So you’d set that datatype to whatever HTML you have set up. You should be able to get an idea of what I’m saying from the link I posted above. If for some reason it’s just the args[1] that isnt working you could do this. But I don’t see why you would.

RegisterCommand('cash', function(source, args, rawCommand)
local cash = args[1]
    SendNUIMessage({
        test = cash
    })
end)

#3

i thougt i tried that but thanks will check it.


#4

Is the javascript listening for the event.data? Like uh

window.addEventListener 

#5

it worked with the first comment thanks


#6

Awesome.

inset 20 char here