Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sub EVENT_SAY
- {
- if($text=~/^Report/i && !defined $qglobals{Report})
- {
- $dbh = DBI_CONNECT();
- quest::setglobal("Report", 1, 5, "M30");
- my $time = localtime;
- my $split = substr($text, 7);
- quest::gmsay("$name ($time): $split", 331, 1, 0, 80);
- $sth = $dbh->prepare("SELECT max(id) FROM messaging");
- $sth->execute();
- my $id = $sth->fetchrow_array()+1;
- $query = "INSERT INTO messaging VALUES ('$id', '$name', '$split', '$time')";
- $sth = $dbh->do($query);
- $sth->finish();
- $dbh->disconnect();
- }
- elsif($text=~/^Report/i && defined $qglobals{Report})
- {
- $client->Message(327, "You have sent in a report in the last 30 minutes, try again later.");
- }
- if($status >= 200)
- {
- if($text=~/^ClearMessages/i)
- {
- $dbh = DBI_CONNECT();
- $query = "TRUNCATE TABLE messaging";
- $sth = $dbh->do($query);
- quest::gmsay("All reports have been cleared by $name.", 331, 1, 0, 80);
- }
- }
- }
- sub EVENT_CONNECT
- {
- if($status >= 80)
- {
- $dbh = DBI_CONNECT();
- $query = "SELECT COUNT(id) FROM messaging";
- $sth = $dbh->prepare($query);
- $sth->execute();
- my $count = $sth->fetchrow_array();
- if($count > 1)
- {
- quest::popup("Messages!", plugin::PWColor("Green") . "You have " . plugin::PWColor("Yellow") . $count . "</c> messages to view.");
- }
- elsif($count == 1)
- {
- quest::popup("Messages!", plugin::PWColor("Green") . "You have " . plugin::PWColor("Orange") . $count . "</c> message to view.");
- }
- elsif($count == 0)
- {
- quest::popup("Messages!", plugin::PWColor("Green") . "You have " . plugin::PWColor("Red") . $count . "</c> messages to view.");
- }
- }
- }
- sub DBI_CONNECT
- {
- use DBI;
- $database = "DATABASE";
- $host = "HOST";
- $username = "USERNAME";
- $password = "PASSWORD";
- $dbh = DBI->connect("DBI:mysql:database=$database;host=$host", "$username", "$password", {RaiseError => 1});
- return $dbh;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement