PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: juda on 29 September, 2004, 12:41:59

Title: Description tag for favorite users with timer !?
Post by: juda on 29 September, 2004, 12:41:59
Hallo to all scripters !!!
I have request for script for my ptoka hub....Please for your help...

Bot name: RANK MASTER
======================================>
I like to have script :
1.- when user connect to my hub get RANK in description tag - like [[[NEWBIE]]]
or [[[MEMBER]]] OR [[[ROUTINIER]]]...I like to change this by my self ( OP & MASTER )
2.- and I can put by my own in script...like:
  1. jonny - [[[ MEMBER ]]]
  2. rudi - [[[ KING ]]]
  3. [DSL]JUVE - [[[ NEWBIE ]]]
  4. juda - [[[ OWNER ]]]
  5. ..........
  6. ..........
 & up to 50 users......
---------------------------------
I like if it possible to have a timer for all connected users,how much time spend on hub......
  1. jonny - 12 hours 3 minutes
  2. rudi - 2 days 6 hours
  3. [DSL]JUVE - 28 minutes
  4. manny - 16 hours 2 minutes
  5. ..........
  6. ..........
 & up to 50 users......

on this data & how is user active in hub,
I will put his rank in his tag.....
======================================>
Sorry for my english.....& thanks for any replay !!!!
Title: Little tip !!!
Post by: juda on 29 September, 2004, 12:49:25
The same princip is here on this forum-- I think ???
More time you spend on forum
and more post you send....higher rank you get
Title:
Post by: bastya_elvtars on 29 September, 2004, 13:35:47
this is a very nice idea, i will make this script.

just 2 check if im understanding: is the ranking based on number of posted mainchat lines? If so, then i can make it, but will be f***ing bandwidth consuming.
Title:
Post by: juda on 29 September, 2004, 13:54:57
yes - based on number of posted mainchat lines & time
         spend on hub......
Title:
Post by: bastya_elvtars on 29 September, 2004, 13:57:55
QuoteOriginally posted by juda
yes - based on number of posted mainchat lines & time
         spend on hub......

for instance, i divide the lines with time in seconds

this gives a ratio

and the higher this ratio is, the bigger users rank will be

is this okay?
Title:
Post by: juda on 29 September, 2004, 16:44:21
O.K. - try please !!!
Title: i think done..
Post by: bastya_elvtars on 30 September, 2004, 01:04:17
seems 2 work, but the other things are experimental

so no release yet


see a preview

http://rnrdoctor.sytes.net/sample2.bmp
Title:
Post by: bastya_elvtars on 30 September, 2004, 12:23:21
please enter my hub: rnrdoctor.sytes.net

there we can discuss what you exactly want and if you like what i achieved till now

*** EDIT ***

Now we are at a totally automated script. It makes a certain ratio of chatlines/useruptime and changes the users rank, all is seeable in userlist. There are certain bugs, but i am gonna fix them, cause i got interested. This is a very nice, and not an easy2do idea, but niot impossible.
Title:
Post by: Dj_OcTaGoN on 30 September, 2004, 13:34:19
Hi,

Yes i agree, this sounds like a very good idea!
Waiting to see the finished product lol  :D

cheers // Dj_OcTaGoN
Title:
Post by: bastya_elvtars on 30 September, 2004, 13:40:16
the only problem is that useruptime always increases, so a user can be ranked down, not only up. I can do a multiplying instead of division, as nochatting users chatlines always remains 0. Decide which is better.
Title:
Post by: NightLitch on 30 September, 2004, 14:47:44
why not do a function for it

check if number is 0 then what you now should do, do it

and if if number is ~= 0 then / or what you had in mind...

cool idea, gonna try make one too when I get some time over...

CHeers / NightLitch
Title: HAY
Post by: juda on 30 September, 2004, 16:10:11
I visit your hub bastya_elvtars and have some questions....
I see you have all [[[ newbies ]]],but I running my hub like 6 month and have a lot of old user & users who are conected 5 - 6 hours per day every day...
can I change RANK for this users by myself manual...like:
- medo / [[[ member ]]] ; juve / [[[ guest ]]] ; yelo / [[[ king ]]] ; Xibit [[[ friend ]]],....
for all other users stay [[[ guest ]]] not [[[ newbie ]]]
In my hub I have users who are with me,when I start running hub...so for this users rank [[[ friends ]]] or [[[ routiner ]]],....
I will have only 6 to 8 ranks....I run exthetic game and I already have in tag for master,op,vip & reg.users like:
 [[[ MASTER ]]] ; [[[ MODERATOR ]]] ; [[[ OP ]]] ; [[[ VIP ]]] & [[[ REG ]]]....
So I like to have script to put ranks for users that I pick manualy....
Is this possible to do ????
I run hub with 150 users connected every day...
Timer is only to check users how much time spend on hub.....like: TOP HUBBER - can I check time spend on my hub for 100 users ???than I see how much time user spend on hub and give him a RANK - more time spend,higher is RANK....I think,if is possible to run TOP HUBBERS script seperatly with RANK MASTER.....????

This for now !!! I hope you understed my request and thanks for  your good start..... KEEP ON MUVEN !!!
Title:
Post by: BottledHate on 30 September, 2004, 20:02:31
so if the rank is based on a ratio of lines to time spent on the hub... then peoples rank will go down if they don't chat... is that what you want?  if i were to do it i would base it off of words typed in main. i could care less how long people park their clients in my hub for.


-BH
Title: HELLO !!!
Post by: juda on 01 October, 2004, 11:29:49
Zitat:
____________________________________________________________
so if the rank is based on a ratio of lines to time spent on the hub...
then peoples rank will go down if they don't chat...
is that what you want? if i were to do it i would base it off of words typed in main.
 i could care less how long people park their clients in my hub for.
____________________________________________________________

O.K. - good....
Yes,it will be better to do like you say.....
Try to create script & we will see,how script muven !!!
  SEE YA......
Title:
Post by: bastya_elvtars on 01 October, 2004, 11:52:41
QuoteOriginally posted by NightLitch
why not do a function for it

check if number is 0 then what you now should do, do it

and if if number is ~= 0 then / or what you had in mind...

cool idea, gonna try make one too when I get some time over...

CHeers / NightLitch

i do not clearly understand, but i think i already have done this...

***EDIT***

ok, decided 2 post where i am now, if anyone willing 2 help me develop, i will be glad, cause ill have less time in the next few days

ranks={ -- add the chatlines/uptime ratios. u add the maximum levels, so if a users rank is above this value, his rank will be upgraded automatically

[1000]="Newbie" -- test value only, thats why u can only see n00bs, sry, this can only be done experimental


}

rankops=1 -- 1 to rank ops, 0 to not

-- end of editable part

function DataArrival(user,data)
local uptime=maketable("useruptime.dat")
if uptime[user.sName] then
uptime[user.sName]=tonumber(uptime[user.sName])+calculateusersuptime(user)
savefile(uptime,"useruptime.dat")
else
uptime[user.sName]=calculateusersuptime(user)
savefile(uptime,"useruptime.dat")
end
if strsub(data, 1, 1) == "<" then
data=strsub(data,1,strlen(data)-1)
if not strfind(data,"%b<>%s+[%!%?%#%+].*") then
local chatlines=maketable("chatlines.dat")
if not chatlines[user.sName] then
chatlines[user.sName]=1
else
chatlines[user.sName]=chatlines[user.sName]+1
end
savefile(chatlines,"chatlines.dat")
end
elseif strsub(data, 1, 7) == "$MyINFO" and user.sMyInfoString then
SendToAll(changemyinfo(user))
end
end

function checkratio(user)
local chatlines=maketable("chatlines.dat")
local uptime=maketable("useruptime.dat")
if not chatlines[user.sName] or not uptime[user.sName] or tonumber(uptime[user.sName])==0 then
return calculate(0,1)
else
return calculate(tonumber(chatlines[user.sName]),tonumber(uptime[user.sName]))
end
end

function calculate(chat, upt)
for a,b in ranks do
if chat/upt end
end

function NewUserConnected(user)
local userentered=maketable("userentered.dat")
userentered[user.sName]=date("%Y. %m. %d. %X")
savefile(userentered,"userentered.dat")
local uptime=maketable("useruptime.dat")
if not uptime[user.sName] then
uptime[user.sName]=0
savefile(uptime,"useruptime.dat")
end
SendToAll(changemyinfo(user))
onconnectmyinfos(user)
end

function UserDisconnected(user)
local uptime=maketable("useruptime.dat")
if uptime[user.sName] then
uptime[user.sName]=tonumber(uptime[user.sName])+calculateusersuptime(user)
savefile(uptime,"useruptime.dat")
else
uptime[user.sName]=calculateusersuptime(user)
savefile(uptime,"useruptime.dat")
end
local userentered=maketable("userentered.dat")
userentered[user.sName]=nil
savefile(userentered,"userentered.dat")
end

