English Spaces Errors

1 reply
Goto Page
To the start Previous 1 Next To the start
21.02.16 01:16:07 pm
Up
xNir
User
Offline Off
Hi everyone, does anyone know how to fix this issue ?
When I open the console in my server and I type this:
Code:
1
lua print('hello')


Everything is fine but when I try this:
Code:
1
lua print('hello world')


I've got this error:
ERROR: Unknown command 'world')' (lua print('hello world'))

So I've managed to find this solution:
Code:
1
lua print('hello..string.char(32)..'world')


Then I wanted to implement this in a custom function which is called from a timer:

Code:
1
2
3
4
5
6
7
function infoMessage(id, message)
     msg2(id, string.char(169).."255255255[INFO]: "..message);
end

local releaseString = "Someone"..string.char(32).."has";

timer(JAIL_DURATION * 1000, "parse", 'lua infoMessage('..id..',"'..releaseString..'")');


And I still got the previous error
Code:
1
ERROR: Unknown command 'has")' (lua infoMessage(2,"Someone has"))


Thanks for your answers
21.02.16 01:21:17 pm
Up
EngiN33R
Moderator
Offline Off
The CS2D command cs2d cmd lua takes one string as an argument. If there is a space after the first contiguous string, it tries to interpret the things that follow as arguments, but, since cs2d cmd lua takes only one argument, it interprets them as separate new commands.

To fix this, simply surround your Lua expression with "" in the console:
Code:
1
lua "print('hello world!')"


Please note that if you do this, you will not be able to use double quotes in your Lua code since it will break as soon as it's parsed by the console.
I code, therefore I exist. | Visit my blog for Lua tips and other interesting info
To the start Previous 1 Next To the start