PtokaX forum

Lua 5.3/5.2/5.1 Scripts (for PtokaX 0.4.0.0 and newer) => Help with scripts => Topic started by: [NL]Daddy-Bear? on 02 March, 2008, 14:45:19

Title: What I am doing wrong?
Post by: [NL]Daddy-Bear? on 02 March, 2008, 14:45:19
Hello it?s me again.

What I doing wrong?  It?s a part of a script what I hope to finish.
Getting error on this line  >>>  name = Core.GetUser(nick,true)
If the rest is oke don?t know yet.
Please some one help me.   ???
function OnTimer(tmr)
TmrMan.RemoveTimer(tmr)
for i,v in pairs(Core.GetOnlineUsers(true)) do
local nick = ""
nick = v["sName"]
name = Core.GetUser(nick,true)
user = Core.GetUser(nick,true)
local shareMB = user.iShareSize / (1024^2) or 0
local shareGB = user.iShareSize / (1024^3) or 0
if name and DeKlos[user.iProfile] == 1 and shareGB < minshareReg then
sUser = Core.GetUser(nick,true)
local kunst = "\t"..string.rep("~",80).."\r\n"
local share = string.format(" %.2f MB ",shareMB)
local sharem = string.format(" %.2f GB ",shareGB)
        local Difference = minshareReg - shareGB
local txt = "\r\n\r\n"..kunst..""..
                        "\r\n\tYour current share of "..sharem.." does not meet our minimum of "..minshareReg.." GB  for Users."..   
"\r\n\r\n\tYou will have to increase your share with "..string.format(" %.2f ", Difference).."GB  to meet de min share of "..minshareReg.." GB  for Users in this Hub."..   
"\r\n\r\n\tPlease increase your share and return to this nice hub.\t\tYou get now a "..action.."."..
                        "\r\n\r\n"..kunst.."\r\n"
Core.SendToNick(user.sNick,"<"..sBot.."> "..txt)


Respectfully,

[NL]Daddy-Bear?
Title: Re: What I am doing wrong?
Post by: speedX on 02 March, 2008, 20:00:32
I think this line
Quote
nick = v["sName"]

Should be:
Quote
nick = v["sNick"]
Title: Re: What I am doing wrong?
Post by: [NL]Daddy-Bear? on 02 March, 2008, 22:35:01
Hello it?s me again.

;) ;) ;)  Thanks speedX for you reply.   ;) ;) ;)
What I doing wrong?  It?s a part of a script what I hope to finish.
Getting now error on this line  >>>  name = Core.GetUser(nick,true)
Px says ?bad argument #1 to 'GetUser' (string expected, got nil)?
I have copy now the whole part of the script up to end.    ???
function OnTimer(tmr)
TmrMan.RemoveTimer(tmr)
for i,v in pairs(Core.GetOnlineUsers(true)) do
local nick = ""
nick = v["snick"]  -- v["sName"]
name = Core.GetUser(nick,true)
user = Core.GetUser(nick,true)
local shareMB = user.iShareSize / (1024^2) or 0
local shareGB = user.iShareSize / (1024^3) or 0
if name and DeKlos[user.iProfile] == 1 and shareGB < minshareReg then
sUser = Core.GetUser(nick,true)
local kunst = "\t"..string.rep("~",80).."\r\n"
local share = string.format(" %.2f MB ",shareMB)
local sharem = string.format(" %.2f GB ",shareGB)
        local Difference = minshareReg - shareGB
local txt = "\r\n\r\n"..kunst..""..
                        "\r\n\tYour current share of "..sharem.." does not meet our minimum of "..minshareReg.." GB  for Users."..   
"\r\n\r\n\tYou will have to increase your share with "..string.format(" %.2f ", Difference).."GB  to meet de min share of "..minshareReg.." GB  for Users in this Hub."..   
"\r\n\r\n\tPlease increase your share and return to this nice hub.\t\tYou get now a "..action.."."..
                        "\r\n\r\n"..kunst.."\r\n"