function calculateusersuptime(user)
local diff=JulianDate(SplitTimeString(date("%Y. %m. %d. %X")))-newornot(user)
return diff
end

function newornot(user)
local userentered=maketable("userentered.dat")
if userentered[user.sName] then
return JulianDate(SplitTimeString(userentered[user.sName]))
else
return JulianDate(SplitTimeString(date("%Y. %m. %d. %X")))
end
end

-- Split a specific Time string into its components
-- New Format: D. M. Y. HR:MN:SC" - 24hr time
-- return: Y,M,D,HR,MN,SC  HR is in 24hr format
function SplitTimeString(TimeString) --
--local s,e,Y,M,D,HR,MN,SC = strfind(TimeString, "([^.]+). ([^.]+). ([^.]+). ([^:]*):([^:]*):(%S*)");
-- 14/09/2004 16.23.25
local grab=function(TimeString)
if strfind(TimeString,"/")then
local _,_,D,M,Y,HR,MN,SC=strfind(TimeString,"([^/]+).([^/]+).(%S+) ([^:]+).([^:]+).([^:]+)")
return D,M,Y,HR,MN,SC
elseif strfind (TimeString,"%d%-%d") then
local _,_,D,M,Y,HR,MN,SC = strfind(TimeString, "([^-]+).([^-]+).(%S+) ([^:]+).([^:]+).(%S+)")
return D,M,Y,HR,MN,SC
elseif strfind (TimeString,"%d%d.%d%d.%d%d%d%d%s+") then
local _,_,Y,M,D,HR,MN,SC = strfind(TimeString, "([^.]+).([^.]+).(%S+). ([^:]+).([^:]+).(%S+)")
return D,M,Y,HR,MN,SC
else
local _,_,Y,M,D,HR,MN,SC = strfind(TimeString, "([^.]+). ([^.]+). ([^.]+). ([^:]+).([^:]+).(%S+)")
return D,M,Y,HR,MN,SC
end
end

local D,M,Y,HR,MN,SC=grab(TimeString)
D = tonumber(D)
M = tonumber(M)
Y = tonumber(Y)
HR = tonumber(HR)
--assert(HR < 24)
MN = tonumber(MN)
--assert(MN < 60)
SC = tonumber(SC)
--assert(SC < 60)

assert(HR < 24);
assert(MN < 60);
assert(SC < 60);
return D,M,Y,HR,MN,SC
end

function JulianDate(DAY, MONTH, YEAR, HOUR, MINUTE, SECOND) -- HOUR is 24hr format
local jy, ja, jm;
assert(YEAR ~= 0);
assert(YEAR ~= 1582 or MONTH ~= 10 or DAY < 4 or DAY > 15);
--The dates 5 through 14 October, 1582, do not exist in the Gregorian system!");
if(YEAR < 0 ) then
YEAR = YEAR + 1;
end
if( MONTH > 2) then
jy = YEAR;
jm = MONTH + 1;
else
jy = YEAR - 1;
jm = MONTH + 13;
end
local intgr = floor( floor(365.25*jy) + floor(30.6001*jm) + DAY + 1720995 );
--check for switch to Gregorian calendar
local gregcal = 15 + 31*( 10 + 12*1582 );
if(DAY + 31*(MONTH + 12*YEAR) >= gregcal ) then
ja = floor(0.01*jy);
intgr = intgr + 2 - ja + floor(0.25*ja);
end
--correct for half-day offset
local dayfrac = HOUR / 24 - 0.5;
if( dayfrac < 0.0 ) then
dayfrac = dayfrac + 1.0;
intgr = intgr - 1;
end
--now set the fraction of a day
local frac = dayfrac + (MINUTE + SECOND/60.0)/60.0/24.0;
--round to nearest second
local jd0 = (intgr + frac)*100000;
local  jd  = floor(jd0);
if( jd0 - jd > 0.5 ) then jd = jd + 1 end
return jd
end

function frac(num)
return num - floor(num);
end

function changemyinfo(user)
local myinfopart1,myinfopart2=strsub(user.sMyInfoString,1,(13+strlen(user.sName))),strsub(user.sMyInfoString,(14+strlen(user.sName)),strlen(user.sMyInfoString))
return myinfopart1.." "..checkratio(user).." // "..myinfopart2
end

function savefile(table,file)
writeto(file)
for a,b in table do
write(a.."|"..b.."\n")
end
writeto()
end

