error regbot
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

error regbot

Started by gizmo, 08 February, 2004, 21:31:38

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

gizmo

can someone please tell me wht this error mean when i drive this script =(


Syntax error: attempt to call field `AddRegUser' (a nil value)
stack traceback:
   1:  function `RegUser' at line 52 [file `...lone grejer1\Potax clone 4\scripts\regboten.lua']
   2:  function `DataArrival' at line 97 [file `...lone grejer1\Potax clone 4\scripts\regboten.lua


botname = "Regbot"
kb = 1024
mb = kb*kb
gb = kb*kb*kb
tb = kb*kb*kb*kb
pb = kb*kb*kb*kb*kb
bot_name = "Regbot"
bot_email = "here@hub"
bot_speed = "T3"
bot_descr = "[Imperial]"
bot_share_size = 0 * mb


function Main()
frmHub:RegBot(botname)
end

function NewUserConnected(curUser)
curUser:SendData( my_info_string )

end

function OpConnected(curUser)
curUser:SendData( my_info_string )

end

hubaddress="clone4.myftp.org"


-------------------------------------------------------------------------
--DO NOT EDIT BELOW THIS TEXT!
-------------------------------------------------------------------------

function Get1Arg(data)
s,e,cmd,arg = strfind( data, "%b<>%s+(%S+)%s+(%S+)" )
return arg
end

function Get2Arg(data)
s,e,cmd,arg,arg2 = strfind( data, "%b<>%s+(%S+)%s+(%S+)%s+(.+)" )
return arg, arg2
end

function RegUser(user,data)
Get1Arg(data)
if arg==nil then
user:SendPM(botname, "You have to provide a password!")
end
if not arg==nil then
if not user.bOperator then
frmHub:AddRegUser(user.sName, arg, "0")
user:SendPM(botname, "You are now registered at "..frmHub:GetHubName().."!")
user:SendPM(botname, "Add this hub to your favourites (if you haven?t done so already),")
user:SendPM(botname, "and be sure to write down your account-information and password:")
user:SendPM(botname, "HubName:\t"..frmHub:GetHubName().." Address:\t"..hubaddress.."")
user:SendPM(botname, "Your Nick:\t"..user.sName.."")
user:SendPM(botname, "Your Password:\t"..arg.."")
end
if user.bOperator then
user:SendPM(botname, "Feel the need to deop yourself? ;)")
user:SendPM(botname, "If you want to register a useraccount use < +newuser Name Pwd >")
end
end
end


function DataArrival(user, data)
data=strsub(data,1,strlen(data)-1)
if ( strsub(data, 1, 1) == "<" ) then
s,e,cmd = strfind(data,"%b<>%s+(%S+)")
if not cmd==nil then
if (cmd=="+regme") then
user:SendPM(botname,"It is not wise to display your password in the mainchat!")
user:SendPM(botname,"Send a pm to me and try again. ")
return 1
end
if (cmd=="+reg") or (cmd=="+reghelp") then
user:SendPM(botname,"Yes! It?s true! Now you can register an account with us!")
user:SendPM(botname,"To register:")
user:SendPM(botname,"Send a pm to "..botname.." and type < +regme ThePasswordYouWant >. Done!")
end
end
end


if ( strsub(data, 1, 5) == "$To: " ) then
s,e,whoTo,from=strfind(data, "$To:%s+(%S+)%s+From:%s+(%S+)")
if whoTo==botname then
s,e,cmd = strfind(data,"%b<>%s+(%S+)")
if (cmd=="+reg") or (cmd=="+reghelp") then
user:SendPM(botname,"Yes! It?s true! Now you can register an account with us!")
user:SendPM(botname,"To register:")
user:SendPM(botname,"Send a pm to "..botname.." and type < +regme ThePasswordYouWant >. Done!")
end
if (cmd=="+regme") then
RegUser(user,data)
end
if user.bOperator then
if (cmd=="+reguser") then
Get2Arg(data)
frmHub:AddRegUser(arg,arg2,"0")
user:SendPM(botname, "As you wish my master!")
user:SendPM(botname, "The user "..arg.." with the password "..arg2.." is now")
user:SendPM(botname, "registered at "..frmHub:GetHubName().." / "..hubaddress.."")
end
end
end
end
end








