Modules/IRCEcho/ircDisconnect: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(New page: __NOTOC__ Disconnects an open IRC Connection ==Syntax== <syntaxhighlight lang="lua"> function ircDisconnect ( IRCConnection irc ) </syntaxhighlight> ===Required arguments=== * '''irc:''' The IRCConnection you wish...)
 
No edit summary
 
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{ModuleFunction|IRCEcho}}
Disconnects an open IRC Connection
Disconnects an open IRC Connection



Latest revision as of 15:21, 13 January 2008


Package-x-generic.png This function is provided by the external module IRCEcho. You must install this module to use this function.

Disconnects an open IRC Connection

Syntax

function ircDisconnect ( IRCConnection irc )

Required arguments

  • irc: The IRCConnection you wish to disconnect

Example

Example 1: This example connects to a server on ResourceStart and disconnects on ResourceStop

szChans = {} --Init an array of channels for storage

function onResourceStart( res )
	if res == getThisResource() then -- If the starting resource is this one
		ircInit( ) -- Initialize the module for this resource
		pIRC = ircOpen( "irc.gtanet.com", 6667, "WikiTest", "#channel" ) -- Open the IRC connection
		if pIRC then -- If opening connection was successful
			szChans[ pIRC ] = "#channel" -- Add the channel to the table
		end
	end
end

function onResourceStop( res )
	if res == getThisResource () then -- If the stopping resource is this one
		if pIRC then -- If theres an IRC Connection
			ircDisconnect( pIRC ) -- Disconnect the connection
			szChans[ pIRC ] = nil -- Removes the channel from the array
			pIRC = nil -- Set the connection to nil
		end
	end
end

addEventHandler( "onResourceStart", getRootElement(), onResourceStart )
addEventHandler( "onResourceStop", getRootElement(), onResourceStop )

See also