PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: D-J Valhala on 10 January, 2004, 11:12:09

Title: +goodpoint?
Post by: D-J Valhala on 10 January, 2004, 11:12:09
sup ppl's i need some GooD script for my good user's :)
can a script be write for that i can give a user a GooD point like +warn but not warn the user give hem a good point and the BoT will count the good point's and will post "the best user of the WeeK" "the best user of the month"
and only the OP's can use that commend
coz all the OP's commend are bad for the user i wanna be GooD for the user it will be FuN =)))

and what i give GooD point for user it will SendToAll + SendPM
CyA all
Title:
Post by: anubis_say on 10 January, 2004, 14:00:34
Good idea :) Please help us
Title:
Post by: DJ Bert on 10 January, 2004, 14:06:59
It's a good idea. Troubadour and i gonna try to make a script for it  :P
Title:
Post by: D-J Valhala on 10 January, 2004, 14:36:01
hehehehe i know :P
hope you can make one

CyA all
Title:
Post by: tezlo on 10 January, 2004, 17:52:40
cool idea.. heres a start
points = {}

function Main()
points = dofile("points.dat") or {}
end

function OnExit()
local f = openfile("points.dat", "w+")
assert(f, "points.dat")

write(f, "return {\n")
for nick, value in points do
write(f, "\t"..format("[%q]", nick).." = "..value..",\n")
end; write(f, "}")
closefile(f)
end

function DataArrival(user, data)
if strsub(data, 1, 1) == "<" then
local s, e, cmd, args = strfind(data, "^%b<> %+(%a+)%s*(.*)%|$")
if s then
cmd = strlower(cmd)
if cmd == "give" and user.bOperator then
local s, e, nick, value, reason = strfind(args, "^(%S+)%s*([%d%-]*)%s*(.*)$")
if s then
if value == "" then value = 1
else value = tonumber(value) end

if reason == "" then reason = "for no reason"
else reason = "because "..reason end

points[nick] = (points[nick] or 0) + value
user:SendData(">> "..nick.." now has "..points[nick].." points")
SendToNick(nick, ">> "..user.sName.." has given you "..value.." points "..reason)

else
user:SendData(">> syntax: +give [points] [reason]")
end
elseif cmd == "topusers" then
local index = {}
for nick, value in points do tinsert(index, nick) end
sort(index, function(a, b) return points[a] > points[b] end)

local n = getn(index)
if n > 10 then n = 10 end
user:SendData(">> top "..n.." users..")
for i = 1, n do
local nick = index[i]
local value = points[nick]
user:SendData(">>\t["..value.."]\t "..nick)
end
else return
end; return 1
end
end
end

OPs can +give [points] [reason]
points and reason are optional
by default 1 point and no reason
points can also be negative :)

anyone can +topusers

topweek topmonth would be pain to do
maybe later.. or if someone else can be bothered
Title:
Post by: DJ Bert on 10 January, 2004, 17:55:58
That's a good start ;)
Title:
Post by: D-J Valhala on 10 January, 2004, 18:38:19
thanks m8 but you forgot the BoT name + SendToAll

and "+ungive" GooD point

:D

CyA all
Title:
Post by: tezlo on 10 January, 2004, 21:21:31
theres no need for a botname
if you really want.. insert this below SendToNick
SendToAll("whoever", nick.." got "..value.." points "..reason)
i think it would get annoying
and well.. you can give negative points
Title:
Post by: D-J Valhala on 10 January, 2004, 21:40:43
yes i know i modefide the scrip and not it work perfect but i nedd +ungive commend

CyA all
Title: kool script
Post by: XPMAN on 11 January, 2004, 02:29:23
This is a very kool script. Just wondering though, If the hub goes down ,does everything get reset so when the hub restarts everyone is at 0 or does everyone keep what they have even if the hub restarts?

Could find out the easy way...by just resetting the hub, but its been humming along (PtokaX that is) for 42days now.

What would really be kool would be to automate it. For example someone in the hub for (x amount) days gets 25 points (make adjustable)