nErBoS

Hi,

Try this..

botname = "Regbot" 
kb = 1024 
mb = kb*kb 
gb = kb*kb*kb 
tb = kb*kb*kb*kb 
pb = kb*kb*kb*kb*kb 
bot_name = "Regbot" 
bot_email = "here@hub" 
bot_speed = "T3" 
bot_descr = "[Imperial]" 
bot_share_size = 0 * mb 


function Main() 
frmHub:RegBot(botname) 
end 

function NewUserConnected(curUser) 
curUser:SendData( my_info_string ) 

end 

function OpConnected(curUser) 
curUser:SendData( my_info_string ) 

end 

hubaddress="clone4.myftp.org" 


------------------------------------------------------------------------- 
--DO NOT EDIT BELOW THIS TEXT! 
------------------------------------------------------------------------- 

function Get1Arg(data) 
s,e,cmd,arg = strfind( data, "%b<>%s+(%S+)%s+(%S+)" ) 
return arg 
end 

function Get2Arg(data) 
s,e,cmd,arg,arg2 = strfind( data, "%b<>%s+(%S+)%s+(%S+)%s+(.+)" ) 
return arg, arg2 
end 

function RegUser(user,data) 
Get1Arg(data) 
if arg==nil then 
user:SendPM(botname, "You have to provide a password!") 
end 
if not arg==nil then 
if not user.bOperator then 
AddRegUser(user.sName, arg, "0") --edit
user:SendPM(botname, "You are now registered at "..frmHub:GetHubName().."!") 
user:SendPM(botname, "Add this hub to your favourites (if you haven?t done so already),") 
user:SendPM(botname, "and be sure to write down your account-information and password:") 
user:SendPM(botname, "HubName:\t"..frmHub:GetHubName().." Address:\t"..hubaddress.."") 
user:SendPM(botname, "Your Nick:\t"..user.sName.."") 
user:SendPM(botname, "Your Password:\t"..arg.."") 
end 
if user.bOperator then 
user:SendPM(botname, "Feel the need to deop yourself? ;)") 
user:SendPM(botname, "If you want to register a useraccount use < +newuser Name Pwd >") 
end 
end 
end 


function DataArrival(user, data) 
data=strsub(data,1,strlen(data)-1) 
if ( strsub(data, 1, 1) == "<" ) then 
s,e,cmd = strfind(data,"%b<>%s+(%S+)") 
if not cmd==nil then 
if (cmd=="+regme") then 
user:SendPM(botname,"It is not wise to display your password in the mainchat!") 
user:SendPM(botname,"Send a pm to me and try again. ") 
return 1 
end 
if (cmd=="+reg") or (cmd=="+reghelp") then 
user:SendPM(botname,"Yes! It?s true! Now you can register an account with us!") 
user:SendPM(botname,"To register:") 
user:SendPM(botname,"Send a pm to "..botname.." and type < +regme ThePasswordYouWant >. Done!") 
end 
end 
end 


if ( strsub(data, 1, 5) == "$To: " ) then 
s,e,whoTo,from=strfind(data, "$To:%s+(%S+)%s+From:%s+(%S+)") 
if whoTo==botname then 
s,e,cmd = strfind(data,"%b<>%s+(%S+)") 
if (cmd=="+reg") or (cmd=="+reghelp") then 
user:SendPM(botname,"Yes! It?s true! Now you can register an account with us!") 
user:SendPM(botname,"To register:") 
user:SendPM(botname,"Send a pm to "..botname.." and type < +regme ThePasswordYouWant >. Done!") 
end 
if (cmd=="+regme") then 
RegUser(user,data) 
end 
if user.bOperator then 
if (cmd=="+reguser") then 
Get2Arg(data) 
AddRegUser(arg,arg2,"0") --edit
user:SendPM(botname, "As you wish my master!") 
user:SendPM(botname, "The user "..arg.." with the password "..arg2.." is now") 
user:SendPM(botname, "registered at "..frmHub:GetHubName().." / "..hubaddress.."") 
end 
end 
end 
end 
end

It works with me !!

Best regards, nErBoS
--## nErBoS Spot ##--

Snooze

Any chance of adding these commands to this script:


+userpassword
-diplays a regged users password.

+changeuserpassword
 changes a regged users password.

nErBoS

Hi,

Made only the changepass...

botname = "Regbot" 
kb = 1024 
mb = kb*kb 
gb = kb*kb*kb 
tb = kb*kb*kb*kb 
pb = kb*kb*kb*kb*kb 
bot_name = "Regbot" 
bot_email = "here@hub" 
bot_speed = "T3" 
bot_descr = "[Imperial]" 
bot_share_size = 0 * mb 


function Main() 
frmHub:RegBot(botname) 
end 

function NewUserConnected(curUser) 
curUser:SendData( my_info_string ) 

end 

function OpConnected(curUser) 
curUser:SendData( my_info_string ) 

end 

hubaddress="clone4.myftp.org" 


------------------------------------------------------------------------- 
--DO NOT EDIT BELOW THIS TEXT! 
------------------------------------------------------------------------- 

function Get1Arg(data) 
s,e,cmd,arg = strfind( data, "%b<>%s+(%S+)%s+(%S+)" ) 
return arg 
end 

function Get2Arg(data) 
s,e,cmd,arg,arg2 = strfind( data, "%b<>%s+(%S+)%s+(%S+)%s+(.+)" ) 
return arg, arg2 
end 

function ChangePass(user, data)
Get2Arg(data) 
if (arg == nil or arg2 == nil) then
	user:SendPM(botname, "Syntax error, +changeuserpassword  , musdt have a nick and a new pass.")
else
	if (DelRegUser(arg) == -1) then
		user:SendPM(botname, "The user "..arg.." is not registerd in the Hub.")
	else
		DelRegUser(arg)
		AddRegUser(arg, arg2, "0")
		user:SendPM(botname, "The user "..arg.." has been register with a new pass: "..arg2)
	end
end
end

function RegUser(user,data) 
Get1Arg(data) 
if arg==nil then 
user:SendPM(botname, "You have to provide a password!") 
end 
if not arg==nil then 
if not user.bOperator then 
AddRegUser(user.sName, arg, "0") --edit
user:SendPM(botname, "You are now registered at "..frmHub:GetHubName().."!") 
user:SendPM(botname, "Add this hub to your favourites (if you haven?t done so already),") 
user:SendPM(botname, "and be sure to write down your account-information and password:") 
user:SendPM(botname, "HubName:\t"..frmHub:GetHubName().." Address:\t"..hubaddress.."") 
user:SendPM(botname, "Your Nick:\t"..user.sName.."") 
user:SendPM(botname, "Your Password:\t"..arg.."") 
end 
if user.bOperator then 
user:SendPM(botname, "Feel the need to deop yourself? ;)") 
user:SendPM(botname, "If you want to register a useraccount use < +newuser Name Pwd >") 
end 
end 
end 


function DataArrival(user, data) 
data=strsub(data,1,strlen(data)-1) 
if ( strsub(data, 1, 1) == "<" ) then 
s,e,cmd = strfind(data,"%b<>%s+(%S+)") 
if not cmd==nil then 
if (cmd=="+regme") then 
user:SendPM(botname,"It is not wise to display your password in the mainchat!") 
user:SendPM(botname,"Send a pm to me and try again. ") 
return 1 
end 
if (cmd=="+reg") or (cmd=="+reghelp") then 
user:SendPM(botname,"Yes! It?s true! Now you can register an account with us!") 
user:SendPM(botname,"To register:") 
user:SendPM(botname,"Send a pm to "..botname.." and type < +regme ThePasswordYouWant >. Done!") 
end 
end 
end 


if ( strsub(data, 1, 5) == "$To: " ) then 
s,e,whoTo,from=strfind(data, "$To:%s+(%S+)%s+From:%s+(%S+)") 
if whoTo==botname then 
s,e,cmd = strfind(data,"%b<>%s+(%S+)") 
if (cmd=="+reg") or (cmd=="+reghelp") then 
user:SendPM(botname,"Yes! It?s true! Now you can register an account with us!") 
user:SendPM(botname,"To register:") 
user:SendPM(botname,"Send a pm to "..botname.." and type < +regme ThePasswordYouWant >. Done!") 
end 
if (cmd=="+regme") then 
RegUser(user,data) 
end 
if user.bOperator then 
if (cmd=="+reguser") then 
Get2Arg(data) 
AddRegUser(arg,arg2,"0") --edit
user:SendPM(botname, "As you wish my master!") 
user:SendPM(botname, "The user "..arg.." with the password "..arg2.." is now") 
user:SendPM(botname, "registered at "..frmHub:GetHubName().." / "..hubaddress.."") 
elseif (cmd=="+changeuserpassword") then 
ChangePass(user, data)
end
end 
end 
end 
end

Its no good to work with the RegisterUser.dat the only to have access to the pass should be the person who is runnig the hub.. if someone forget his pass just use the other command you have requested.

Best regards, nErBoS
--## nErBoS Spot ##--

Snooze

#4
Thanks for the reply :)

Though, when i try to change the password of a user NOT regged in the hub, that username will be registered as a Master ?


Quoteif someone forget his pass just use the other command you have requested.

I cant seem to find that piece of code in your script ?

**Snooze

**EDIT**

Got it :) - Then just change the password.

Sorry ;)

Snooze

Oops !

More testing showed that all users that get their password changed will be "upgraded" to Masters ;)

How do we prevent that ?


**Snooze

Snooze

Hmm.. looks like i was too tired to read last night

AddRegUser(arg, arg2, "0")

As i understand it, all users who has their password changed will end up with status = "0"

What i should have asked is:

How do I make sure that the user will keep the current level ?

I hope you can help :)

**Snooze

plop

#7
cleaned it up a lot and added +changepassword so every1 can change there own password.
hope the +changeuserpassword now also works for every level (unless the user 2 be changed has a higher level then the user trying 2 change it).
get ready for bug's, it's up 2 you 2 find them.
botname = "Regbot" 
kb = 1024 
mb = kb*kb 
gb = kb*kb*kb 
tb = kb*kb*kb*kb 
pb = kb*kb*kb*kb*kb 
bot_name = "Regbot" 
bot_email = "here@hub" 
bot_speed = "T3" 
bot_descr = "[Imperial]" 
bot_share_size = 0 * mb 


function Main() 
   frmHub:RegBot(botname) 
end 

function NewUserConnected(curUser) 
   curUser:SendData( my_info_string ) 
end 

function OpConnected(curUser) 
   curUser:SendData( my_info_string ) 
end 

hubaddress="clone4.myftp.org" 


------------------------------------------------------------------------ 
--DO NOT EDIT BELOW THIS TEXT! 
------------------------------------------------------------------------- 

function Get1Arg(data) 
   s,e,cmd,arg = strfind( data, "%b<>%s+(%S+)%s+(%S+)" ) 
   return arg 
end 

function Get2Arg(data) 
   s,e,cmd,arg,arg2 = strfind( data, "%b<>%s+(%S+)%s+(%S+)%s+(.+)" ) 
   return arg, arg2 
end 

function GetProfileOffline(nick)
   ret = nil
   for a,b in GetProfiles() do
      for c,d in GetUsersByProfile(b) do
         if d == nick then
            ret = b
            break
         end
      end
   end
   return ret
end

function ChangePass(user, data)
   local arg, arg2 = Get2Arg(data) 
   if (arg == nil or arg2 == nil) then
      user:SendPM(botname, "Syntax error, +changeuserpassword  , must have a nick and a new pass.")
   else
      local tmp = GetProfileOffline(arg)
      if tmp == nil then
         user:SendPM(botname, "The user "..arg.." is not registerd in the Hub.")
      elseif tmp <= user.iProfile then
         user:SendPM(botname, "The user "..arg.." has the same or higher level then you.")
      else
         DelRegUser(arg)
         AddRegUser(arg, arg2, tmp)
         user:SendPM(botname, "The user "..arg.." has been register with a new pass: "..arg2)
      end
   end
end

function ChangeMyPass(user, data)
   if user.iProfile ~= -1 then
      local arg2 = Get1Arg(data)
      if arg2 ~= nil then
         DelRegUser(user.sName)
         AddRegUser(user.sName, arg2, user.iProfile)
         user:SendPM(botname, "The user "..arg.." has been register with a new pass: "..arg2)
      else
         user:SendPM(botname, "how about telling me the new password?|")
      end
   else
      user:SendPM(botname, "there is no password 2 change as you are not registered!|")
   end
end

function RegUser(user,data) 
   local arg = Get1Arg(data) 
   if arg==nil then 
      user:SendPM(botname, "You have to provide a password!") 
   end 
   if arg ~= nil then 
      if user.iProfile == -1 then 
         AddRegUser(user.sName, arg, "3") --edit
         user:SendPM(botname, "You are now registered at "..frmHub:GetHubName().."!") 
         user:SendPM(botname, "Add this hub to your favourites (if you haven?t done so already),") 
         user:SendPM(botname, "and be sure to write down your account-information and password:") 
         user:SendPM(botname, "HubName:\t"..frmHub:GetHubName().." Address:\t"..hubaddress.."") 
         user:SendPM(botname, "Your Nick:\t"..user.sName.."") 
         user:SendPM(botname, "Your Password:\t"..arg.."") 
      else
         user:SendPM(botname, "why try 2 register yourself when you allready are? ;)") 
         user:SendPM(botname, "If you want to register a useraccount use < +newuser Name Pwd >") 
      end 
   end 
end 


function DataArrival(user, data) 
   data=strsub(data,1,strlen(data)-1) 
   if ( strsub(data, 1, 1) == "<" ) then 
      local s,e,cmd = strfind(data,"%b<>%s+(%S+)") 
      if cmd ~= nil then 
         if (cmd=="+regme") then 
            user:SendPM(botname,"It is not wise to display your password in the mainchat!") 
            user:SendPM(botname,"Send a pm to me and try again. ") 
            return 1 
         elseif (cmd=="+reg") or (cmd=="+reghelp") then 
            user:SendPM(botname,"Yes! It?s true! Now you can register an account with us!") 
            user:SendPM(botname,"To register:") 
            user:SendPM(botname,"Send a pm to "..botname.." and type < +regme ThePasswordYouWant >. Done!") 
            return 1
         end 
      end 
   elseif ( strsub(data, 1, 5) == "$To: " ) then 
      local s,e,whoTo,from=strfind(data, "$To:%s+(%S+)%s+From:%s+(%S+)") 
      if whoTo==botname then 
         local s,e,cmd = strfind(data,"%b<>%s+(%S+)") 
         if (cmd=="+reg") or (cmd=="+reghelp") then 
            user:SendPM(botname,"Yes! It?s true! Now you can register an account with us!") 
            user:SendPM(botname,"To register:") 
            user:SendPM(botname,"Send a pm to "..botname.." and type < +regme ThePasswordYouWant >. Done!") 
         elseif (cmd=="+regme") then 
            RegUser(user,data) 
         elseif (cmd == "+changepassword") then
            ChangeMyPass(user, data)
         elseif user.bOperator then 
            if (cmd=="+reguser") then 
               local arg, arg2 =Get2Arg(data) 
               AddRegUser(arg,arg2,"3") --edit
               user:SendPM(botname, "As you wish my master!") 
               user:SendPM(botname, "The user "..arg.." with the password "..arg2.." is now") 
               user:SendPM(botname, "registered at "..frmHub:GetHubName().." / "..hubaddress.."") 
            elseif (cmd=="+changeuserpassword") then 
               ChangePass(user, data)
            end
         end 
      end 
   end 
