Kitchen Sink.
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

Kitchen Sink.

Started by TZB, 26 August, 2009, 10:56:23

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

TZB

Please Let us have some more Fun madman If you can make your creation for newer ptokax also. :P
-- 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.

?ippe??


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

--[[
-- 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

TZB

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.

TZB

To the max to what i seen so far the converter which even i used it could only do the function till.
Quotefunction 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.

?ippe??

 
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
            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??

TZB

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.

Madman

the problem is that for loops requiers pairs or ipairs, depending if it's an array or table.
Table is
t = {
	["one"] = true,
	["two"] = true,
}

while array is
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

TZB

Thanks a lot madman.
QuoteHow? 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.

Madman

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

SMF spam blocked by CleanTalk