PDA

View Full Version : Anti-MQ2 Reward NPC


phate8908
01-02-2019, 09:09 AM
credits to poru (http://www.eqemulator.org/forums/showthread.php?t=41283) for the original script wrote in perl

REQUIRES:
MySQL Connect (http://www.eqemulator.org/forums/showthread.php?t=42243)
Client:GetAccountName() (http://www.eqemulator.org/forums/showthread.php?t=42244)

Custom Views .sql (add to you database)

CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`127.0.0.1` VIEW `hackers_account` AS SELECT *, COUNT(*) as hack_count FROM hackers WHERE `date` >= now() - INTERVAL 1 DAY and hacked not like "/MQZone%" GROUP BY `account` ORDER BY hack_count DESC;
CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`127.0.0.1` VIEW `hackers_ip` AS SELECT account_ip.ip, account.name as `account`, hackers.name as `character`, hackers.hacked, hackers.zone, COUNT(*) as hack_count FROM hackers LEFT JOIN (account,account_ip) ON (hackers.account = account.name AND account.id = account_ip.accid) WHERE hackers.`date` >= now() - INTERVAL 1 DAY AND account_ip.lastused >= now() - INTERVAL 1 DAY AND hackers.hacked not like "/MQZone%" GROUP BY account_ip.ip ORDER BY hack_count DESC;


Rewards_Bot.pl (rename to Your_NPC.pl)

function event_say(e)
local npcName = e.self:GetCleanName();
if(e.message:findi("hail")) then
local hackCheck = 1
local hackCountAccount = 0
local hackMessage = ""
if (hackCheck == 1) then
local MySQLi = require('MySQLi')
local connection = MySQLi.Connect()
local queryhackers_account = string.format("SELECT hack_count FROM hackers_account WHERE account = '%s'",e.other:AccountName())
connection:query(queryhackers_account)
result = connection:store_result()
for v,hack_count in result:rows() do
hackCountAccount = hack_count
end
if (hackCountAccount > 3) then
hackMessage = string.format("Sorry, %s, your Hack Count is %u for the last 24 hours. I can't reward you until your Hack Count is less than 3. Please check back in an hour or two.",e.other:GetCleanName(),tonumber(hackCountAccount) )
elseif (hackCountAccount > 0) then
hackMessage = string.format(" By the way, your Hack Count is %u for the last 24 hours, %s. I will be temporarily unable to reward you if your Hack Count becomes greater than 2.",tonumber(hackCountAccount),e.other:GetCleanName() )
end
end
if (hackCountAccount <= 2) then
hackMessage = string.format("I like your style, %s, have a carrot!",e.other:GetCleanName(),hackMessage)
e.other:SummonItem(1001);
end
e.self:Whisper(e.other,hackMessage)
end
end