function maketable(file)
local table={}
readfrom(file)
while 1 do
local line = read()
if line == nil then
readfrom()
break
else
local _,_,nick,value=strfind(line,"(.+)|(.+)")
table[nick]=value
end
end
readfrom()
return table
end

function Main()
if rankops==1 then
OpConnected=NewUserConnected
OpDisconnected=UserDisconnected
end
end

function onconnectmyinfos(user)
local userentered=maketable("userentered.dat")
for a,b in userentered do
if GetItemByName(a) then
user:SendData(changemyinfo(GetItemByName(a)))
end
end
user:SendData(changemyinfo(user))
end
Title:
Post by: Dj_OcTaGoN on 01 October, 2004, 13:00:38
Wish i could help :(  , but my knowledge arent very wide in scripting yet...still trying to learn
Title:
Post by: BottledHate on 02 October, 2004, 02:01:37
well i tried to add the tag to the description.. but i
couldn't find a way that i was 100% acurrate. Even tried
 bastya's method... even so, doing such takes up ALOT
 more bandwidth than should be used for a hub.

so anyways.. i made one too... too big to post here lol...

get it HERE (http://www.stcycles.com/hate/scripts/pto/aaChatRankv0.1.lua)

here are the user set commands...
--//////////////////////////////////////
--//ChatRank Bot v0.1
--//by: BottledHate
--//requested by: juda
--//first release 01/10/04
--//////////////////////////////////////
-- Bot gives users "tags" based on how much they chat in the main. Similar to a forum and posting messages.
-- +Set word number for each level of tag.
-- +Set tag names foreach level.
-- +Main Chat Tags: "[tag] text", "<[tag] nick> text", "[tag] text"
-- +User stats: First Post Date, Total words, Total chars, Average cpw.
-- +Set permanent tags.
-- +Set users/ops to have no tag.
-- +Toggle the main chats' tag position or to off.
-- +Full help menu for ops and users.
-- +User defined commands.
--//////////////////////////////////////

--//////////////////////////////////////////////////////////
--//EDIT THIS JUNK!

--//Hub prefixes for other bot and hub commands.
HubPrefixes = {[COLOR=green]"!","+","*"[/COLOR]}

--//ChatRank Bot..BotName
RankBotName = "[COLOR=green]ChatRank[/COLOR]"
registerBot = [COLOR=green]0[/COLOR] --// 1=regbotname. 0= don't reg.

--//Chat Ranking Table. Edit table according to example.
ChatRanks = {
[[COLOR=green]0[/COLOR]] = {[[COLOR=green]0[/COLOR]] = "[COLOR=green]NewB[/COLOR]"}, --//[level] = {[words#] = "rank tag"},   !!LEAVE LEVEL 0 AT 0 WORDS!!
[[COLOR=green]1[/COLOR]] = {[[COLOR=green]10[/COLOR]] = "[COLOR=green]b00b[/COLOR]"},
[[COLOR=green]2[/COLOR]] = {[[COLOR=green]20[/COLOR]] = "[COLOR=green]Lamer[/COLOR]"},
[[COLOR=green]3[/COLOR]] = {[[COLOR=green]30[/COLOR]] = "[COLOR=green]ID10T[/COLOR]"},
[4] = {[40] = "I EAT PASTE"},
[5] = {[50] = "NO LIFE"},
--[6] = {[2000] = "????"},
--[7] = {[3000] = "????"},
--[8] = {[4000] = "????"},
--[9] = {[10000] = "????"},
--[10] = {[50000] = "you get the point..."},
}

--//user commands table. edit stuff in quotes.
ChatRankUserDefined = {
cmd1 = "[COLOR=green]!showranks[/COLOR]",  --//show the ranking table.
cmd2 = "[COLOR=green]!mystats[/COLOR]", --//show your stats
cmd3 = "[COLOR=green]!rankhelp[/COLOR]", --//shows users their commands only, and ops all commands.
}

--//op commands table. edit stuff in quotes
ChatRankUserDefinedOP = {
cmd1 = "[COLOR=green]!setmaintag[/COLOR]",   --//  --// 0 = Main chat tag off. | 1 = [tag]  |  2 = <[tag] nick>  | 3 = [tag]
cmd2 = "[COLOR=green]!setusertag[/COLOR]", --//  --//set a permanenant tag for a nick. blank clears.
cmd3 = "[COLOR=green]!setimmune[/COLOR]", --//  --// makes the bot not place a tag on (toggles on or off)(stats still kept.)
cmd4 = "[COLOR=green]!showimmune[/COLOR]", --//show's the list of currently ignored users.
}

--//set what ops can do....(MASTER CAN DO ALL ANYTIME)
LetOPsSetTag = [COLOR=green]0[/COLOR]  --// 0 = OPs can only set their own tag. 1 = OPs can set users tags and own tag.(not master or other op)
LetOPsSetImmune = [COLOR=green]0[/COLOR]  --// 0 = OPs cannot use this command. 1 = OPs can set usser or self to be immune.(not master or other op)
LetOPsSetMainTag = [COLOR=green]0[/COLOR]  --// 0 = OPs cannot use this command. 1 = OPs can set the Main Chat Tag position, or turn it off.

--//ok stop editing :D
--//////////////////////////////////////////////////////////

-BH
Title:
Post by: Dj_OcTaGoN on 02 October, 2004, 13:41:20
Yeah I like this really hard hehe it looks really cool!  :D

But i keep getting this error:
Syntax error: attempt to index a nil value
stack traceback:
   1:  function `OpDisconnected' at line 91 [file `...-= PtokaX [debug] =-\scripts\aaChatRankv0.1.lua']

Syntax error: attempt to index a nil value
stack traceback:
   1:  function `OpDisconnected' at line 91 [file `...-= PtokaX [debug] =-\scripts\aaChatRankv0.1.lua']

And even if i have the profile NetFounder, have also tried Master profile,  i can only use the OP commands on myself. Though this is not a very necessary function for me, i found out how to change in the ChatRanks.dat file

thx cheers // Dj_OcTaGoN
Title:
Post by: BottledHate on 02 October, 2004, 20:47:09
updated the file above.. you shouldn't get that error anymore...

i'll look into the commands for master and what not...

-BH
Title:
Post by: Dj_OcTaGoN on 02 October, 2004, 22:00:27
Ok, it seems to work now!

cheers // Dj_OcTaGoN
Title: Hay to all scripters !!!
Post by: juda on 02 October, 2004, 22:23:47
I think you dont understand my idea....look,this what you done is exelent,
but I like to have RANK - [[[MEMBER]]] or other ranks
showen in description tag....!!!! Like this:
*
   NICK---------------SHARED-----------------DESCRIPTION----------------TAG-------------------CONNECTION
------------------------------------------------------------------------------------------------------------------

[SI][dsl]prfox--------4.66 GB--------[[[USER]]] Movies & music....--------<++V:401,M:A,H:1....--------DSL
samurai --------3.16 GB--------[[[MEMBER]]] Mp3 & games.... --------<++V:401,M:A,H:1.... --------DSL
jesse--------2.88 GB--------[[[COOL MEMBER]]] Movies & music.... --------<++V:401,M:A,H:1.... --------DSL

-----------------------------------------------------------------------------------------------------------------

I already run Esthetic bot and have users tag(description)  for :
 - master  ---  [[[OWNER]]]
 -  operator ---  [[[OP]]]
 - vip user  ---  [[[VIP]]]
 - registred user  ---  [[[REG]]]
[[[xxx]]] rank is showen non stop!!!
So please if you can,do script just for users,for other profiles I will use old script......
other stuff in your script rocks,so dont change the rest of it....!!!
Thanks for your time......see ya
Title:
Post by: BottledHate on 03 October, 2004, 02:40:48
on the contrary.. i understand your idea well! it's a
great one... however, if you read my post, you'll see
what i said wabout changing users descriptions...


it takes ALOT more bandwidth than normally used by a
hub.. and so far i have not been able to make it 100%
 accurate. if i can find a way to do so that is 100%
accurate... i can easily add it to my script, and would be
glad to do so as an option.

The script i posted is the next best thing and what i
have come up with so far in regards to your request. i
only hope i am able to make it something that you
would like to use. i will make an option to change the
 brackets that hold the tag customizeable.. ie: so you
can change it to [[[tag]]].


-BH
Title:
Post by: Dj_OcTaGoN on 06 October, 2004, 16:10:33
Hi!

Is there some way to make Robocops anti-advertise function work with this tag script? cause when having those tags "on", Robocop wont kick for advertising (which i believe is because the Tag bot is sending the chat, and not the user?)

cheers // Dj_OcTaGoN
Title:
Post by: bastya_elvtars on 06 October, 2004, 16:13:27
name this as ZZZuserranker.lua or whatever
make sure its name is last in scripts' alphabetical order
then it will not forward the modded desc 2 rc
Title:
Post by: Dj_OcTaGoN on 07 October, 2004, 10:54:30
ok will try that, thx