PtokaX forum

Development Section => Your Developing Problems => Topic started by: Themaster on 30 December, 2004, 12:48:02

Title: Got a error on time
Post by: Themaster on 30 December, 2004, 12:48:02
Hello ppl

I just got this HubTime-V.1.63.lua script...and i got a error on 1 thin

elseif cmd == "+myhubtime" then
local tmp = UserHubTime[user.sName]
local months, days, hours, minutes = floor(tmp/43200), floor(mod(tmp/1440, 30)), floor(mod(tmp/60, 24)), floor(mod(tmp/1, 60))
user:SendData(Bot, "You have been online : "..months.." months, "..days.." days, "..hours.." hours, "..minutes.." minutes ( "..tmp.." min ). That is "..format("%.2f",tmp/UserHubTime["HubUpTime"]*100).." % of the total HubUpTime.")
return 1

the error
Syntax error: attempt to perform arithmetic on local `tmp' (a nil value)
stack traceback:
   1:  function `UserCommands' at line 237 [file `...ettings\scripts\Blade1.5.lua']
   2:  function `DataArrival' at line 91 [file `...ettings\scripts\Blade1.5.lua']


i can't get it right...the other 2 function's work ass it shoot
Title:
Post by: [_XStaTiC_] on 30 December, 2004, 13:12:34
try this :)
elseif cmd == "+myhubtime" then
local tmp = UserHubTime[user.sName]
                        if tmp then
local months, days, hours, minutes = floor(tmp/43200), floor(mod(tmp/1440, 30)), floor(mod(tmp/60, 24)), floor(mod(tmp/1, 60))
user:SendData(Bot, "You have been online : "..months.." months, "..days.." days, "..hours.." hours, "..minutes.." minutes ( "..tmp.." min ). That is "..format("%.2f",tmp/UserHubTime["HubUpTime"]*100).." % of the total HubUpTime.")          
                        end
return 1
Title:
Post by: Optimus on 30 December, 2004, 13:42:05
yups i think that should do it
Title:
Post by: Themaster on 30 December, 2004, 16:40:12
thx...that work :)
Title:
Post by: Themaster on 31 December, 2004, 00:20:15
I Still got the bug on my time function i do have try many thing .....plz help now i'm so sad now

Error
Syntax error: bad argument #1 to `write' (string expected, got nil)
stack traceback:
   1:  function `write' [C]
   2:  function `WriteFile' at line 478 [file `...s\den lille\Blade1.5.lua']
   3:  function `OnTimer' at line 47 [file `...s\den lille\Blade1.5.lua']

Script
function WriteFile(table, tablename, file)
local handle = openfile("txt/"..file, "w")
write(handle, tablename.." = {\n" )
for key, value in table do
if value >= Max2 then
[COLOR=red]write(handle, "\t"..format("[%q]",key).." = "..value..",\n")[/COLOR] end
end
write(handle, "}");
  closefile(handle)
end

and

function OnTimer()
for i,v in UserHubTime do
if GetItemByName(i) or i=="HubUpTime" then
v=v+1
UserHubTime[i]=v
end
end
var1 = var1 + 1
if var1 == Max1 then
[COLOR=red]WriteFile(UserHubTime, "UserHubTime", File1)[/COLOR]
var1 = 0
end
   clear()
end
and also that function here i got
File1 = "Blade/txt/UserHubTime.txt"
Title:
Post by: [_XStaTiC_] on 31 December, 2004, 01:39:48
try this :)

function WriteFile(table, tablename, file)
local handle = openfile(file, "w")
write(handle, tablename.." = {\n" )
for key, value in table do
if value >= Max2 then
write(handle, "\t"..format("[%q]",key).." = "..value..",\n")
end
end
write(handle, "}");
  closefile(handle)
end
Title:
Post by: Themaster on 31 December, 2004, 10:54:40
Thx again...It just work ass it shoot....

And HAPPY NEW YEAR !!!!!!!!!!!!

PARTY ON !!!!!!!!