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.
(Thanks to TheBlackNinja)
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:
- Event_BotClanInfo(ClanTag, Rank)
- Event_ChannelJoin(ChannelName, Flags)
- Event_ClanCandidateList(Result, Users())
- Event_ClanInfo(Name, Rank, Online)
- Event_ClanInvitation(Token, ClanTag, RawClanTag, ClanName, InvitedBy, NewClan)
- Event_ClanMemberList(Username, Rank, Online)
- Event_ClanMemberUpdate(Username, Rank, Online)
- Event_FlagUpdate(Username, NewFlags, Ping)
- Event_KeyReturn(KeyName, KeyValue)
- Event_LoggedOn(Username, Product)
- Event_MessageQueued(MessageID, Message, Tag)
- Event_MessageSent(MessageID, Message, Tag)
- Event_PacketReceived(Protocol, ID, Length, Data)
- Event_PacketSent(Protocol, ID, Length, Data)
- Event_UserEmote(Username, Flags, Message)
- Event_UserInChannel(Username, Flags, Message, Ping, Product, StatUpdate)
- Event_UserJoins(Username, Flags, Message, Ping, Product, Level, OriginalStatstring, Banned)
- Event_UserLeaves(Username, Flags)
- Event_UserTalk(Username, Flags, Message, Ping)
- Event_WhisperFromUser(Username, Flags, Message, Ping)