1 # VoreTournament rcon2irc plugin by Merlijn Hofstra licensed under GPL - votestop.pl
2 # Place this file inside the same directory as rcon2irc.pl and add the full filename to the plugins.
4 # This plugin will stop an ongoing vote when the person who called it leaves. Edit the options below
5 # to disallow votes after certain events.
8 mapstart => 90, # can't call mapchange votes for this amount of seconds after mapstart
9 connected => 120, # can't call votes when you just joined the server
10 minplayers => 2, # minimal amount of players for this script to work.
13 $store{plugin_votestop} = \%vs; }
15 # add a dependency on joinsparts.pl
16 if (defined %config && $config{plugins} !~ m/joinsparts.pl /gi) {
17 die "votestop.pl depends on joinsparts.pl but it appears to not be loaded.";
23 my @ar = split /:/, $_[0];
24 return ($ar[0] * 60 * 60) + ($ar[1] * 60) + $ar[2];
27 [ dp => q{:vote:vcall:(\d+):(.*)} => sub {
28 my ($id, $command) = @_;
29 $command = color_dp2irc $command;
30 my $vs = $store{plugin_votestop};
32 # use joinsparts for player check
33 return 0 unless ($id && get_player_count() >= $vs->{minplayers});
35 my $slot = $store{"playerslot_byid_$id"};
36 if ($vs->{mapstart} && (time() - $store{map_starttime}) < $vs->{mapstart}) {
37 if ($command =~ m/(endmatch|restart|gotomap|chmap)/gi) {
38 $vs->{vstopignore} = 1;
39 out dp => 0, "sv_cmd vote stop";
40 out irc => 0, "PRIVMSG $config{irc_channel} :* vote \00304$command\017 by " . $store{"playernick_byid_$id"} .
41 "\017 was rejected because the map hasn't been played long enough";
43 out dp => 0, "tell #$slot your vote was rejected because this map only just started.";
49 my $time = time_to_seconds $store{"playerslot_$slot"}->{'time'};
51 if ($vs->{connected} && $time < $vs->{connected}) {
52 $vs->{vstopignore} = 1;
53 out dp => 0, "sv_cmd vote stop";
54 out irc => 0, "PRIVMSG $config{irc_channel} :* vote \00304$command\017 by " . $store{"playernick_byid_$id"} .
55 "\017 was rejected because he isn't connected long enough";
57 out dp => 0, "tell #$slot your vote was rejected because you just joined the server.";
62 $vs->{currentvote} = $id;
66 [ dp => q{:vote:v(yes|no|timeout|stop):.*} => sub {
68 $store{plugin_votestop}->{currentvote} = undef;
69 my $vs = $store{plugin_votestop};
71 if ($cmd eq 'stop' && $vs->{vstopignore}) {
72 $vs->{vstopignore} = undef;
79 [ dp => q{:part:(\d+)} => sub {
81 my $vs = $store{plugin_votestop};
83 if (defined $store{plugin_votestop}->{currentvote} && $id == $store{plugin_votestop}->{currentvote}) {
84 $vs->{vstopignore} = 1;
85 out dp => 0, "sv_cmd vote stop";
86 out irc => 0, "PRIVMSG $config{irc_channel} :* vote \00304$command\017 by " . $store{"playernick_byid_$id"} .
87 "\017 was stopped because he left the server";
93 [ dp => q{:gamestart:(.*):[0-9.]*} => sub {
94 my $vs = $store{plugin_votestop};
96 if (defined $store{plugin_votestop}->{currentvote}) {
97 out dp => 0, "sv_cmd vote stop";
98 $store{plugin_votestop}->{currentvote} = undef;
99 $vs->{vstopignore} = undef;