Forum

> > CS2D > Scripts > Spaces Errors
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Spaces Errors

1 Antwort
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Spaces Errors

xNir
User Off Offline

Zitieren
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

alt Re: Spaces Errors

EngiN33R
Moderator Off Offline

Zitieren
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.
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht