Check if Offline User is Registered
 

Check if Offline User is Registered

Started by pR0Ps, 04 July, 2010, 17:18:49

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

pR0Ps

How would I check if an offline user is registered? I'm writing an offline message script and for security reasons want only users that are registered to be able to receive them. I'm guessing it has something to do with matching the username with an entry in the table that RegMan.GetRegsByProfile(nProfileNumber) returns but I'm not entirely sure. Any help would be much appreciated.

Dessamator

QuoteGetReg(sNick)         - Return registered user with given nick as registered user table or nil when reg with this nick not exist.
You can also use that getregbyprofile, although you need to loop through the table to find that particular user. By the way you can use Mutor's Change Nick 2.0 as reference, he uses it there.
Ignorance is Bliss.

pR0Ps

OK, going off that I quickly wrote up a function, I don't have the facilities to test it at the moment though (on my Linux box). Will this get the job done?

--Determines if the user is a registered user
function validUser (user)
	--0 to 3 are the registered profiles
	for i = 0, 3 do
		local t = RegMan.GetRegsByProfile(i)
		for _, u in ipairs (t) do
			if (u.sNick == user) then
				return true
			end
		end
	end
	return false
end

Dessamator

That might work but it looks like taking the long way  around the Great Wall , to go into China, what I originally meant was something like:
If RegMan.GetReg(user) then ...


As for your long way of doing it, using
GetRegs()			- Return table with all registered users as registered user tables.


would be better because you want to check all registered users regardless of profile
Ignorance is Bliss.

pR0Ps

Forgot to thank you for your help, I got it working perfectly :)

SMF spam blocked by CleanTalk