members of the hub already are eating this point thing up.....kinda like a status thing to them i guess..trying to see who can "earn" the most points.

Anyways, just wondering about if it keeps all the data when the hub is reset.

My thnx again for such a kool script. Never dreamed a script this small could draw so much attention in the hub..lol
Title:
Post by: tezlo on 11 January, 2004, 04:34:36
points get saved/loaded on script (re)start ;)
Title:
Post by: D-J Valhala on 11 January, 2004, 10:46:45
it dont save the points whan i restart the scripts it give 0 point to 0 users
:\

and please can you add +ungive good point

CyA all
Title: ungiving...
Post by: Stravides on 11 January, 2004, 12:18:33
Quoteand please can you add +ungive good point


This is not neccessary as you can give -1 point
ie ungive 1 point
:)

Regs
Title:
Post by: D-J Valhala on 11 January, 2004, 12:51:28
yes CooL -1 work but whan i reset scrips it wont save the point's

CyA all
Title:
Post by: D-J Valhala on 11 January, 2004, 18:22:37
can enyone moddefy the scrip??????????????????
it not work good the script dont save the point's and dont send PM to user who got the good point

maybe plop?

:\

CyA all
Title:
Post by: NotRabidWombat on 11 January, 2004, 19:08:53
quick fix. Now saves the table every time you change points. This will also save data in the event of a crash.

points = {}

function Main()
points = dofile("points.dat") or {}
end

function OnExit()
local f = openfile("points.dat", "w+")
assert(f, "points.dat")

write(f, "return {\n")
for nick, value in points do
write(f, "\t"..format("[%q]", nick).." = "..value..",\n")
end; write(f, "}")
closefile(f)
end

function DataArrival(user, data)
if strsub(data, 1, 1) == "<" then
local s, e, cmd, args = strfind(data, "^%b<> %+(%a+)%s*(.*)%|$")
if s then
cmd = strlower(cmd)
if cmd == "give" and user.bOperator then
local s, e, nick, value, reason = strfind(args, "^(%S+)%s*([%d%-]*)%s*(.*)$")
if s then
if value == "" then value = 1
else value = tonumber(value) end

if reason == "" then reason = "for no reason"
else reason = "because "..reason end

points[nick] = (points[nick] or 0) + value
user:SendData(">> "..nick.." now has "..points[nick].." points")
SendToNick(nick, ">> "..user.sName.." has given you "..value.." points "..reason)
OnExit();
else
user:SendData(">> syntax: +give [points] [reason]")
end
elseif cmd == "topusers" then
local index = {}
for nick, value in points do tinsert(index, nick) end
sort(index, function(a, b) return points[a] > points[b] end)

local n = getn(index)
if n > 10 then n = 10 end
user:SendData(">> top "..n.." users..")
for i = 1, n do
local nick = index[i]
local value = points[nick]
user:SendData(">>\t["..value.."]\t "..nick)
end
else return
end; return 1
end
end
end
Title: update
Post by: XPMAN on 11 January, 2004, 19:58:59
Appreciate the update. Well done.
Title:
Post by: DJ Bert on 11 January, 2004, 23:00:27
I just tested the script that i updated. That was the same funtion that NotRabidWombat writing. It works fine.  :)
Title:
Post by: plop on 11 January, 2004, 23:21:08
it was actualy saving automaticly on closing/restarting of ptokax, but only on 0.3.3.0.
function OnExit() is new in that version.

plop
Title:
Post by: D-J Valhala on 12 January, 2004, 09:59:14
the sctipt work GooooooooD NotRabidWombat 10x

now can you add to the script 2 new things?

i whant that the script will post 1 in a week "the best user of the week" + " the best user of the month???


 :D

CyA all
Title:
Post by: BlazeXxX on 12 January, 2004, 15:29:27
Nice one ;) Something i always wanted to have :D
Title:
Post by: NotRabidWombat on 12 January, 2004, 20:31:42
Yes... but for some reason PtokaX has an *elite* group of beta testers and we do not have access to that version. So I made it save all the time which is the only thing you can really do with TD4.

-NotRabidWombat