I tried to loop trough the args of a chat command, but my problem is, instead of adding the current arg to the string, it replaces it.
If I do the Command like this: /test 1 2 3
Using my code It should be in the chat like this:
1
1 2
1 2 3
but it looks like this:
1
2
3
This is my code:
what am I doing wrong?Code:local allArgs = "" local arg = args:GetEnumerator() while arg:MoveNext() do local allArgs = allArgs .. " " .. arg.Current rust.SendChatMessage(player, allArgs) end
The rust.SendChatMessage() is for debugging
Solved Looping through Args (LUA)
Discussion in 'Rust Development' started by LaserHydra, May 26, 2015.
-
You are initialising a new allArgs variable in every loop.
-
local allArgs = ""
is outside of the loop, isnt it? -
-
so thats what i basicly done. Whats wrong with that logic? -
Wulf Community Admin
Code:local allArgs ="" local arg = args:GetEnumerator() while arg:MoveNext()do allArgs = allArgs .." ".. arg.Current rust.SendChatMessage(player, allArgs) end
-
Does that really affect that? -
Wulf Community Admin
-
-
Wulf Community Admin
-