Kaien Posted July 1, 2011 Share Posted July 1, 2011 (edited) I am requesting a Spar/Challenge Mod, where a user sends a request to another user and if the challenged user accepts they automatically battle. The battle script could be the one click attack system with hospital time taken out. I dont do the scripts too well, but I'll attempt to start it off. (Credits to Daron, for helping me with it.) SQL: CREATE TABLE IF NOT EXISTS `spar` ( `id` int(11) NOT NULL auto_increment, `challenger` int(11) NOT NULL default '0', `challenged` int(11) NOT NULL default '0', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=25 ; Send Request Script: <?php include("globals.php"); if(isset($_GET['challenge'])) { $_POST['ID'] = abs(@intval($_POST['ID'])); if($_POST['ID']) { mysql_query("INSERT INTO spar VALUES('','{$ir['userid']}','{$_POST['ID']}')") or die(mysql_error()); $i=mysql_insert_id($c); event_add($_POST['ID'],"{$ir['username']} Just challenged you to a spar. <br><br><a href=spar.php?id=43&act=challenge&username={$i}>Accept</a> | <a href=spar.php?id=1donow=decline&id={$i}>Decline</a>"); echo 'Challenege has been sent to id '.$_POST['ID'].'.'; $h->endpage(); exit; } $a = mysql_query("SELECT * FROM spar WHERE challenger='{$ir['userid']}'") or die(mysql_query()); if(mysql_num_rows($a) > 0) { echo 'You already have a challenge sent!<br>'; $h->endpage(); exit; } $c = mysql_query("SELECT * FROM spar WHERE challenged='{$ir['userid']}'") or die(mysql_query()); if(mysql_num_rows($c) > 0) { echo 'You already have a challenge you have not declined or accepted.<br>'; $h->endpage(); exit; } echo ' <form action="?challenge" method="post"> User id to challenge: <input type="text" name="ID"> <br><input type="submit" value="Submit"> </form>'; $h->endpage(); exit; } if(isset($_GET['viewchallengerecieved'])) { if($_GET['id']) { $db->query("DELETE FROM spar WHERE id='{$_GET['id']}'") or die(mysql_error()); echo 'challenge canceled'; exit; } echo ' <table border=1 width=100%> <tr> <th>User to Challenge</th> <th>Actions</th> </tr>'; $t = mysql_query("SELECT * FROM spar WHERE challenged='{$ir['userid']}'") or die(mysql_error()); if(mysql_num_rows($t) == 0) { echo '<td colspan=2>No Challenges To You!</td></table>'; $h->endpage(); exit; } while($d = mysql_fetch_assoc($t)) { $b = mysql_query("SELECT * FROM users WHERE userid='{$d['challenged']}'") or die(mysql_error()); $h = mysql_fetch_assoc($b); echo ' <tr> <td>'.$h['username'].'</td> <td><a href="?viewchallengerecieved&id='.$d['id'].'">Delete</a></td>'; } echo '</td></table>'; exit; } if(isset($_GET['viewchallengesent'])) { if($_GET['id']) { $db->query("DELETE FROM spar WHERE id='{$_GET['id']}'") or die(mysql_error()); echo 'Challenge canceled'; $h->endpage(); exit; } echo ' <table border=1 width=100%> <tr> <th>User Challenged Against</th> <th>Actions</th> </tr>'; $t = mysql_query("SELECT * FROM spar WHERE challenger='{$ir['userid']}'") or die(mysql_error()); if(mysql_num_rows($t) == 0) { echo '<td colspan=2>No Challeneges sent by you!</td></table>'; $h->endpage(); exit; } while($d = mysql_fetch_assoc($t)) { $b = mysql_query("SELECT * FROM users WHERE userid='{$d['challenged']}'") or die(mysql_error()); $h = mysql_fetch_assoc($b); echo ' <tr> <td>'.$h['username'].'</td> <td><a href="?viewchallengerecieved&id='.$d['id'].'">Delete</a></td>'; } echo '</td></table>'; $h->endpage(); exit; } if($_GET['donow'] == accept) { $id = $_GET['id']; $a = mysql_query("SELECT * FROM spar WHERE id='{$id}'") or die(mysql_error()); $f = mysql_fetch_assoc($a); if($f['challenged'] != $ir['userid']) { echo 'This challenge does not belong to you!'; $h->endpage(); exit; } $db->query("UPDATE users SET attacking={$ir['attacking']} WHERE userid=$userid"); event_add($f['challenger'], "{$ir['username']} Accepeted your challenge."); mysql_query("DELETE FROM spar WHERE id='{$f['id']}'") or die(mysql_error()); $h->endpage(); exit; } if($_GET['donow'] == decline) { $id = $_GET['id']; $a = mysql_query("SELECT * FROM spar WHERE id='{$id}'") or die(mysql_error()); $f = mysql_fetch_assoc($a); if($f['challenged'] != $ir['userid']) { echo 'This challenge does not belong to you!'; $h->endpage(); exit; } mysql_query("DELETE FROM spar WHERE id='{$f['id']}'") or die(mysql_error()); event_add($f['challenger'], "{$ir['username']} Declined your challenge."); echo 'You declined the challenge!'; $h->endpage(); exit; } echo '<a href="?challenge">Challenge Some one</a><br> <a href="?viewchallengesent">View Your Sent Challenge That Has Not Been Accepted/Declined</a><br> <a href="?viewchallengerecieved">View Your Recieved Challenged That Has Not Been Aceppted/Declined</a>'; $h->endpage(); ?> If that is correct, please tell me. If you can, could any users help me with the one click attack? Edited July 1, 2011 by Dominion added tags Quote Link to comment Share on other sites More sharing options...
Rory_M Posted July 1, 2011 Share Posted July 1, 2011 Kaien if you put your code in ["SQL"][/"SQL"] and ["PHP"][/"PHP"] tags without the quotes then people are more likely to read it. :) Are you paying people for this? 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.