PtokaX forum

Archive => Archived 5.0 boards => Help with scripts => Topic started by: Tiskelion on 18 October, 2005, 16:30:58

Title: I need to find the parent object for a username
Post by: Tiskelion on 18 October, 2005, 16:30:58
Hello fellow LUA-users :D ,

I was wondering if someone could help me with this:

I have a function that gets a string (sUser is not a User object) that contains a users nick,  and i need to determine what User object it belongs to.

I've tried doing it this way:


function GetUserObject(sUser)

SendToAll("Finding parent object for "..sUser)

local sReturnUser

for _,sUserObject in FrmHub:GetOnlineNonOperators() do

if sUser == sUserObject.sName then

sReturnUser = sUserObject

break

end

end

SendToAll("Success!")

return sReturnUser

end



but then the function doesn't seem to process anything because the "Success!" message is never seen in mainchat and any script after the GetUserObject call is not processed...  ?(

If anybody can point out where im making a stupid mistake  please do  :rolleyes:



I forgot to say that ofcourse there is only me in my testhub, so it wont find any non operator users, but even when i change GetOnlineNonOperators() to GetOnlineOperators() it still doesn't work :(





Greets,

Tiskelion
Title:
Post by: bastya_elvtars on 18 October, 2005, 16:53:45
If you want to fetch the userobject when only the nick is available:

local user=GetItemByName(nick)

Explanation here (http://www.ptxwiki.psycho-chihuahua.net/doku.php/scriptinghelp/ptokaxapi#getitembyname_nick).
Title:
Post by: Tiskelion on 18 October, 2005, 16:57:01
Thanks for the ultra-fast reply! :D

I'm going to test that right now.



works like a dream :D



Greets,

Tiskelion