end
plop

* edit forgot 2 say that you were adding all registered users with the level number 0.
on testdrive+ these are masters.
check the docs for more info.
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

nErBoS

#8
Hi,

Well just make a conditons, something like this..

function ChangePass(user, data)
Get2Arg(data) 
if (arg == nil or arg2 == nil) then
	user:SendPM(botname, "Syntax error, +changeuserpassword  , musdt have a nick and a new pass.")
else
	if (DelRegUser(arg) == -1) then
		user:SendPM(botname, "The user "..arg.." is not registerd in the Hub.")
	else
		local profile = GetUsersByProfile(GetProfileName(3)) ---To keep the user a REG
		for i=1, getn(profile) do
		if (ptofile[i] == arg) then
			DelRegUser(arg)
			AddRegUser(arg, arg2, "3")
			user:SendPM(botname, "The user "..arg.." has been register with a new pass: "..arg2)
		end
		end
		local profile2 = GetUsersByProfile(GetProfileName(2)) ---To keep the user a VIP
		for i=1, getn(profile2) do
		if (profile2[i] == arg) then
			DelRegUser(arg)
			AddRegUser(arg, arg2, "2")
			user:SendPM(botname, "The user "..arg.." has been register with a new pass: "..arg2)
		end
		end	
	end
end
end

Best regards, nErBoS
--## nErBoS Spot ##--

Snooze

I can't make this part work..

if (DelRegUser(arg) == -1) then
		user:SendPM(botname, "The user "..arg.." is not registerd in the Hub.")
	else

I have it running like this:


function DelUser(user, data)
		Get1Arg(data)
	if (DelRegUser(arg) == -1) then
		user:SendPM(botname, "The User "..arg.." is not registerd in the Hub.")
			appendto(sOplog)
			write("\r\n", "The non existing user "..arg.." was attempted deleted by: "..user.sName.." on "..GetTime())
			writeto()
else
		if (arg == nil) then
			user:SendPM(Bot, "Syntax error, !deluser .")
		else
			DelRegUser(arg)
			user:SendPM(Bot, "The User "..arg.." has been deleted. This action was added to log. ")
			appendto(sOplog)
			write("\r\n", "The User "..arg.." was deleted by: "..user.sName.." on "..GetTime())
			writeto()
		end
	end
end

As i understand it should work just fine like that ???
Im not getting any errors, just the "The User "..arg.." has been deleted. This action was added to log. " msg...

Please help me out once again :-)


The newbie, Snooze :-)

nErBoS

Hi,

Better this way, frist check if arg is nil then see if the arg is registered or not.

function DelUser(user, data)
	Get1Arg(data)
	if (arg == nil) then
		user:SendPM(Bot, "Syntax error, !deluser .")
	else
		if (DelRegUser(arg) == -1) then
			user:SendPM(botname, "The User "..arg.." is not registerd in the Hub.")
				appendto(sOplog)
				write("\r\n", "The non existing user "..arg.." was attempted deleted by: "..user.sName.." on "..GetTime())
				writeto()
		else
			DelRegUser(arg)
			user:SendPM(Bot, "The User "..arg.." has been deleted. This action was added to log. ")
			appendto(sOplog)
			write("\r\n", "The User "..arg.." was deleted by: "..user.sName.." on "..GetTime())
			writeto()
		end
	end
