Author |
Message |
minor59er Newbie
Age:36 Gender: Joined: Dec 14 2002 Posts: 11 Offline
|
Posted: Sun Feb 11, 2007 3:42 am Post subject: making bot commands |
 |
|
|
|
Hi, i was just wondering if someone could show me some code and tell me where to put it for making a command (e.g. !announce ) start a countdown and trigger events. |
|
Back to top |
|
 |
Witchie NL Seasoned Helper
Age:35 Gender: Joined: Jul 24 2005 Posts: 112 Location: Veere, Zeeland, Netherlands Offline
|
Posted: Sun Feb 11, 2007 5:51 am Post subject: |
 |
|
|
|
You have a file command.cpp with this part:
void botInfo::gotCommand(Player *p, Command *c)
{
if (!p) return;
if (!c) return;
switch (p->access)
{
case OP_Duke:
case OP_Baron:
case OP_King:
case OP_Emperor:
case OP_RockStar:
case OP_Q:
case OP_God:
case OP_Owner:
{ // Owner-level commands
}
case OP_SysOp:
{ // SysOp-level commands
}
case OP_SuperModerator:
{ // SuperModerator-level commands
}
case OP_Moderator:
{ // Moderator-level commands
}
case OP_Limited:
{ // Limited-level commands
}
case OP_Player:
{ // Player-level commands
}
}
} |
You can add this into the code:
if (c->check("announce")) //if command name is announce
{
countdown[0] = 5; // set countdown0 to 5 seconds
sendPrivate(p, "message"); // Send in private something back to the player who triggered the command.
}
|
So you get this:
void botInfo::gotCommand(Player *p, Command *c)
{
if (!p) return;
if (!c) return;
switch (p->access)
{
case OP_Duke:
case OP_Baron:
case OP_King:
case OP_Emperor:
case OP_RockStar:
case OP_Q:
case OP_God:
case OP_Owner:
{ // Owner-level commands
}
case OP_SysOp:
{ // SysOp-level commands
}
case OP_SuperModerator:
{ // SuperModerator-level commands
}
case OP_Moderator:
{ // Moderator-level commands
}
case OP_Limited:
{ // Limited-level commands
}
case OP_Player:
{ // Player-level commands
if (c->check("announce")) //if command name is announce
{
countdown[0] = 5; // set countdown0 to 5 seconds
sendPrivate(p, "message"); // Send in private something back to the player who triggered the command.
}
}
}
} |
Also alot is explained here
You need to add the event triggering manualy in (usualy) spawn.cpp |
|
Back to top |
|
 |
minor59er Newbie
Age:36 Gender: Joined: Dec 14 2002 Posts: 11 Offline
|
Posted: Sun Feb 11, 2007 8:41 am Post subject: |
 |
|
|
|
cool thanks for your help, was just unsure of it thats all.. and i have been following the mervbot tutorial.. it just doesnt explain properly.
And also, if i wanted it to show periodically count down from 5 minutes, and display every minute after the command has been typed, how would i go about that?
And one more thing, what do you mean add the event trigger manually?
sorry for all the questions.. just new at this and thanks for all your help so far. |
|
Back to top |
|
 |
Witchie NL Seasoned Helper
Age:35 Gender: Joined: Jul 24 2005 Posts: 112 Location: Veere, Zeeland, Netherlands Offline
|
Posted: Mon Feb 12, 2007 1:15 pm Post subject: |
 |
|
|
|
if (c->check("announce")) //if command name is announce
{
countdown[0] = 5 * 60; // set countdown0 to 5 * 60 = 5 minutes
sendPrivate(p, "message"); // Send in private something back to the player who triggered the command.
}
|
Put this in command.cpp
Then in spawn.cpp you see this:
case EVENT_Tick:
{
for (int i = 0; i < 4; ++i)
--countdown[i];
}
break;
|
Which can be changed into:
case EVENT_Tick:
{
for (int i = 0; i < 4; ++i)
--countdown[i];
if (countdown[0] == 300) // if countdown is 5 minutes
{
sendPublic("5 Minutes");
}
else if (countdown[0] == 240) // if countdown is 4 minutes
{
sendPublic("4 Minutes");
}
else if (countdown[0] == 180) // if countdown is 3 minutes
{
sendPublic("3 Minutes");
}
else if (countdown[0] == 120) // if countdown is 2 minutes
{
sendPublic("2 Minutes");
}
else if (countdown[0] == 60) // if countdown is 1 minute
{
sendPublic("1 Minutes");
}
else if (countdown[0] == 0) //is countdown is over (0 seconds)
{
sendPublic("0 Minutes (Countdown over)");
}
}
break;
|
This sais how many minutes left in pubchat.
By adding it manualy i mean you need to add it yourself coz since there are so many events i cant give an example. (well i can but im to lazy to post them all) |
|
Back to top |
|
 |
minor59er Newbie
Age:36 Gender: Joined: Dec 14 2002 Posts: 11 Offline
|
Posted: Thu Feb 15, 2007 9:17 am Post subject: |
 |
|
|
|
Thanks for all your help, i have it all figured out now.  |
|
Back to top |
|
 |
Witchie NL Seasoned Helper
Age:35 Gender: Joined: Jul 24 2005 Posts: 112 Location: Veere, Zeeland, Netherlands Offline
|
Posted: Thu Feb 15, 2007 10:30 am Post subject: |
 |
|
|
|
No problemo. |
|
Back to top |
|
 |
|