X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=Usermgm.pm;fp=Usermgm.pm;h=0000000000000000000000000000000000000000;hb=ca8f6135c9709112a5d6605ac34064f5946d9570;hp=dc798110bbb366ac795747d6338a27664fb4a4b3;hpb=46d32b072c0eb2c390a981616bdec029eb179d1d;p=NDIRC.git diff --git a/Usermgm.pm b/Usermgm.pm deleted file mode 100644 index dc79811..0000000 --- a/Usermgm.pm +++ /dev/null @@ -1,78 +0,0 @@ -#************************************************************************** -# Copyright (C) 2006 by Michael Andreen * -# * -# This program is free software; you can redistribute it and/or modify * -# it under the terms of the GNU General Public License as published by * -# the Free Software Foundation; either version 2 of the License, or * -# (at your option) any later version. * -# * -# This program is distributed in the hope that it will be useful, * -# but WITHOUT ANY WARRANTY; without even the implied warranty of * -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -# GNU General Public License for more details. * -# * -# You should have received a copy of the GNU General Public License * -# along with this program; if not, write to the * -# Free Software Foundation, Inc., * -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * -#**************************************************************************/ -package NDIRC::Usermgm; -use strict; -use warnings; -use ND::DB; -use NDIRC::Access; -require Exporter; - -our @ISA = qw/Exporter/; - -our @EXPORT = qw/addPoints/; - -sub addPoints { - my ($msg, $t) = @_; - - my ($nick, $points); - if(defined $msg && $msg =~ /^(\S+)(?: (-?(\d+)?(\.\d+)?))?$/){ - $nick = $1; - $points = $2; - }else{ - $ND::server->command("notice $ND::nick syntax: .$t nick [points] | % can be used for wildcards \%arro\% will match barrow, if the number of points isn't specified, then 1 will be assumed."); - return; - } - if ( ($t eq "d" && dc()) - || ($t eq "a" && bc()) - || ($t eq "h" && officer()) - || ($t eq "s" && scanner())){ - $points = 1 unless $points; - if ($points*$points > 400){ - $ND::server->command("msg $ND::target Values between -20 and 20 please"); - return; - } - my $f = $ND::DBH->prepare("SELECT uid,username FROM users WHERE username ILIKE ?"); - $f->execute($nick); - my @row = $f->fetchrow(); - if ($f->rows == 1){ - my $type = "defense"; - $type = "attack" if $t eq "a"; - $type = "humor" if $t eq "h"; - $type = "scan" if $t eq "s"; - my ($fleets) = $ND::DBH->selectrow_array('SELECT count(*) FROM raids r JOIN raid_targets rt ON r.id = rt.raid JOIN raid_claims rc ON rt.id = rc.target WHERE not launched AND uid = ? AND tick + 24 > tick();',undef,$row[0]); - if ($t eq 'a' && $fleets > 0 && $points > 0){ - $ND::server->command("msg $ND::target $row[1] has $fleets claimed waves the last 24 ticks that aren't marked as launched, so no points."); - return; - } - $type .= "_points"; - $ND::DBH->do("UPDATE users SET $type = $type + ? WHERE uid = ?",undef,$points,$row[0]); - $ND::server->command("msg $ND::target $row[1] has been given $points $type"); - }elsif ($f->rows == 0){ - $ND::server->command("msg $ND::target No hit, maybe spelling mistake, or add % as wildcard"); - }else{ - $ND::server->command("msg $ND::target More than 1 user matched, please refine the search"); - } - $f->finish; - - }else{ - $ND::server->command("msg $ND::target You don't have access for that"); - } -} - -1;