end

Best regards, nErBoS
--## nErBoS Spot ##--

Snooze

I must be missing some vital part of the script as it's still not doing the check :(


This is the code im using:

arg:
function Get1Arg(data) 
s,e,cmd,arg = strfind( data, "%b<>%s+(%S+)%s+(%S+)" ) 
return arg 
end

function:

function DelUser(user, data)
	Get1Arg(data)
	if (arg == nil) then
		user:SendPM(Bot, "Syntax error, !deleteuser .")
	else
		if (DelRegUser(arg) == -1) then
			user:SendPM(botname, "The User "..arg.." is not registerd in the Hub.")
				appendto(sOplog)
				write("\r\n", "The non existing user "..arg.." was attempted deleted by: "..user.sName.." on "..GetTime())
				writeto()
		else
			DelRegUser(arg)
			user:SendPM(Bot, "The User "..arg.." has been deleted. This action was added to log. ")
			appendto(sOplog)
			write("\r\n", "The User "..arg.." was deleted by: "..user.sName.." on "..GetTime())
			writeto()
		end
	end
end

I apologize for all my dumb questions, but i gotta learn somehow ...


**Snooze

nErBoS

Hi,

I have tested also and the functions is always returning 1, maybe a bug on this function. Lets see if anyone can explian.

Best regards, nErBoS
--## nErBoS Spot ##--

Snooze

QuoteHi,

I have tested also and the functions is always returning 1, maybe a bug on this function. Lets see if anyone can explian.

Thanks for testing it nErBoS :-)

Snooze

I started to play with plop's version of the

function ChangePass(user, data)

But when the script runs this part:

     elseif tmp <= user.iProfile then
         user:SendPM(botname, "The user "..arg.." has the same or higher level then you.")

i get this error:

Syntax Error: attempt to compare string with number


Should there be a part that changed "Master" to "0" or did i messup the script ?


**Snooze

plop

told you there were bugs. lol
never tested it.
function GetProfileOffline(nick)
   ret = nil
   for a,b in GetProfiles() do
      for c,d in GetUsersByProfile(b) do
         if d == nick then
            ret = GetProfileIdx(b)
            break
         end
      end
   end
   return ret
end
plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Snooze

lol - your right .. well.. its gonna be tested now ;)

Your fix worked perfectly - Thanks :)


Isnt this part missing too ?
my_info_string = "$MyINFO $ALL "..bot_name.." "..bot_descr.."$ $"..bot_speed..strchar( 1 ).."$"..bot_email.."$"..bot_share_size.."$"



**Snooze

Snooze

#17
hehe - i thought i were getting the hang of this, so i dived into a small mod ;)

This is what i came up with:

added a new getarg:

function Get3Arg(data) 
s,e,cmd,arg,arg2,arg3 = strfind( data, "%b<>%s+(%S+)%s+(%S+)%s+(%S+)%s+(.+)" ) 
return arg, arg2,arg3
end

and added the arg3 to the "mix":

function RegUser(user,data) 
   local arg, arg2, arg3 = Get3Arg(user, data) 
   if (arg==nil or arg2 == nil or arg3 == nil) then 
      user:SendPM(botname, "Syntax error, !register   , must have a nick and a new pass and level.") 
   else
      local tmp = GetProfileOffline(arg)
      if tmp ~= nil then
         user:SendPM(Bot, "The user "..arg.." is already registerd in the Hub.")
      elseif tmp <= user.iProfile then
         user:SendPM(Bot, "The user "..arg.." has the same or higher level then you. You can only register a user with lower level than yourself.")
      else
         AddRegUser(arg, arg2, arg3)
         user:SendPM(Bot, "The user "..arg.." has been register with a new pass: "..arg2)
      end 
   end 
end

Though as your trained eye might see, im having some problems

