Modules/bIRC/ircGetBotByName: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with '{{ml_birc}} __NOTOC__ This function returns the first {{ml_birc|ircbot}} pointer of the bot with the specified name. It's useful if you don't have access to the variable where bo…')
 
 
Line 20: Line 20:
     local theBot = ircGetBotByName ( botName )
     local theBot = ircGetBotByName ( botName )
     if theBot then
     if theBot then
         outputChatBox ( botnames .. " is currently " .. ircGetBotState ( theBot ) .. "." )
         outputChatBox ( botName .. " is currently " .. ircGetBotState ( theBot ) .. "." )
     else
     else
         outputChatBox ( "There's no ircbot called " .. botName .. "!" )
         outputChatBox ( "There's no ircbot called " .. botName .. "!" )

Latest revision as of 08:48, 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 returns the first ircbot pointer of the bot with the specified name. It's useful if you don't have access to the variable where bot was originally stored in ircCreateBot.

Syntax

ircbot ircGetBotByName ( string botName )

Required Arguments

  • botName: The name of the ircbot you want to get.

Returns

Returns the ircbot pointer if ircbot with specified name was found, false otherwise.

Example

This example adds a command getbotstate which can be used to check the current state of an ircbot.

function getIrcBotState ( thePlayer, commandName, botName )
    local theBot = ircGetBotByName ( botName )
    if theBot then
        outputChatBox ( botName .. " is currently " .. ircGetBotState ( theBot ) .. "." )
    else
        outputChatBox ( "There's no ircbot called " .. botName .. "!" )
    end
end
addCommandHandler ( "getbotstate", getIrcBotState )

See Also

Bot functions

Creation

Connection

Other

IRC functions

Channel

User

Communication

Other