Author Topic: Kitchen Sink.  (Read 3487 times)

0 Members and 1 Guest are viewing this topic.

Offline TZB

  • Double Ace
  • *
  • Posts: 119
  • Karma: +13/-1
  • ||-T-z-B-||
    • FastFix Support
Kitchen Sink.
« on: 26 August, 2009, 10:56:23 »
Please Let us have some more Fun madman If you can make your creation for newer ptokax also. :P
Code: [Select]
-- Kitchen Sink made by Madman, 28.02.06
--[[--
Made beacuse of bastya_elvtars comment on the board
quote: These scripts contain everything but the kitchen sink. :)
But now this board does ;)
Warning! Use with caution!
This script will disconnect a random number of users when a Op use the cmd !sink

How? How the hell did i came up with the idea of this script?
If you figured it out, please let me know
--]]--

function ChatArrival(curUser, data)
local data = string.sub(data, 1, -2)
local s,e,cmd = string.find(data, "%b<>%s+[%!%+%#](%S+)")
if curUser.bOperator then
if cmd == "sink" then
Sink(curUser) return 1
end
end
end

function Sink(user)
local TmpTable,WhileTable,Dissed = {}, {0,}, ""
if frmHub:GetUsersCount() == 1 then
user:SendData("*** We need more users before we pull the plug") return 1
end
for _,oUser in frmHub:GetOnlineUsers() do
if oUser.sName == user.sName then
-- Don't add user that used the cmd
else
table.insert(TmpTable, oUser.sName)
end
end
SinkNr = math.random(0, (frmHub:GetUsersCount()-1))
if SinkNr == 0 then
SendToAll(user.sName.. " pulled the plug in the kitchen sink, but no user went down the drain") return 1
end
WhileTable[1] = SinkNr
while WhileTable[1] > 0 do
UserDis = TmpTable[math.random(table.getn(TmpTable))]
DisconnectByName(UserDis)
WhileTable[1] = WhileTable[1] - 1
Dissed = Dissed..UserDis..", "
end
Msg = user.sName.. " pulled the plug and the following users went down the drain " ..Dissed
SendToAll(Msg)
end
Fun Script had been awesome way to keep the main chat alive can this script be brought back to work on new ptokax.

PtokaX forum

Kitchen Sink.
« on: 26 August, 2009, 10:56:23 »

Offline ?ippe??

  • Fulll Member
  • ****
  • Posts: 55
  • Karma: +3/-1
Re: Kitchen Sink.
« Reply #1 on: 26 August, 2009, 18:59:15 »

 Here comes the converted script using the API Convertor
 Tested in my hub and working fine.

 
Code: [Select]
--[[
-- Kitchen Sink made by Madman

Made beacuse of bastya_elvtars comment on the board
quote: These scripts contain everything but the kitchen sink. :)
But now this board does ;)
Warning! Use with caution!
This script will disconnect a random number of users when a Op use the cmd !sink

How? How the hell did i came up with the idea of this script?
If you figured it out, please let me know

Changes :-
-- This script is converted to API 2 using PtokaX LUA API Converter v1.0

]]--

function ChatArrival(curUser,data)
local data = string.sub(data, 1, -2)
local s,e,cmd = string.find(data, "%b<>%s+[%!%+%#](%S+)")
if Core.GetUserValue(curUser,11) then
if cmd == "sink" then
Sink(curUser) return true
end
end
end

