PtokaX forum

Archive => Archived 5.1 boards => Help with scripts => Topic started by: Ivosch on 19 May, 2006, 19:16:05

Title: GetUserCount
Post by: Ivosch on 19 May, 2006, 19:16:05
local uziv=frmHub:GetUserCount()

What?s wrong?
[20:12] Syntax lawmaker/components/linda.lmc:21: attempt to call method `GetUserCount' (a nil value)
I found this function on wiki...
Title: Re: GetUserCount
Post by: Psycho_Chihuahua on 19 May, 2006, 19:19:08
as far as i know Lawmaker is not yet Lua 5.1 compatibal.
Title: Re: GetUserCount
Post by: Ivosch on 19 May, 2006, 19:57:09
but for example function frmHub:GetCurrentShareAmount() is working  ???
Title: Re: GetUserCount
Post by: Psycho_Chihuahua on 19 May, 2006, 20:10:59
Here is an Example how GetUserCount is used:

function GetEnable(enable)
if enable == nil or enable == "" then
enable = "not set"
end
return enable
end


"\tThere Are Now:\t"..GetEnable(frmHub:GetUsersCount()).." of "..GetEnable(frmHub:GetMaxUsers()).." max users online.\r\n\r\n"..


Thats how its used in InfoBot created by Mutor and Modded a bit by me

Hope it helps you out a bit as i cant tell you much more (i'm still a script noob myself in some ways hehe)
Title: Re: GetUserCount
Post by: Ivosch on 19 May, 2006, 20:31:09
thnx
It?s working  :D
Title: Re: GetUserCount
Post by: Psycho_Chihuahua on 19 May, 2006, 20:52:26
your'e welcome - glad i could help you out  8)
Title: Re: GetUserCount
Post by: Markitos on 19 May, 2006, 21:34:28
But wouldn't
"\tThere Are Now:\t"..(frmHub:GetUsersCount() or "N/A").." of "..(frmHub:GetMaxUsers() or "N/A").." max users online.\r\n\r\n"..
be more simplified???
Title: Re: GetUserCount
Post by: Psycho_Chihuahua on 19 May, 2006, 21:58:18
Sure it would - but in InfoBot the GetEnable Function is used more then once ;)

in specific for:

"\tHub Name: \t"..GetEnable(frmHub:GetHubName())..",  "..Topic.."\r\n"..
"\tHub description:\t"..GetEnable(frmHub:GetHubDescr()).."\r\n"..
"\tPeak Users:\t"..GetEnable(frmHub:GetMaxUsersPeak()).."\r\n"..
"\tThere Are Now:\t"..GetEnable(frmHub:GetUsersCount()).." of "..GetEnable(frmHub:GetMaxUsers()).." max users online.\r\n\r\n"..
"\tIP Address:\t"..GetEnable(user.sIP).."\r\n"..
"\tDC Tag:\t\t"..GetEnable(user.sTag).."\r\n"..
"\tEmail:\t\t"..GetEnable(user.sEmail).."\r\n"..
"\tConnection:\t"..GetEnable(user.sConnection).."\r\n\r\n"..


which makes that function rather good
Title: Re: GetUserCount
Post by: Markitos on 20 May, 2006, 10:03:02
Quote from: Mutor on 20 May, 2006, 03:49:00
It's also because some hub calls might return nil, -1 or an empty string.
The intent of the original function was to return a boolean response from any call.
ie.. 0/1
I understand.
Title: Re: GetUserCount
Post by: bastya_elvtars on 26 May, 2006, 13:32:41
Quote from: Psycho_Chihuahua on 19 May, 2006, 19:19:08
as far as i know Lawmaker is not yet Lua 5.1 compatibal.

And will not be until a stabl?e PtokaX version with Lua 5.1 gets released. It is however damn easy to rewrite, that will be called 1.1 probably.
Title: Re: GetUserCount
Post by: Snooze on 14 July, 2006, 16:55:52
Quote from: bastya_elvtars on 26 May, 2006, 13:32:41
And will not be until a stabl?e PtokaX version with Lua 5.1 gets released. It is however damn easy to rewrite, that will be called 1.1 probably.

Good Call ;)

-Snooze