Modules/bIRC/ircGetBots: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with '{{ml_birc}} __NOTOC__ This function is used to check whether the specified {{ml_birc|ircbot}} is connected to a server. ==Syntax== <syntaxhighlight lang="lua"> bool ircGetBots () </syntaxhighlight> ==…')
 
mNo edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{ml_birc}}
{{ml_birc}}
__NOTOC__
__NOTOC__
This function is used to check whether the specified {{ml_birc|ircbot}} is connected to a server.
This function can be used to list out all created {{ml_birc|ircbot}}s.


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool ircGetBots ()
table ircGetBots ()
</syntaxhighlight>  
</syntaxhighlight>  


Line 22: Line 22:
         outputConsole ( "There are no ircbots!", thePlayer )
         outputConsole ( "There are no ircbots!", thePlayer )
     else
     else
         outputConsole ( "There's " .. #ircBots .. " ircbots:" )  
         outputConsole ( "There's " .. #ircBots .. " ircbots:", thePlayer )  
         for key, value in ipairs ( ircBots ) do
         for key, value in ipairs ( ircBots ) do
             outputConsole ( "- " .. ircGetName ( value ) )
             outputConsole ( "- " .. ircGetName ( value ), thePlayer )
         end
         end
     end
     end

Latest revision as of 10:50, 30 July 2009

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

This function can be used to list out all created ircbots.

Syntax

table ircGetBots ()

Required Arguments

None

Returns

Returns a table over all created ircbots. Returns an empty table if no ircbots exist.

Example

This example adds a command listbots which can be used to print out all currently available ircbots along with their names to console.

function printOutIrcBots ( thePlayer )
    local ircBots = ircGetBots ()
    if #ircBots == 0 then
        outputConsole ( "There are no ircbots!", thePlayer )
    else
        outputConsole ( "There's " .. #ircBots .. " ircbots:", thePlayer ) 
        for key, value in ipairs ( ircBots ) do
            outputConsole ( "- " .. ircGetName ( value ), thePlayer )
        end
    end
end
addCommandHandler ( "listbots", printOutIrcBots )

See Also

Bot functions

Creation

Connection

Other

IRC functions

Channel

User

Communication

Other