I can't use print in command functions (server side qbcore)

Hi, I have a problem with commands.
I use QBCore Framework on my server, and when I add new command in qb-smallresources main.lua, like this:

QBCore.Commands.Add("testcmdd", "Test", {}, false, function(source)
    print("Test command")
end, "user")

Function print() don’t work, anybody knows why?

Where are you checking for it to print? I dont believe it will print in f8, but it’ll print in the picture below

1 Like

I check console for print, because command is on server side, but I don’t get any error, info, nothing. When I execute command (on client side) is working (I use event for notification to check is command works at all), but function “print()” don’t work, it doesn’t print anything in console. This look like function “print()” has been skipped when command code be executed.

Im going to assume its something to do with the QBCore.Commands.Add ? are u sure thats how u correctly add a command on QBCore?

1 Like

Yes, I’m sure.
image
This screenshot will show how i add command using QBCore Framework.
Screen from F8 console after using command:


And I know that command work, becouse on chat i got message:
image

And last screenshot of server console without the “print()” message :confused:
image

Not the best solution, but try putting it in a new thread:

CreateThread(function()
print('TEST MESSAGE')
end)
1 Like

Using print in CreateThread is working, but in my server function “print()” doesnt work in commands.
I tried to create command by QBCore Framework and next using “RegisterCommand” and twice of this, function “print()” has been skip, something like this.
I tried to make other function with print, and then execute but dont work.
I tried to made an event and call to him, but dont work. (I try only server event, i dont tried using client event and then print, becouse i need working print in server side)

works perfect for me,

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.