If first you place code in your script, it will be executed as soon as the script is loaded. To wait until something else calls your code, you must put it inside of subroutines.
Every subroutine needs a triggering event to run: something needs to happen before the script can begin to do anything. For instance, if you want to make a greet, you need to first detect someone joining. Someone joining will be the triggering event we are looking for, so we would want the Event_UserJoins subroutine to catch that event. Now, if you want something to happen when a user types something, specifically in the white chat (channel chat), what event do you think we need? Something that catches someone talking, right? Event_UserTalk is what we'll look for.
Every event has a set of required parameters (in some cases, they require zero parameters) that must be present. You don't necessarily need to use all of them; you'll probably just want one of the variables. But you have to list all of them as the parameters for the subroutine or else the subroutine will not be called.
It will be overwhelming at first, but the events are named in such a way that they generally describe when they will be called: Event_PressedEnter is "fired" (called) when you press the Enter key from within the bot to send a message.
- This information was originally written by The-Black-Ninja.
How to use
- Put the event in your script like so.
- Put valid VBScript code in place of the comment.
- You're done! Your bot will do the specified instructions when the event occurs.
Sub Event_EventName(EventArgument, EventArgument) ' place VBScript code here End Sub
List of script events
Here are a list of the current script events that you can use:
Bot Status Changes
|Event_FirstRun||called when the bot first starts up and not on subsequent script reloads|
|Event_Load||occurs after the bot loads or when a script is enabled/reloaded|
|Event_LoggedOn||Username, Product||the bot has successfully logged on to the server (but is not yet in a channel)|
|Event_ChannelJoin||ChannelName, Flags||the bot joins a channel|
|Event_ChannelLeave||the bot leaves a channel|
|Event_Close||occurs before the bot closes or the script is disabled/reloaded|
|Event_LoggedOff||the bot disconnects from Battle.net|
|Event_Shutdown||occurs when the bot closes|
|Event_Command||Cmd||the bot receives a command. Cmd is a Command object|
|Event_MessageQueued||MessageID, Message, Tag||a message is added to the message queue|
|Event_MessageSent||MessageID, Message, Tag||the bot sends a message to the server|
|Event_Error||Number, Description, Line, Column, Text, Source||an error occurs in the execution of the script|
|Event_PressedEnter||Text||when the enter key is pressed on the send box|
|Event_PacketReceived||Protocol, ID, Length, Data||the bot receives a packet from the server (or BNLS)|
|Event_PacketSent||Protocol, ID, Length, Data||the bot sends a packet to the server (or BNLS)|
|Event_UserEmote||Username, Flags, Message||occurs when a user in the channel uses an emote (the /emote or /me command)|
|Event_UserInChannel||Username, Flags, Message, Ping, Product, StatUpdate||occurs once for each user in a channel when the bot joins|
|Event_UserJoins||Username, Flags, Message, Ping, Product, Level, OriginalStatstring, Banned||occurs when a user joins the channel|
|Event_UserLeaves||Username, Flags||occurs when a user leaves the channel|
|Event_UserTalk||Username, Flags, Message, Ping||occurs when a user talks in a channel|
|Event_WhisperFromUser||Username, Flags, Message, Ping||occurs when the bot receives a private whisper from another user|
|Event_FlagUpdate||Username, NewFlags, Ping||occurs when a user receives an update to their channel flags|
|Event_ChannelList||Channels()||when the bot receives a list of available channels from the server|
|Event_ServerError||Message||the bot receives an error message from the server|
|Event_ServerInfo||Message||the bot receives an informational message from the server|
|Event_KeyReturn||KeyName, KeyValue||occurs when the bot receives a user's profile information|
|Event_BotClanInfo||ClanTag, Rank||the bot is told it is a member of a WarCraft III clan|
|Event_BotClanRankChanged||NewRank||the bot is promoted or demoted in a WarCraft III Clan|
|Event_BotJoinedClan||ClanTag||the bot successfully joins a WarCraft III clan|
|Event_BotRemovedFromClan||the bot is removed from a WarCraft III clan or the clan is disbanded|
|Event_ClanCandidateList||Result, Users()||the bot receives a list of potential clan members|
|Event_ClanDemoteUserReply||Result||the server responds to an attempt to demote a clan member, result is boolean|
|Event_ClanDisbandReply||Result||the server responds to an attempt to disband the clan, result is boolean|
|Event_ClanInfo||Name, Rank, Online||called once for each member of the clan|
|Event_ClanInvitation||Token, ClanTag, RawClanTag, ClanName, InvitedBy, NewClan||the bot is invited to join a clan|
|Event_ClanInviteUserReply||Result||a user responds to the bot's invitation to join a clan|
|Event_ClanMemberLeaves||Username||a member leaves the clan|
|Event_ClanMemberList||Username, Rank, Online||called once for each member of a clan upon login|
|Event_ClanMemberUpdate||Username, Rank, Online||a clan member changes rank or online status|
|Event_ClanMOTD||Message||the bot receives the clan's message of the day (every 30 seconds and when joining the clan channel)|
|Event_ClanPromoteUserReply||Result||the server responds to an attempt to promote a clan member, result is boolean|
|Event_ClanRemoveUserReply||Result||the server responds to the bot's attempt to remove a user, or itself, from the clan|
An object event is a script event "called by" an object created with the CreateObj function.
The name of the event uses a similar format as the above script events, except that instead of the word
Event, we use the name we has passed to CreateObj() as the name of the object.
For example, if we created a LongTimer object and named it
LTimerObj, its Timer() event would fire an event called
LTimerObj_Timer. The number of parameters and function name still must match what the event call is looking for.
It can be simplified to think of the script as having a global object named
Event whose job is to call global script events and that all events follow the naming format of ObjectName