Forum

> > CS2D > Scripts > Spaces Errors
Forums overviewCS2D overview Scripts overviewLog in to reply

English Spaces Errors

1 reply
To the start Previous 1 Next To the start

old Spaces Errors

xNir
User Off Offline

Quote
Hi everyone, does anyone know how to fix this issue ?
When I open the console in my server and I type this:
1
lua print('hello')


Everything is fine but when I try this:
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:
1
lua print('hello..string.char(32)..'world')

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

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
1
ERROR: Unknown command 'has")' (lua infoMessage(2,"Someone has"))

Thanks for your answers

old Re: Spaces Errors

EngiN33R
Moderator Off Offline

Quote
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:
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.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview