PtokaX forum

Archive => Archived 5.0 boards => Help with scripts => Topic started by: dragos_sto on 26 April, 2005, 09:48:53

Title: Help Whit Commnad
Post by: dragos_sto on 26 April, 2005, 09:48:53
some little question how to use this command
GetOnlineRegUsers() and what return
? a number and vor 0 value return nil ?
and this command for specify profile return the specify user profile online , GetOnlineUsers(ProfileNumber)   
 how to specify the profile number ?

this return a table and not a number ?
and i huve to number the user from the table ?

10x a lot for help
Title: some success
Post by: dragos_sto on 26 April, 2005, 10:36:02
I make some  excavations and ai meke next code  8)
--//Reg User Count
function OnlineRegUsers()
local table, count = frmHub:GetOnlineUsers(), 0
for i, User in table do
if User.iProfile >=0 then
count = count + 1
end
end
return count
end


i hope some one to uset  :D
Title:
Post by: Dessamator on 26 April, 2005, 11:07:31
here u go:
QuoteGetOnlineUsers(ProfileNumber)      - Without number return table with all logged user objects, with number only users with given profile.
Title:
Post by: jiten on 26 April, 2005, 11:15:28
QuoteOriginally posted by dragos_sto
some little question how to use this command
GetOnlineRegUsers() and what return
? a number and vor 0 value return nil ?
and this command for specify profile return the specify user profile online , GetOnlineUsers(ProfileNumber)   
 how to specify the profile number ?

this return a table and not a number ?
and i huve to number the user from the table ?

10x a lot for help
When in doubt, check the "PtokaX\Scripting-Interface.txt" ;)

Cheers
Title:
Post by: dragos_sto on 26 April, 2005, 11:50:50
i'm not always understand what  they want from me :D
or how to work whit the command,
par example il try to use the command
GetOnlineUsers(ProfileNumber) and put a number between () ..and dont success whit tis command
Title:
Post by: jiten on 26 April, 2005, 12:13:14
Try using this:
GetOnlineUsers(GetProfileIdx(ProfileName)) -- where ProfileName is its name (reg,vip,op,master,etc)Cheers
Title:
Post by: Dessamator on 26 April, 2005, 13:13:12
or this

for i,user in GetOnlineUsers(GetProfileIdx(ProfileName)) do -- where ProfileName is its name reg,vip,op,master,etc)
SendToAll(user)
end
Title:
Post by: dragos_sto on 26 April, 2005, 13:53:19
hi , i dont whant to make vizible to all , just whant to make my own statisitc :)
Title:
Post by: jiten on 26 April, 2005, 14:09:41
If you want to know the online reg users why don't u use:
frmHub:GetOnlineRegUsers()
Cheers
Title:
Post by: Dessamator on 26 April, 2005, 14:26:03
well use let me explain it better then, the
frmHub:GetOnlineRegUsers()
is just a table of online users, for example if u have a hub with 3 users, namely , John , JJ and Joe.

What that api(frmHub:GetOnlineRegUsers()) does is simply, take those 3 users and put it in a table like so::

   
onlineusers ={[1]="John",
                       [2]="JJ",
                       [3]="Joe",}


and all u need to do is read from it(the table), and use it for ur purposes!
Title:
Post by: dragos_sto on 27 April, 2005, 02:25:30
true it a lite bate faster ,
one question less for each user
but to obtain a number the for remain :(
Title:
Post by: jiten on 27 April, 2005, 10:03:08
QuoteOriginally posted by dragos_sto
true it a lite bate faster ,
one question less for each user
but to obtain a number the for remain :(
Can you explain us what exactly u want to do? Maybe we can post a script that can help u understand.

Best regards.
Title:
Post by: Dessamator on 27 April, 2005, 10:39:21
QuoteOriginally posted by jiten
QuoteOriginally posted by dragos_sto
true it a lite bate faster ,
one question less for each user
but to obtain a number the for remain :(
Can you explain us what exactly u want to do? Maybe we can post a script that can help u understand.

Best regards.

indeed !!
Title:
Post by: dragos_sto on 28 April, 2005, 01:29:14
10x a lot for help whit the script,
i realy want to know the sintax  
exactly (whit one example ) for each command
to create my own script , in lua  4 brainmaster make a verry good script ho dont was compile ,
so i may change'it for my need ,
and understend some command from him ,
now i try to understeand how to use the new command ,
and whit some help i understend few command
shame for me :( , i dont have enough time to make
test and this it the reason i try to find more whit your help in little time i have

my own script will be public when i will finish him ..


i'm crazy whit statistics
Title:
Post by: jiten on 28 April, 2005, 10:22:21
Have a look at this then:
-- frmHub:GetOnlineUsers example : Send PM to all user of a certain profile (VIP in this one)

Bot = frmHub:GetHubBotName()

ChatArrival = function (user,data)
data = string.sub(data, 1, -2)
local s,e,cmd,args = string.find( data, "%b<>%s+(%S+)%s*(.*)")
if cmd == "!msgvip" then
if user.bOperator then
if args then
for i, nick in frmHub:GetOnlineUsers() do
if nick.iProfile == 2 then
nick:SendPM(Bot, user.sName.." sent this message: "..args)
end
end
else
user:SendData(Bot, "*** Syntax Error: Type !msgvip msg")
end
else
user:SendData(Bot,"*** Error: You are not allowed to use this command.")
end
return 1
end
end
-- frmHub:GetOnlineRegUsers example : Send PM to all REG Profile users

Bot = frmHub:GetHubBotName()

ChatArrival = function (user,data)
data = string.sub(data, 1, -2)
local s,e,cmd,args = string.find( data, "%b<>%s+(%S+)%s*(.*)")
if cmd == "!msgreg" then
if user.bOperator then
if args then
for i, nick in frmHub:GetOnlineRegUsers() do
nick:SendPM(Bot, user.sName.." sent this message: "..args)
end
else
user:SendData(Bot, "*** Syntax Error: Type !msgreg msg")
end
else
user:SendData(Bot,"*** Error: You are not allowed to use this command.")
end
return 1
end
end
Cheers
Title:
Post by: Stravides on 02 May, 2005, 23:12:13
I'm trying to write something similar - ie a per profile lister... but it wont work for the UNREGGED users

i've tried using profile -1 but doesnt work :(

can anyone please help ???

function GetUsers(user,data,arg)
if arg==nil then
arg1 = "Unregistered"
else
arg1 = GetProfileName(arg)
end
user:SendPM(BOTName ,"------ Users of type: "..arg1.." ----- ")
for i,usr in frmHub:GetOnlineUsers() do
if arg == nil and usr.iProfile == nil then
user:SendPM(BOTName,"Unregged\t - \t"..usr.sName)
elseif usr.iProfile == tonumber(arg) then
user:SendPM(BOTName,GetProfileName(usr.iProfile).."\t - \t"..usr.sName)
end

end
return 1
end
Title:
Post by: Dessamator on 02 May, 2005, 23:28:10
function GetUsers(user,data,arg)
if arg==nil then
arg1 = "Unregistered"
else
arg1 = GetProfileName(arg)
end
user:SendPM(BOTName ,"------ Users of type: "..arg1.." ----- ")
for i,usr in frmHub:GetOnlineUsers() do
if arg == nil and not(usr.bRegistered) then
user:SendPM(BOTName,"Unregged\t - \t"..usr.sName)
elseif usr.iProfile == tonumber(arg) then
user:SendPM(BOTName,GetProfileName(usr.iProfile).."\t - \t"..usr.sName)
end

end
return 1
end
Done!!,

(Untested)
Title:
Post by: Stravides on 02 May, 2005, 23:32:26
Many thanks -- sorted now
didnt even think of that heheheheh
Title:
Post by: Dessamator on 02 May, 2005, 23:42:11
QuoteOriginally posted by Stravides
Many thanks -- sorted now
didnt even think of that heheheheh

yw,  :))