• Help fixing an error. attempt to call a number value
    8 replies, posted
I'm getting an error. [CODE][ERROR] addons/dlist/lua/autorun/init.lua:21 attempt to call a number value[/CODE] This is a portion of my init.lua [LUA]net.Receive ("physgundisablebutton", function() local ply = net.ReadEntity() local num = net.ReadFloat()*60*60 ply:SetNWFloat("physguninput", num) ply:SetNWBool( "physgundisable", true ) hook.Add("PlayerDisconnected", "saveprogress", function() if ply:GetNWBool("physgundisable") == true then file.Append( "d5q7g68w2t74.txt", "local " .. ply:SteamID().. "table = {playersteamid = " .. ply:SteamID() .. ", currenttime = ".. ply:GetUTimeTotalTime() .. ", targettime = " .. ply:GetUTimeTotalTime() + ply:GetNWFloat("physguninput")"} " ) ply:SetNWBool("physgundisable", false) end end) hook.Add("ShutDown", "saveprogress", function() if ply:GetNWBool("physgundisable") == true and ply:IsValid() then file.Append( "d5q7g68w2t74.txt", "local " .. ply:SteamID().. "table = {playersteamid = " .. ply:SteamID() .. ", currenttime = ".. ply:GetUTimeTotalTime() .. ", targettime = " .. ly:GetUTimeTotalTime() + ply:GetNWFloat("physguninput")"} " ) ply:SetNWBool("physgundisable", false) end end) end)[/LUA]
Which line is line 21
Its the first file.append line, but there will be the same problem with the other file.append line too
Try converting the text you are appending to a string by putting it inside tostring()
You shouldn't store files like Lua. Making a SteamID a variable is a weird format: just store the data in either JSON or plain, sequenced numbers.
Tried your way peppers and it didn't work just said the same thing but attempt to call a string.
problem is [lua]ply:GetNWFloat("physguninput")"} "[/lua] you forgot .. so it's trying to pass "} " as an argument and call it as a function also, advice, follow what code_gs said and look into string.format
Thank you that worked. But I have another question. How would I go about doing code_gs's way?
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/util/TableToJSON]util.TableToJSON[/url] for save to file and [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/util/JSONToTable]util.JSONToTable[/url] for reading
Sorry, you need to Log In to post a reply to this thread.