Serin Posted April 24, 2013 Share Posted April 24, 2013 hi im looking for a 7minute online protection mod that stops users attacking the same user within a 7 minute period.. does anyone have this mod and how much do they want for it? Quote Link to comment Share on other sites More sharing options...
sniko Posted April 24, 2013 Share Posted April 24, 2013 7 minutes is a random number, haha. Anyway, I assume it's for McCodes - as that's what your game is based off, right? CREATE TABLE last_attacks ( attacker smallint(5) NOT NULL, defender smallint(5) NOT NULL, can_attack int(11) NOT NULL ); Then, when they've attacked (where it shows all the options you can do; leave, mug, and hospitalize) /* * Please sanitize and filter the $_GET var */ $time = time() + 420; $db->query("INSERT INTO `last_attacks` (`attacker`,`defender`,`can_attack`) VALUES ($userid, $_GET['ID'], $time)"); And at the top of the attack page $db->query("DELETE FROM `last_attacks` WHERE `can_attack`> unix_timestamp()"); $get = $db->query("SELECT `attacker` FROM `last_attacks` WHERE (`attacker`=$userid) AND (`defender`={$_GET['ID']}) AND (`can_attack` <= unix_timestamp())"); if( $db->num_rows($get) ) { echo 'This user is in seven minutes of heaven.'; $h->endpage(); exit; } Untested, but should work ;) Quote Link to comment Share on other sites More sharing options...
sniko Posted April 24, 2013 Share Posted April 24, 2013 I am unsure why you would make another table, since `attacklogs` already exists and logs the information anyway. $sql = "SELECT `time` FROM `attacklogs` WHERE `attacker` = '{$ir['userid']}' AND `attacked` = '{$_GET['ID']}' AND `time` > (UNIX_TIMESTAMP() - 420)"; $run = mysql_query($sql); if (($result = mysql_fetch_assoc($run)) == true) { echo 'You can not attack this person for another ' . ($result['time'] - (time() - 420)) . ' seconds.'; $h->endpage(); exit; } Forgot about that table! Quote Link to comment Share on other sites More sharing options...
Scorpio Posted April 24, 2013 Share Posted April 24, 2013 Loooll nice one sniko, Quote Link to comment Share on other sites More sharing options...
Scorpio Posted April 24, 2013 Share Posted April 24, 2013 $q1=$db->query("SELECT * FROM attacklog WHERE $userid=attacker AND attacktime >unix_timestamp()-10"); if($db->num_rows($q1) >= 1) { print "Sorry, You either tried to submit the attack more than once or you are trying to <br />attack out quicker than 10 second intervals"; $h->endpage(); exit; } Quote Link to comment Share on other sites More sharing options...
Spudinski Posted April 24, 2013 Share Posted April 24, 2013 Never knew MCCodes had audit logs, blows my ****ing mind really. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.