function Sink(user)
local TmpTable,WhileTable,Dissed = {}, {0,}, ""
if Core.GetUsersCount() == 1 then
Core.SendToUser(user,"*** We need more users before we pull the plug") return 1
end
for _,oUser in Core.GetOnlineUsers(false) do
if oUser.sNick == user.sNick then
-- Don't add user that used the cmd
else
table.insert(TmpTable, oUser.sNick)
end
end
SinkNr = math.random(0, (Core.GetUsersCount()-1))
if SinkNr == 0 then
Core.SendToAll(user.sNick.. " pulled the plug in the kitchen sink, but no user went down the drain") return 1
end
WhileTable[1] = SinkNr
while WhileTable[1] > 0 do
UserDis = TmpTable[math.random(#TmpTable)]
Core.Disconnect(UserDis)
WhileTable[1] = WhileTable[1] - 1
Dissed = Dissed..UserDis..", "
end
Msg = user.sNick.. " pulled the plug and the following users went down the drain " ..Dissed
Core.SendToAll(Msg)
end

Offline TZB

  • Double Ace
  • *
  • Posts: 119
  • Karma: +13/-1
  • ||-T-z-B-||
    • FastFix Support
Re: Kitchen Sink.
« Reply #2 on: 26 August, 2009, 19:05:15 »
What should i say i actually tried already what you did but there is a problem for me its not getting done when i type !sink.

Offline TZB

  • Double Ace
  • *
  • Posts: 119
  • Karma: +13/-1
  • ||-T-z-B-||
    • FastFix Support
Re: Kitchen Sink.
« Reply #3 on: 26 August, 2009, 19:16:10 »
To the max to what i seen so far the converter which even i used it could only do the function till.
Quote
function Sink(user)
   local TmpTable,WhileTable,Dissed = {}, {0,}, ""
   if Core.GetUsersCount() == 1 then
      Core.SendToUser(user,"*** We need more users before we pull the plug") return 1
   end
i.e when user count is 1
But when user count increased the script failed for some reason on my side i got no idea if you tested the script in hub with users more than 1.
Please update me with your results so that i could recheck my problems.

Offline ?ippe??

  • Fulll Member
  • ****
  • Posts: 55
  • Karma: +3/-1
Re: Kitchen Sink.
« Reply #4 on: 27 August, 2009, 05:46:35 »
 
 Sorry to say that the script is failing at my end too when the users exceed more that one.

 When i type "!sink" the following error occurs :-

 Syntax C:\Myhub\scripts\KitchenSink.lua:33: attempt to call a table value

 Something is wrong in this part of the script
Code: [Select]

            SinkNr = math.random(0, (Core.GetUsersCount()-1))
if SinkNr == 0 then
Core.SendToAll(user.sNick.. " pulled the plug in the kitchen sink, but no user went down the drain") return 1
end
WhileTable[1] = SinkNr
while WhileTable[1] > 0 do
UserDis = TmpTable[math.random(#TmpTable)]
Core.Disconnect(UserDis)
WhileTable[1] = WhileTable[1] - 1
Dissed = Dissed..UserDis..", "
end

 Hope i can solve this with some R&D.... lol

 Regards,
 ?ippe??

Offline TZB

  • Double Ace
  • *
  • Posts: 119
  • Karma: +13/-1
  • ||-T-z-B-||
    • FastFix Support
Re: Kitchen Sink.
« Reply #5 on: 27 August, 2009, 07:04:49 »
Thank Goodness by analysis were right.
now i can just go ahead for editing but its madman's script so am not sure if he permits. got to ask him first. :P
Madman please help with this script if you have time.

Offline Madman

  • Scripter
  • Emperor
  • ******
  • Posts: 1 316
  • Karma: +75/-1
Re: Kitchen Sink.
« Reply #6 on: 27 August, 2009, 13:25:03 »
the problem is that for loops requiers pairs or ipairs, depending if it's an array or table.
Table is
Code: [Select]
t = {
["one"] = true,
["two"] = true,
}
while array is
Code: [Select]
a = {
[1] = true,
[2] = true,
}
so the line for _,oUser in Core.GetOnlineUsers(false) do  needs a ipairs. ipairs(Core.GetOnlineUsers())  btw, the false is not needed either.

I attached the converted version I wrote.
I made some improvement, but it still does the same thing.

As for editing my scripts, it's free to use/rewrite anything, aslong as the I'm credited in someway.
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

Offline TZB

  • Double Ace
  • *
  • Posts: 119
  • Karma: +13/-1
  • ||-T-z-B-||
    • FastFix Support
Re: Kitchen Sink.
« Reply #7 on: 27 August, 2009, 13:29:47 »
Thanks a lot madman.
Quote
How? How the hell did i came up with the idea of this script?
If you figured it out, please let me know
Any answer for this question its bit curious thing in the script :P if you could please reveal the mystery behind the script.
Thanks once again.

Offline Madman

  • Scripter
  • Emperor
  • ******
  • Posts: 1 316
  • Karma: +75/-1
Re: Kitchen Sink.
« Reply #8 on: 27 August, 2009, 22:16:53 »
The mystery?
I have no idea. I just wrote the script... And I don't really know why...
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

PtokaX forum

Re: Kitchen Sink.
« Reply #8 on: 27 August, 2009, 22:16:53 »