Jump to content

Some help?


Recommended Posts

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;
$_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']}");
$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.


Link to comment
Share on other sites

 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. (:

  • Like 1
Link to comment
Share on other sites

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 by PureKing
Edited the code slightly, it was worse. ;o
Link to comment
Share on other sites

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']);
Link to comment
Share on other sites

Join the conversation

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

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...