Core.SendToNick(user.sNick,"<"..sBot.."> "..txt)
redictstart = redictstart + 1
memgebruik = collectgarbage(count)
local msg1="\r\n\r\n\t\t\t\t\t*Lua Aktie's*\r\n"
        msg1 = msg1.."\t================================================================================\r\n"
msg1 = msg1.."\t       User   "..user.sNick.."\t   Wass getting this action:    "..action.."\tTotal actions so far "..redictstart.."\r\n"
msg1 = msg1.."\t\t\t\tThe lua is started on "..opstart.."\r\n"
msg1 = msg1.."\t\t\t\tMemory use at this moment "..memgebruik.." Kb\r\n"
        msg1 = msg1.."\t================================================================================\r\n"
msg1=msg1.."\r\n"
k = k + 1
if k == kk then Core.SendPmToNick(Nick,bot,msg1)
-- SendPmToNick(Nick,bot,msg1)
-- SendPmToOps(bot,msg1)
if act == 1 then Core.TempBan(sUser,bantyd,"","",0) end
if act == 2 then snick:Redirect(redicthub) end
-- if act == 2 then sUser:Redirect(redicthub) end
if act == 3 then Core.Disconnect(sUser) end
if k == kk then k = 0 end
end
end
end
collectgarbage(collect)
tmr = TmrMan.AddTimer(Min*klik)
end


Respectfully,

[NL]Daddy-Bear?

Title: Re: What I am doing wrong?
Post by: [NL]Daddy-Bear? on 03 March, 2008, 14:45:04
Hello it?s me again.

Thanks Mutor for your reply.  ;) ;)
Its running better now, only this part still does end work get no actions taken on user.
Note: no errors from Px.

if act == 1 then Core.TempBan(sUser,bantyd,"","",0) end
if act == 2 then snick:Redirect(redicthub) end
-- if act == 2 then sUser:Redirect(redicthub) end
if act == 3 then Core.Disconnect(nick) end
if k == kk then k = 0 end
end
end
end
collectgarbage(collect)
tmr = TmrMan.AddTimer(Min*klik)
end


Note >>  if act == 3 then Core.Disconnect(nick) end is Working
             if act == 2  gifs error     attempt to call method 'Redirect' (a nil value)

Respectfully,

[NL]Daddy-Bear?
Title: Re: What I am doing wrong?
Post by: speedX on 03 March, 2008, 16:45:23
Its BanMan.TempBan and not Core.TempBan
Also it is Core.Redirect and not user:Redirect

You are still using old API codes, for more info please read the new scripting-interface of 0.4.0.0
Title: Re: What I am doing wrong?
Post by: [NL]Daddy-Bear? on 03 March, 2008, 18:40:56
Hello it?s me again.

speedX  first    ???????????? Lets enjoy our Hobby ??????????  !!!!!!   ;)
Commands works not for me try them all in the script Px don?t like it.
And where can the new scripting-interface of 0.4.0.0 be found?

Respectfully,

[NL]Daddy-Bear?
Title: Re: What I am doing wrong?
Post by: Tw?sT?d-d?v on 03 March, 2008, 21:34:14
In the Scripting.docs folder that comes with PtokaX
Title: Re: What I am doing wrong?
Post by: [NL]Daddy-Bear? on 04 March, 2008, 15:55:01
Hello it?s me again.

Thanks Tw?sT?d-d?v?l  for your reply.   :)
That was just what I needed.
Lua is running now. After test period shall I post it in Finished Scripts section.  ;D

Thanks all for reply and your help.

Respectfully,

[NL]Daddy-Bear?
Title: Re: What I am doing wrong?
Post by: [NL]Daddy-Bear? on 15 March, 2008, 14:06:57
Hello it?s me again.

After test period I shall post it in Finished Scripts section.
http://board.ptokax.ath.cx/index.php?topic=7671.0
Done.

Respectfully,

[NL]Daddy-Bear?