As you can see, i were trying to add level to the script but all i get is this error:

Syntax Error: bad argument #1 to `strfind' (string expected, got table)

and i have NO idea about what that mean

Please help me work this out ..


**Snooze
-the lua newbie

plop

here's a hint.
check on how you call the function Get3Arg in the function RegUser.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Snooze

#19
Thanks plop :)

just the hint i needed ;)

function RegUser(user,data)
   local arg, arg2, arg3 = Get3Arg[B](data)[/B]  
   if (arg==nil or arg2 == nil or arg3 == nil) then 
      user:SendPM(botname, "Syntax error, !register   , must have a nick and a new pass and level.") 
   else
      local tmp = GetProfileOffline(arg)
      if tmp ~= nil then
         user:SendPM(Bot, "The user "..arg.." is already registerd in the Hub.")
      elseif tmp <= user.iProfile then
         user:SendPM(Bot, "The user "..arg.." has the same or higher level then you. You can only register a user with lower level than yourself.")
      else
         AddRegUser(arg, arg2, arg3)
         user:SendPM(Bot, "The user "..arg.." has been register with a new pass: "..arg2)
      end 
   end 
end

Snooze

Umm ... solved one problem - created another ....

When comparing  the regged users level with arg3 im getting another error:

Syntax Error: attempt to compare string with number

This is the part:

     elseif arg3 <= user.iProfile then
         user:SendPM(Bot, "The user "..arg.." has the same or higher level then you. You can only register a user with lower level than yourself.")
      else


I replaced the tmp with my new arg3 as i cant do a lookup on a user that dont exist.. ;) - I hope thats the way to do it ..

Well.. Do anyone have another "hint" for me


**Snooze
-still learning :D

nErBoS

#21
Hi,

Your error say every think you are comparing a string (arg3) with a number (user.iPrfile)..

just make this..

"tonumber(arg3) <= user.iProfile" will pass the string to number if the string had a number otherwise you will get error.

Best regards, nErBoS
--## nErBoS Spot ##--

Snooze

That solved the error part :)
Though its not comparing the arg3 with user.iProfile or not doing it correctly.

No matter what combo of arg3 and user.iProfile i try, it still returns a negative result :(

I assume that lua is looking at 2 being higher than 1 so i would have to reverse the  (">=" and not "<=") right ?

Any hints to that ?

**Snooze
- going mad over this function

nErBoS

Hi,

What does the arg3 sends ??? a number i soppose.

Best regards, nErBoS
--## nErBoS Spot ##--

Snooze

#24
Get3Arg:

function Get3Arg(data) 
s,e,cmd,arg,arg2,arg3 = strfind( data, "%b<>%s+(%S+)%s+(%S+)%s+(%S+)%s+(.+)" ) 
return arg, arg2,arg3
end  


The function:

function RegUser(user,data)
   local arg, arg2, arg3 = Get3Arg(data)  
   if (arg==nil or arg2 == nil or arg3 == nil) then 
      user:SendPM(Bot, "Syntax error, !register   , must have a nick and a new pass and level.") 
   else
      local tmp = GetProfileOffline(arg)
      if tmp ~= nil then
         user:SendPM(Bot, "The user "..arg.." is already registerd in the Hub.")
      elseif "tonumber(arg3) <= user.iProfile" then
         user:SendPM(Bot, "The user "..arg.." has the same or higher level then you. You can only register a user with lower level than yourself.")
      else
         AddRegUser(arg, arg2, arg3)
         user:SendPM(Bot, "The new user "..arg.." has been register with pass: "..arg2.." and profile: "..GetProfileName(arg3))
			appendto(sOplog)
			write("\r\n", "The User "..arg.." was regged by: "..user.sName.." with level: "..GetProfileName(arg3).." on "..GetTime())
			writeto()
      		end 
   	end 
end


arg3 is the userlevel..


**Snooze

SMF spam blocked by CleanTalk