Twisted Posted February 10, 2021 Share Posted February 10, 2021 Hello, I've wrapped my head around this many times trying to figure out the issue, its to do with gang wars, now gangs can ask for a surrender but the other gangs cant accept them did anyone ever had this issue or know what i need to do? Many thanks Quote Link to comment Share on other sites More sharing options...
Magictallguy Posted February 10, 2021 Share Posted February 10, 2021 Based entirely on the query alone, I'm throwing a guess that you're running MC Codes v2. Have any edits been made to the code governing the gang surrenders? Were both gangs involved created in a standard manner (e.g., created in-game via creategang.php)? Quote Link to comment Share on other sites More sharing options...
Twisted Posted February 10, 2021 Author Share Posted February 10, 2021 Yes im running MC Codes v2, nothing has been changed to date and yes both gangs are created in game, the war is there, it works, someone can request for surrenders but the other gang cannot accept them Quote Link to comment Share on other sites More sharing options...
SRB Posted February 11, 2021 Share Posted February 11, 2021 It's not passing the war id variable to the query, hence it erroring on warID= ... nothing. So on the surrender form, make sure the field for the war id is populated, and that it's passing the variable by the same name, to that query. Quote Link to comment Share on other sites More sharing options...
Twisted Posted February 11, 2021 Author Share Posted February 11, 2021 Im new to coding and slowly learning to me everything looks alright is there anyway of showing you? maybe youll pick something up I wont? Quote Link to comment Share on other sites More sharing options...
Veramys Posted February 12, 2021 Share Posted February 12, 2021 Post the surrender function in here @Twisted Quote Link to comment Share on other sites More sharing options...
rockwood Posted February 12, 2021 Share Posted February 12, 2021 you need proper validation with try catch stuff Quote Link to comment Share on other sites More sharing options...
Twisted Posted February 12, 2021 Author Share Posted February 12, 2021 function gang_staff_surrender() { global $db,$ir,$c,$userid,$gangdata; if(!isset($_POST['subm'])) { print "<form action='yourgang.php?action=staff&act2=surrender' method='post'> Choose who to surrender to.<br /> <input type='hidden' name='subm' value='submit' /> Gang: <select name='war' type='dropdown'>"; $wq=$db->query("SELECT * FROM gangwars where warDECLARER={$ir['gang']} or warDECLARED={$ir['gang']}"); while($r=$db->fetch_row($wq)) { if($gangdata['gangID'] == $r['warDECLARER']) { $w="You";$f="warDECLARED"; } else { $w="Them";$f="warDECLARER"; } $d=date('F j, Y, g:i:s a',$r['warTIME']); $ggq=$db->query("SELECT * FROM gangs WHERE gangID=".$r[$f]); $them=$db->fetch_row($ggq); print "<option value='{$r['warID']}'>{$them['gangNAME']}</option>"; } print "</select><br /> Message: <input type='text' STYLE='color: black; background-color: white;'name='msg' /><br /> <input type='submit' STYLE='color: black; background-color: white;'value='Surrender' /></form>"; } else { $_POST['war'] = abs((int) $_POST['war']); $wq=$db->query("SELECT * FROM gangwars where warID={$_POST['war']}"); $r=$db->fetch_row($wq); if($gangdata['gangID'] == $r['warDECLARER']) { $w="You";$f="warDECLARED"; } else { $w="Them";$f="warDECLARER"; } $db->query("INSERT INTO surrenders VALUES('',{$_POST['war']},{$ir['gang']},".$r[$f].",'{$_POST['msg']}')"); $ggq=$db->query("SELECT * FROM gangs WHERE gangID=".$r[$f]); $them=$db->fetch_row($ggq); $event=str_replace("'","''","<a href='gangs.php?action=view&ID={$ir['gang']}'>{$gangdata['gangNAME']}</a> have asked to surrender the war against <a href='gangs.php?action=view&ID={$them['gangID']}'>{$them['gangNAME']}</a>"); $db->query("INSERT INTO gangevents VALUES('',{$ir['gang']},unix_timestamp(),'$event') , ('',".$r[$f].",unix_timestamp(),'$event')"); print "You have asked to surrender."; } } function gang_staff_viewsurrenders() { global $db,$ir,$c,$userid,$gangdata; if(!isset($_POST['subm'])) { print "<form action='yourgang.php?action=staff&act2=viewsurrenders' method='post'> Choose who to accept the surrender from.<br /> <input type='hidden' name='subm' value='submit' /> Gang: <select name='sur' type='dropdown'>"; $wq=$db->query("SELECT s.*,w.* FROM surrenders s LEFT JOIN gangwars w ON s.surWAR=w.warID WHERE surTO={$ir['gang']}"); while($r=$db->fetch_row($wq)) { if($gangdata['gangID'] == $r['warDECLARER']) { $w="You";$f="warDECLARED"; } else { $w="Them";$f="warDECLARER"; } $ggq=$db->query("SELECT * FROM gangs WHERE gangID=".$r[$f]); $them=$db->fetch_row($ggq); print "<option value='{$r['surID']}'>War vs. {$them['gangNAME']} (Msg: {$r['surMSG']})</option>"; } print "</select><br /><input type='submit' STYLE='color: black; background-color: white;'value='Accept Surrender' /></form>"; } else { $_POST['sur'] = abs((int) $_POST['sur']); $q=$db->query("SELECT surWAR FROM surrenders WHERE surID={$_POST['sur']}"); list($_POST['war']) = $db->fetch_row($q); $wq=$db->query("SELECT * FROM gangwars where warID={$_POST['war']}"); $r=$db->fetch_row($wq); if($gangdata['gangID'] == $r['warDECLARER']) { $w="You";$f="warDECLARED"; } else { $w="Them";$f="warDECLARER"; } $db->query("DELETE FROM surrenders WHERE surID={$_POST['sur']}"); $db->query("DELETE FROM gangwars WHERE warID={$_POST['war']}"); $ggq=$db->query("SELECT * FROM gangs WHERE gangID=".$r[$f]); $them=$db->fetch_row($ggq); $event=str_replace("'","''","<a href='gangs.php?action=view&ID={$ir['gang']}'>{$gangdata['gangNAME']}</a> have accepted the surrender from <a href='gangs.php?action=view&ID={$them['gangID']}'>{$them['gangNAME']}</a>, the war is over!"); $db->query("INSERT INTO gangevents VALUES('',{$ir['gang']},unix_timestamp(),'$event') , ('',".$r[$f].",unix_timestamp(),'$event')"); print "You have accepted surrender, the war is over."; } } @Veramis Quote Link to comment Share on other sites More sharing options...
Twisted Posted February 18, 2021 Author Share Posted February 18, 2021 issue has been fixed many help for the advice 🙂 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.