-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgs_roulette.cpp
95 lines (82 loc) · 2.19 KB
/
gs_roulette.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/* GameServ: Roulette
*
* (C) 2019 Michael Hazell
* Contact me at michaelhazell@hotmail.com
*
* You may use this module under the terms of docs/LICENSE, in the Anope source directory
*
* Configuration:
* module { name = "gs_roulette"; }
* command { name = "ROULETTE"; service = "GameServ"; command = "gameserv/roulette"; }
* fantasy { name = "ROULETTE"; command = "gameserv/roulette"; prepend_channel = true; }
*/
#include "module.h"
class CommandGSRoulette : public Command
{
public:
CommandGSRoulette(Module* creator, const Anope::string& sname = "gameserv/roulette") : Command(creator, sname, 1, 1)
{
this->SetDesc(_("Perform a round of roulette (live or die)"));
this->SetSyntax("\037#channel\037");
this->AllowUnregistered(true);
}
void Execute(CommandSource& source, const std::vector<Anope::string>& params) anope_override
{
const Anope::string& chan = params[0];
ChannelInfo* ci = ChannelInfo::Find(chan);
BotInfo *gs = Config->GetClient("GameServ");
if (!ci)
{
source.Reply(CHAN_X_NOT_REGISTERED, chan.c_str());
return;
}
if (!ci->bi)
{
source.Reply(BOT_NOT_ASSIGNED);
return;
}
if (!ci->c || !ci->c->FindUser(ci->bi))
{
source.Reply(BOT_NOT_ON_CHANNEL, ci->name.c_str());
return;
}
if (!gs)
{
source.Reply("GameServ client not found");
return;
}
User* u = source.GetUser();
int random = rand() % 1000;
if(random > 499)
{
u->Kill(gs, "BANG!");
}
else
{
IRCD->SendPrivmsg(gs, ci->name, "*click*");
}
}
bool OnHelp(CommandSource& source, const Anope::string& subcommand) anope_override
{
this->SendSyntax(source);
source.Reply(" ");
source.Reply(_("Perform a round of roulette. The gun will click or go off with a bang!"));
return true;
}
};
class GSRoulette : public Module
{
CommandGSRoulette commandgsroulette;
public:
GSRoulette(const Anope::string& modname, const Anope::string& creator) : Module(modname, creator, THIRD),
commandgsroulette(this)
{
this->SetAuthor("Techman");
this->SetVersion("0.1");
if (!ModuleManager::FindModule("gameserv"))
{
throw ModuleException("This module requires the GameServ core module to be loaded in order to function.");
}
}
};
MODULE_INIT(GSRoulette)