A boolean value
6 replies



21.08.14 03:05:02 pm
Hey, I'm currently working on a script and I've gotten an error I can't solve (btw, I'm currently learning lua so please skip the "lol this is so easy" comments, ty). It would be great if someone could help me.
The error:
It gets affected whenever I use the mute and speclock command. The mute and speclock doesn't get removed after the specified time, it stays forever.
Line 56 from table.lua:
Mute and speclock commands + when they are supossed to end (not on same lua):
If anyone has any ideas on what to do, please tell me.
Thanks.
The error:
Code:
1
LUA ERROR: sys/lua/serverfiles/table.lua:56: attempt to concatenate local 'Value' (a boolean value)
It gets affected whenever I use the mute and speclock command. The mute and speclock doesn't get removed after the specified time, it stays forever.
Line 56 from table.lua:
Mute and speclock commands + when they are supossed to end (not on same lua):
If anyone has any ideas on what to do, please tell me.
Thanks.
One of your tables keys holds a boolean - specifically User[id]["muted"] and User[id]["speclock"] for each id. Lua won't concatenate booleans (won't turn true or false into strings), and returns an error.
Another error is that your table won't print keys that hold a false, because the and operator checks whether Value exists and is not false.
To fix this, store booleans as a 1 and 0, and not as a boolean true and false.
----
Alternatively you could do the following;
Another error is that your table won't print keys that hold a false, because the and operator checks whether Value exists and is not false.
To fix this, store booleans as a 1 and 0, and not as a boolean true and false.
Code:
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
User[id]["muted"] = true
User[id]["speclock"] = true
User[id]["muted"] = false
User[id]["speclock"] = false
--to
User[id]["muted"] = 1
User[id]["speclock"] = 1
User[id]["muted"] = 0
User[id]["speclock"] = 0
User[id]["speclock"] = true
User[id]["muted"] = false
User[id]["speclock"] = false
--to
User[id]["muted"] = 1
User[id]["speclock"] = 1
User[id]["muted"] = 0
User[id]["speclock"] = 0
----
Alternatively you could do the following;
Code:
1
2
3
4
5
2
3
4
5
table.insert( result, Key .. "=" .. Value ) --Line 56
--to
table.insert( result, tostring( Key ) .. "=" .. tostring( Value ) ) --Line 56
--to
table.insert( result, tostring( Key ) .. "=" .. tostring( Value ) ) --Line 56
That bug seems to be gone now, but now I can't use any command that has a level restriction, this one:
The error is:
What causes this?
Code:
1
if PlayerLevel(id) >= 15 then
The error is:
Code:
1
LUA ERROR: sys/lua/RDAdministrationScript.lua:105: attempt to compare number with string
What causes this?
Check if the script makes sense, whether it should always return a number. If it doesn't always return a number, change return * to return tonumber( * ) to make sure it's always a number.
As you should always do with these kinds of errors, try to print( tostring( PlayerLevel( id ) ) ) to see if it's actually a number. Also try to find out whether PlayerLevel( id ) is ever not a number, with print( tonumber( PlayerLevel( id ) ) and "Number" or "Not a number" ). Basic bugfixing.
As you should always do with these kinds of errors, try to print( tostring( PlayerLevel( id ) ) ) to see if it's actually a number. Also try to find out whether PlayerLevel( id ) is ever not a number, with print( tonumber( PlayerLevel( id ) ) and "Number" or "Not a number" ). Basic bugfixing.
I tried checking with both print( tostring( PlayerLevel( id ) ) ) and print( tonumber( PlayerLevel( id ) ) and "Number" or "Not a number" ). All I get is this error:
I tried adding PlayerLevel = {} and PlayerLevel(id) = {} to the script but it didn't help.
Code:
1
LUA ERROR: sys/lua/RDAdministrationScript.lua:1: attempt to call global 'PlayerLevel' (a nil value)
I tried adding PlayerLevel = {} and PlayerLevel(id) = {} to the script but it didn't help.
You shouldn't call a function before you declared it. Try again, and at the right line.
(sys/lua/RDAdministrationScript.lua:105)
(sys/lua/RDAdministrationScript.lua:105)
Oh, I thought that it didn't matter. Well, I got the same old error in the console, so I added return tonumber in the PlayerLevel(id) function and the commands now work, but the tag is always activated for some reason, don't know why.
I also got a new error:
Line:
I tried adding UserData["TRANKTIME"] = 0 and UserData["TRANK"] = 0 but it didn't fix it.
What kind of sorcery is this? I fix a bug, two more are created.
I also got a new error:
Code:
1
LUA ERROR: sys/lua/RDAdministrationScript.lua:8: attempt to index field '?' (a nil value)
Line:
I tried adding UserData["TRANKTIME"] = 0 and UserData["TRANK"] = 0 but it didn't fix it.
What kind of sorcery is this? I fix a bug, two more are created.



