PtokaX forum

Development Section => Your Developing Problems => Topic started by: kepp on 13 November, 2003, 17:30:53

Title: Getting a nil value from AddRegUser(user)
Post by: kepp on 13 November, 2003, 17:30:53
elseif (cmd=="?addreg") or (cmd=="!addreg") or (cmd=="+addreg") then
s,e,cmd,newuser,pass = strfind(data,"%b<>%s+(%S+)%s+(%S+)%s+(.+)")

ProFile = GetProfileName(3)
AddRegUser(newuser, pass, 3)
if newuser ~= nil then
victim:SendPM(BotName, "\r\nYou are now Registered by: "..user.sName.." \r\nYour New Profile: "..ProFile.." \r\nYour password is set to: "..pass.." \r\n\r\nTo Activate your account please Reconnect! And don't forget your password :)")
user:SendData(BotName, "user : "..victim.sName.." Was sucessfully added as a Reg!") return 1
else
user:SendData(BotName, "User is not Online") return 1 end

The code above is just a part of my script..
Im getting a nil value IF the user is Not online when
doing this command.

I did try to change a little bit

elseif (cmd=="?addreg") or (cmd=="!addreg") or (cmd=="+addreg") then
s,e,cmd,newuser,pass = strfind(data,"%b<>%s+(%S+)%s+(%S+)%s+(.+)")

ProFile = GetProfileName(3)
AddRegUser(newuser, pass, 3)
if newuser ~= nil then
victim:SendPM(BotName, "\r\nYou are now Registered by: "..user.sName.." \r\nYour New Profile: "..ProFile.." \r\nYour password is set to: "..pass.." \r\n\r\nTo Activate your account please Reconnect! And don't forget your password :)")
user:SendData(BotName, "user : "..victim.sName.." Was sucessfully added as a Reg!") return 1
else
AddRegUser(newuser, pass, 3)
user:SendData(BotName, "User is not Online, But he/she was added with succes") return 1 end

However, i do belive this will return nil aswell...

Help me out and make comments on what you've changed!

Thanks

Title:
Post by: kepp on 13 November, 2003, 17:33:25
Or shall i remove the line SendPM
and don't use

if newuser ~= nil then ??
Title:
Post by: ((UKSN))shad_dow on 28 January, 2004, 20:54:01
hello :)

found u code other day so i had a play , basicly to learn lua and i modifed it to this


if (cmd == "!reg") then
s,e,cmd,newuser,pass = strfind(data,"%b<>%s+(%S+)%s+(%S+)%s+(.+)")

ProFile = GetProfileName(3)
AddRegUser(newuser, pass, 3)
user:SendPM(Bot, "\r\nYou are now Registered by: "..user.sName.." \r\nYour New Profile: "..ProFile.." \r\nYour password is set to: "..pass.." \r\n\r\nTo Activate your account please Reconnect! And don't forget your password :)")
else
if newuser ~= nil then
user:SendData(Bot, "User is not Online, But he/she was added with succes") return 1 end

end


use !reg

that was fun to play around with , :)
Title:
Post by: kepp on 28 January, 2004, 20:59:17
he he :)

I solved it along time ago... Keep going and have fun learning.. :)
Title:
Post by: NightLitch on 28 January, 2004, 21:05:11
well My guess is you get that nil value when you just type
the command right ???

you need to resolve the newuser if nilled.

ex:

if newuser == nil then
--more code

this is just hints. :-)
Title:
Post by: kepp on 28 January, 2004, 21:09:16
I suppose that was it... he he, I don't remember... :D
Title:
Post by: ((UKSN))shad_dow on 29 January, 2004, 00:30:31

if (cmd == "!reg") then
s,e,cmd,newuser,pass = strfind(data,"%b<>%s+(%S+)%s+(%S+)%s+(.+)")

ProFile = GetProfileName(3)
AddRegUser(newuser, pass, 3)
user:SendPM(Bot, "\r\nYou are now Registered by: "..user.sName.." \r\nYour New Profile: "..ProFile.." \r\nYour password is set to: "..pass.." \r\n\r\nTo Activate your account please Reconnect! And don't forget your password :)")
else
if newuser ~= nil then
user:SendData(Bot, "User is not Online, But he/she was added with succes") return 1 end

end


kepp and NightLitch

now i have a prob if i change
AddRegUser(newuser, pass, 3)  to DelRegUser(newuser)

like below


if (cmd == "!dereg") then
s,e,cmd,newuser,pass = strfind(data,"%b<>%s+(%S+)%s+(%S+)%s+(.+)")

ProFile = GetProfileName(3)
DelRegUser(newuser, 3)
user:SendPM(Bot, "\r\nYou are now de-Registered by: "..user.sName.." \r\")
else
if newuser ~= nil then
user:SendData(Bot, "User is not Online, But he/she was De-regged with succes")
 return 1
end

end



when i do the command nothing happends and ptokax reports no errors ????, am  i mising some thing or just not codeing up the right tree here ???
 ?(  ?(  ?(  ?(  ?(
Title:
Post by: kepp on 29 January, 2004, 07:16:20
well, In the manual it says "DelRegUser(NickName)"
You are sending
:D
Title:
Post by: pHaTTy on 29 January, 2004, 09:35:58
the original ~= is like if not user == nil