Jump to content
MakeWebGames

Recommended Posts

Posted

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?

Posted

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 ;)

Posted
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!

Posted
$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;
}

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...