PureKing Posted May 16, 2011 Share Posted May 16, 2011 I don't need to go into great length about it, but I'm not that great at php. I don't expect anyone to code for me, or even to teach me. However, In editing a mod, I have encountered a problem when trying to edit "yourgang.php" the code is as followed. global $db,$ir,$c,$userid,$gangdata; if(isset($_POST['subm'])) { $_POST['gang'] = abs((int) $_POST['gang']); if ($gangdata {$_POST['gang']}['status'] = 'Peaceful') { die("You can't go to war with peaceful clans!"); } { $db->query("INSERT INTO gangwars VALUES('',{$ir['gang']},{$_POST['gang']},unix_timestamp())"); $ggq=$db->query("SELECT * FROM gangs WHERE gangID={$_POST['gang']}"); $them=$db->fetch_row($ggq); $event=str_replace("'","''","<a href='gangs.php?action=view&ID={$ir['gang']}'>{$gangdata['gangNAME']}</a> declared war on <a href='gangs.php?action=view&ID={$_POST['gang']}'>{$them['gangNAME']}</a>"); $db->query("INSERT INTO gangevents VALUES('',{$ir['gang']},unix_timestamp(),'$event') , ('',{$_POST['gang']},unix_timestamp(),'$event')"); print "You have declared war!"; The code that I added was if ($gangdata {$_POST['gang']}['status'] = 'Peaceful') { die("You can't go to war with peaceful clans!"); I'm trying to develop to mod the file where clans can only declare on aggressive clans. (clans that are already in the warring mod) Long story short, this is not working, as the code simply does not let me declare war at all. (which is some success in my book.) Likewise, I have already modified the gangs sql for the "aggressive" and "peaceful" status using ALTER TABLE users ADD status enum('Peaceful','Aggressive')NOT NULL 'Peaceful' If anyone could give me some friendly advice point out what I'm doing wrong, and possibly how to correct it, I would be very appreciative. Thanks. Quote Link to comment Share on other sites More sharing options...
Djkanna Posted May 17, 2011 Share Posted May 17, 2011 ALTER TABLE `gangs` ADD `status` ENUM ( 'Peaceful', 'Aggressive') NOT NULL DEFAULT 'Peaceful' $gangStatus = $db->fetch_single($db->query('SELECT `status` FROM `gangs` WHERE (`gangID` = '.$_POST['gang'].')')); if ($gangStatus == 'Peaceful') { //Nope no war can be declared la. } Try something along these lines. (: 1 Quote Link to comment Share on other sites More sharing options...
PureKing Posted May 17, 2011 Author Share Posted May 17, 2011 Thanks buddy, it works perfectly. Quote Link to comment Share on other sites More sharing options...
Djkanna Posted May 17, 2011 Share Posted May 17, 2011 No problem. :) Quote Link to comment Share on other sites More sharing options...
PureKing Posted May 20, 2011 Author Share Posted May 20, 2011 (edited) instead of re-posting a thread, I'll just reuse this one if that's all right. Once again, I apologize for being a "noob" at coding. At the current state, I'm trying to add an item that will increase bank interest rates. The item is already in the game, and it's ID happens to be 5. It was made through the staff panel. It's more than likely going to be a donator incentive item to be quite honest. I understand that bank interest is a massive cause of inflation, so I would like to limit it. Anyways, here is the code that I'm working with, it doesn't work needless to say, I know I have the syntax wrong/out of order. $interestVoucher = $db->fetch_single($db->query('SELECT `inv_itemid` FROM `inventory`')); if ($interestVoucher=='5'){ $db->query("UPDATE users SET bankmoney=bankmoney+(bankmoney/25) where bankmoney>0") ;} Of course it would be added to Cron_day.php, but the code itself is wrong. Thanks for the communities patience, hopefully I can be more of an contributor instead of a leecher once my knowledge expands. Edited May 20, 2011 by PureKing Edited the code slightly, it was worse. ;o Quote Link to comment Share on other sites More sharing options...
Djkanna Posted May 20, 2011 Share Posted May 20, 2011 Maths isn't my strongest suit, so I am using yours. :D $checkItem = $db->query('SELECT `inv_userid` FROM `inventory` WHERE (`inv_itemid` = 5)'); if ($db->num_rows($checkItem)) { $creditedUsers = array(); //Fix for duplicate inventory items (just in case) while ($user = $db->fetch_row($checkItem)) { if (!in_array ($user['inv_userid'], $creditedUsers)) { $db->query('UPDATE `users` SET `bankmoney` = `bankmoney` + (`bankmoney` / 25) WHERE (`userid` = '.$user['inv_userid'].' && `bankmoney` > 0)'); array_push($creditedUsers, $user['inv_userid']); } } } Quote Link to comment Share on other sites More sharing options...
PureKing Posted May 21, 2011 Author Share Posted May 21, 2011 Thanks again Dj, you've been a great help. I think I'll read over some mysql tutorials now. ;) Quote Link to comment Share on other sites More sharing options...
Djkanna Posted May 21, 2011 Share Posted May 21, 2011 No problem. :) 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.