-
Posts
277 -
Joined
-
Last visited
-
Days Won
2
Content Type
Profiles
Forums
Events
Everything posted by Richard
-
Re: New Houses Mod [Mccodes V2] You're more than welcome, Thanks for commenting. If anyone has any problems with this mod, just let me know, But so far I have not found anything wrong at all :)
-
Re: Battle ladder [Mccodes V2] Thanks for all the nice comments, To add ladders just use phpmyadmin, Its very simple :)
-
Re: New Houses Mod [Mccodes V2] That strange, this mod does not require a cron. And maybe you bought a house from the old estate.php? Which needs to be removed once this mod is added
-
Re: New Houses Mod [Mccodes V2] Well, You will have to change it so it selects the name from owned_houses
-
Re: New Houses Mod [Mccodes V2] :P Thanks Karlos
-
Re: New Houses Mod [Mccodes V2] Removed, code didn't work :P I'll try again later
-
Re: New Houses Mod [Mccodes V2] Thanks :)
-
Re: New Houses Mod [Mccodes V2] Just a quick tip, I fixed a bug which prevented users moving into the houses that they rented. So I advise you all to replace your current houses.php with the one from the first post, Sorry about that.
-
Re: New Houses Mod [Mccodes V2] I don't own a copy of mccodes V2, So I'm not too sure at the moment. But just somewhere with the rest of the queries should be fine
-
Re: New Houses Mod [Mccodes V2] Oh, to add those go into phpmyadmin and create some in the house_upgrades table
-
Re: New Houses Mod [Mccodes V2] Just click add upgrades
-
Re: New Houses Mod [Mccodes V2] Thanks, the post gets updated every now and then, so keep and eye out for them :) Update: [01:18]Added move out function: Just replace houses.php with the one posted about
-
This was created for my game engine, and converted for use with mccodes, this mod includes: - house upgrades - house rentals - multiple houses I have put so much time and effort into this, and I am willing to fix bugs if there are some. Run SQL Data: ALTER TABLE `users` ADD `house` int(11) NOT NULL DEFAULT '0'; CREATE TABLE IF NOT EXISTS `house_upgrades` ( `upgradeId` int(11) NOT NULL AUTO_INCREMENT, `upgradeName` varchar(255) NOT NULL, `upgradeMood` int(11) NOT NULL, `upgradeCost` int(11) NOT NULL, PRIMARY KEY (`upgradeId`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; CREATE TABLE IF NOT EXISTS `owned_houses` ( `uhouseId` int(11) NOT NULL AUTO_INCREMENT, `uhouseOwner` int(11) NOT NULL, `uhouseHouse` int(11) NOT NULL, `uhouseMood` int(11) NOT NULL, `uhouseRent` int(11) NOT NULL, `uhouseRTime` int(11) NOT NULL, `uhouseTenant` int(11) NOT NULL, PRIMARY KEY (`uhouseId`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; CREATE TABLE IF NOT EXISTS `owned_upgrades` ( `ownupId` int(11) NOT NULL AUTO_INCREMENT, `ownupHouse` int(11) NOT NULL, `ownupUpgrade` int(11) NOT NULL, PRIMARY KEY (`ownupId`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; Add into cron_day.php $houses = mysql_query(sprintf("SELECT * FROM `owned_houses` LEFT JOIN `users` ON (`userid` = `uhouseTenant`) WHERE `uhouseTenant` > '0'")); while ($r = mysql_fetch_array($houses)) { mysql_query("UPDATE `owned_houses` SET `uhouseRTime` = `uhouseRTime` - '1' WHERE `uhouseRTime` > '0'"); mysql_query(sprintf("UPDATE `users` SET `money` = `money` - '%d' WHERE `userid` = '%u'", $r['uhouseRent'], $r['uhouseTenant'])); mysql_query("UPDATE `owned_houses` SET `uhouseTenant` = '0' WHERE `uhouseRTime` <= '0'"); } Create houses.php: <?php include_once('globals.php'); echo '<p class="heading">Your Houses</p>'; switch ($_GET['page']) { case 'move': move_house(); break; case 'move_out': move_out(); break; case 'estate': estate_agent(); break; case 'sell': sell_house(); break; case 'rentals': rental_market(); break; case 'rent': rent_house(); break; case 'upgrade': upgrade_house(); break; default: houses_index(); break; } function houses_index() { global $ir; $houses = mysql_query(sprintf("SELECT * FROM `owned_houses` LEFT JOIN `houses` ON (`hID` = `uhouseHouse`) LEFT JOIN `users` ON (`userid` = `uhouseOwner`) WHERE (`uhouseOwner` = '%u' || `uhouseTenant` = '%u') AND `uhouseId` != '%d'", $ir['userid'], $ir['userid'], $ir['house'])); echo '<table width="600"> <tr> <td width="50%" align="center">[url="houses.php?page=estate"]Estate agent[/url]</td> <td width="50%" align="center">[url="houses.php?page=rentals"]Rent a house[/url]</td> </tr> </table> '; if($ir['house']) { $fetch = mysql_query(sprintf("SELECT * FROM `owned_houses` LEFT JOIN `houses` ON (`hID` = `uhouseHouse`) WHERE (`uhouseId` = '%u')", $ir['house'])); $h = mysql_fetch_assoc($fetch); echo '[b]Current house:[/b] <table width="300" class="table"> <tr> <th width="50%">Current house</th> <th width="50%">Move out</th> </tr> <tr> <td>'.stripslashes($h['hNAME']).'</td> <td>[url="houses.php?page=move_out"]Move out[/url]</td> </tr> </table> '; } echo '<table width="600" class="table"> <tr> <th width="25%">House name</th> <th width="25%">Owner</th> <th width="25%">Mood value</th> <th width="25%">Manage</th> </tr>'; if(!mysql_num_rows($houses)) { echo '<tr> <td colspan="5">You have no houses at this time, purchase one at the estate agent\'s.</td> </tr>'; } while($r = mysql_fetch_assoc($houses)) { echo '<tr> <td>'.stripslashes($r['hNAME']).'</td> <td>[url="viewuser.php?u='.$r['userid'].'"]'.stripslashes($r['username']).'[/url]</td> <td>'.number_format($r['uhouseMood']).' mood bar</td> <td>[url="houses.php?page=move&id='.$r['uhouseId'].'"]Move in[/url] [url="houses.php?page=sell&id='.$r['uhouseId'].'"]Sell house[/url] [url="houses.php?page=rent&id='.$r['uhouseId'].'"]Rent house[/url] [url="houses.php?page=upgrade&id='.$r['uhouseId'].'"]Add upgrades[/url]</td> </tr>'; } echo '</table>'; } function move_house() { global $ir; $fetch = mysql_query(sprintf("SELECT * FROM `owned_houses` LEFT JOIN `houses` ON (`hID` = `uhouseHouse`) LEFT JOIN `users` ON (`userid` = `uhouseOwner`) WHERE (`uhouseId` = '%u')", abs((int) $_GET['id']))); if(!isset($_GET['id'])) { echo 'You did not select a house to move in to.'; } else if(!mysql_num_rows($fetch)) { echo 'You cannot move into a non-existant house.'; } else { $r = mysql_fetch_assoc($fetch); if($r['uhouseOwner'] != $ir['userid'] AND $r['uhouseTenant'] != $ir['userid']) { echo 'You are not permitted to move into this house.'; } else if($r['uhouseRTime'] AND $r['uhouseOwner'] == $ir['userid']) { echo 'You cannot move into a house while it is being rented to another member.'; } else { mysql_query(sprintf("UPDATE `users` SET `house` = '%d', `maxwill` = '%d' WHERE (`userid` = '%u')", abs((int) $_GET['id']), $r['uhouseMood'], $ir['userid'])); echo 'You have moved into the '.stripslashes($r['hNAME']).', You now have a maximum mood bar of '.number_format($r['uhouseMood']).'.'; } } } function move_out() { global $ir; $fetch = mysql_query(sprintf("SELECT * FROM `owned_houses` LEFT JOIN `houses` ON (`hID` = `uhouseHouse`) LEFT JOIN `users` ON (`userid` = `uhouseOwner`) WHERE (`uhouseId` = '%u')", $ir['house'])); if(!mysql_num_rows($fetch)) { echo 'You cannot move out of a non-existant house.'; } else { $r = mysql_fetch_assoc($fetch); if($r['uhouseOwner'] != $ir['userid'] AND $r['uhouseTenant'] != $ir['userid']) { echo 'You are not permitted to move out of this house.'; } else { mysql_query(sprintf("UPDATE `users` SET `house` = '0', `maxwill` = '100' WHERE (`userid` = '%u')", $ir['userid'])); echo 'You have moved out of the '.stripslashes($r['hNAME']).', You now have a maximum mood bar of 100.'; } } } function sell_house() { global $ir; $fetch = mysql_query(sprintf("SELECT * FROM `owned_houses` LEFT JOIN `houses` ON (`hID` = `uhouseHouse`) LEFT JOIN `users` ON (`userid` = `uhouseOwner`) WHERE (`uhouseOwner` = '%u') AND (`uhouseId` = '%u')", $ir['userid'], abs((int) $_GET['id']))); if(!isset($_GET['id'])) { echo 'You did not select a house to sell.'; } else if(!mysql_num_rows($fetch)) { echo 'You cannot attempt to sell a non-existant house.'; } else { $r = mysql_fetch_assoc($fetch); if($r['uhouseOwner'] != $ir['userid']) { echo 'You do not own this house, so don\'t attempt to sell it.'; } else if($r['uhouseTenant']) { echo 'You cannot sell a house while it is being rented to another member.'; } else { mysql_query(sprintf("UPDATE `users` SET `money` = `money` + '%d' WHERE (`userid` = '%u')", $r['houseCost'], $ir['userid'])); mysql_query(sprintf("DELETE FROM `owned_houses` WHERE (`uhouseId` = '%u')", abs((int) $_GET['id']))); echo 'You have sold the '.stripslashes($r['hNAME']).' for a total of $'.number_format($r['hPRICE']).'.'; } } } function estate_agent() { global $ir; if(isset($_GET['id'])) { $house = mysql_query(sprintf("SELECT * FROM `houses` WHERE (`hID` = '%u')", abs((int) $_GET['id']))); $r = mysql_fetch_assoc($house); if(!mysql_num_rows($house)) { echo 'You cannot attempt to purchase a non-existant house.'; } else if($ir['money'] < $r['hPRICE']) { echo 'You cannot afford to purchase this house right now, come back another time.'; } else { mysql_query(sprintf("UPDATE `users` SET `money` = `money` - '%d' WHERE (`userid` = '%u')", $r['hPRICE'], $ir['userid'])); mysql_query(sprintf("INSERT INTO `owned_houses` (`uhouseId`, `uhouseOwner`, `uhouseHouse`, `uhouseMood`) VALUES ('NULL','%u', '%d', '%d')", $ir['userid'], $r['hID'], $r['hWILL'])); echo 'You have purchased the '.stripslashes($r['hNAME']).' for a total of $'.number_format($r['houseCost']).'!'; } } else { $houses = mysql_query(sprintf("SELECT * FROM `houses` ORDER BY `hWILL` ASC")); echo '<table width="600" class="table"> <tr> <th>House name</th> <th>Mood value</th> <th>Cost</th> </tr>'; while($r = mysql_fetch_assoc($houses)) { echo '<tr> <td>[url="houses.php?page=estate&id='.$r['hID'].'"]'.stripslashes($r['hNAME']).'[/url]</td> <td>'.number_format($r['hWILL']).' mood bar</td> <td>$'.number_format($r['hPRICE']).'</td> </tr>'; } print '</table>'; } } function rental_market() { global $ir; if(isset($_GET['id'])) { $house = mysql_query(sprintf("SELECT * FROM `owned_houses` LEFT JOIN `houses` ON (`hID` = `uhouseHouse`) LEFT JOIN `users` ON (`userid` = `uhouseOwner`) WHERE (`uhouseId` = '%u')", abs((int) $_GET['id']))); $r = mysql_fetch_assoc($house); if(!mysql_num_rows($house)) { echo 'You cannot rent a house that does not exist.'; } else if($r['uhouseOwner'] == $ir['userid']) { echo 'You own this house at this time, You cannot rent it aswell.'; } else { mysql_query(sprintf("UPDATE `owned_houses` SET `uhouseTenant` = '%d' WHERE (`uhouseId` = '%u')", $ir['userid'], abs((int) $_GET['id']))); echo 'You are now renting the '.stripslashes($r['hNAME']).' for a total of $'.number_format($r['uhouseRent']).' each night!'; } } else { $houses = mysql_query(sprintf("SELECT * FROM `owned_houses` LEFT JOIN `houses` ON (`hID` = `uhouseHouse`) LEFT JOIN `users` ON (`userid` = `uhouseOwner`) WHERE `uhouseTenant` = '0' AND `uhouseRent` > '0' ORDER BY `uhouseRent` ASC")); echo '<table width="600" class="table"> <tr> <th>House name</th> <th>Owner</th> <th>Mood value</th> <th>Cost each night</th> <th>Rental time</th> <th>Manage</th> </tr>'; while($r = mysql_fetch_assoc($houses)) { echo '<tr> <td>'.stripslashes($r['hNAME']).'</td> <td>[url="userprofile.php?id='.$r['userid'].'"]'.stripslashes($r['username']).'[/url]</td> <td>'.number_format($r['uhouseMood']).' mood bar</td> <td>$'.number_format($r['uhouseRent']).'</td> <td>'.number_format($r['uhouseRTime']).' nights</td> <td>[url="houses.php?page=rentals&id='.$r['uhouseId'].'"]Rent house[/url]</td> </tr>'; } print '</table>'; } } function rent_house() { global $ir; $fetch = mysql_query(sprintf("SELECT * FROM `owned_houses` LEFT JOIN `houses` ON (`hID` = `uhouseHouse`) LEFT JOIN `users` ON (`userid` = `uhouseOwner`) WHERE (`uhouseOwner` = '%u') AND (`uhouseId` = '%u')", $ir['userid'], abs((int) $_GET['id']))); if(!isset($_GET['id'])) { echo 'You did not select a house to rent out to members.'; } else if(!mysql_num_rows($fetch)) { echo 'You cannot attempt to rent out a non-existant house.'; } else { $r = mysql_fetch_assoc($fetch); if($r['uhouseOwner'] != $ir['userid']) { echo 'You do not own this house, so don\'t attempt to rent it out to people.'; } else if($r['uhouseTenant']) { echo 'You cannot rent out a house while it is being rented to another member.'; } else { if(isset($_POST['time']) AND isset($_POST['cost'])) { mysql_query(sprintf("UPDATE `owned_houses` SET `uhouseRent` = '%d', `uhouseRTime` = '%d' WHERE (`uhouseId` = '%u')", abs((int) $_POST['cost']), abs((int) $_POST['time']), abs((int) $_GET['id']))); echo 'You have added the '.stripslashes($r['hNAME']).' the the rental market at a cost of $'.number_format($_POST['cost']).' per night.'; } else { echo '<form action="houses.php?page=rent&id='.$_GET['id'].'" method="post"> <table width="600"> <tr> <td>[b]Amount of nights:[/b]</td> <td><input type="text" name="time" value="30" /></td> </tr> <tr> <td>[b]Cost per nights:[/b]</td> <td><input type="text" name="cost" value="250" /></td> </tr> <tr> <td colspan="2" align="center"><input type="submit" value="Submit rental" /></td> </tr> </table> </form>'; } } } } function upgrade_house() { global $ir; if(!isset($_POST['id'])) { if(isset($_GET['id'])) { echo '<form action="houses.php?page=upgrade&id='.$_GET['id'].'" method="post" name="upgrades"> <table class="table" width="600"> <tr> <th width="45%">Upgrade name</th> <th width="25%">Mood gain</th> <th width="25%">Cost</th> <th width="5%"></th> </tr>'; $fetch = mysql_query("SELECT * FROM `house_upgrades` ORDER BY `upgradeMood` ASC"); while ($r = mysql_fetch_assoc($fetch)) { echo '<tr> <td>'.stripslashes($r['upgradeName']).'</td> <td>'.number_format($r['upgradeMood']).' mood</td> <td>$'.number_format($r['upgradeCost']).'</td> <td><input type="radio" name="id" value="'.$r['upgradeId'].'" onClick="document.upgrades.submit();" /></td> </tr>'; } echo '</table>'; } else { echo 'You did not select a house to add upgrades to.'; } } else { $upgrade = mysql_query(sprintf("SELECT * FROM `house_upgrades` WHERE `upgradeId` = '%u'", abs((int) $_POST['id']))); if(!mysql_num_rows($upgrade)) { echo 'This upgrade does not exist at this time, if this problem continues report it to staff.'; } else if(!isset($_GET['id'])) { echo 'You did not select a house to add upgrades to.'; } else { $house = mysql_query(sprintf("SELECT * FROM `owned_houses` LEFT JOIN `houses` ON (`hID` = `uhouseHouse`) LEFT JOIN `users` ON (`userid` = `uhouseOwner`) WHERE (`uhouseId` = '%u')", abs((int) $_GET['id']))); $h = mysql_fetch_assoc($house); $r = mysql_fetch_array($upgrade); if(!mysql_num_rows($house)) { echo 'You cannot add upgrades to a non-existant house.'; } else if($h['uhouseOwner'] != $ir['userid']) { echo 'You are not permitted to add upgrades to this house.'; } else if($ir['money'] < $r['upgradeCost']) { echo 'You do not have enough cash to purchase this upgrade right now.'; } else { $check = mysql_query(sprintf("SELECT * FROM `owned_upgrades` WHERE (`ownupHouse` = '%u') AND (`ownupUpgrade` = '%d')", abs((int) $_GET['id']), abs((int) $_POST['id']))); if(mysql_num_rows($check)) { echo 'This house has this upgrade at this time, it cannot be bought again.'; } else { mysql_query(sprintf("UPDATE `users` SET `money` = `money` - '%d' WHERE `userid` = '%u'", $r['upgradeCost'], $ir['userid'])); mysql_query(sprintf("UPDATE `owned_houses` SET `uhouseMood` = `uhouseMood` + '%d' WHERE `uhouseId` = '%u'", $r['upgradeMood'], abs((int) $_GET['id']))); mysql_query(sprintf("INSERT INTO `owned_upgrades` (`ownupId`, `ownupHouse`, `ownupUpgrade`) VALUES ('NULL','%u', '%d')", abs((int) $_GET['id']), abs((int) $_POST['id']))); echo 'You have purchased the '.stripslashes($r['upgradeName']).' for $'.number_format($r['upgradeCost']).'.'; } } } } } $h->endpage(); ?> Not tested right now, so let me know if there are bugs
-
Re: Ask Staff [Mccodes V2] Click the view questions link and post a responce
-
Re: Ask Staff [Mccodes V2] Just run that data in phpmyadmin
-
Re: Battle ladder [Mccodes V2] Thanks :)
-
Re: Ask Staff [Mccodes V2] Thanks again Yubi, I always appreciate feedback and opinions :)
-
Re: Ask Staff [Mccodes V2] Yeah, I guess so :P I just prefer it like this to be honest, That way any member of staff can access the questions instead of just one. They could, but this is more like a short approach to ingame ticketing. Well done once again! :) Thanks!
-
Simple mod, allows users to ask questions to the staff. Staff can then send a reply back to them, Tested and works fine. Run SQL Data: CREATE TABLE IF NOT EXISTS `staff_questions` ( `questionId` int(11) NOT NULL AUTO_INCREMENT, `questionMember` int(11) NOT NULL, `questionSubject` varchar(255) NOT NULL, `questionText` text NOT NULL, `questionResponce` text NOT NULL, `questionStaff` int(11) NOT NULL, `questionTime` int(11) NOT NULL, PRIMARY KEY (`questionId`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 Create askstaff.php: <?php include_once('globals.php'); echo '<style type="text/css"> #question { border : 1px solid #222222; background-color : #eeeeee; color : #222222; margin : 0 auto 0 auto; padding : 8px; text-align : left; width : 600px; } </style> <h2>Ask staff</h2>'; if($ir['user_level'] == '2') { echo '[url="'.$_SERVER['PHP_SELF'].'?page=view"]View unanswered questions[/url] '; } switch($_GET['page']) { case 'submit': submit_question(); break; case 'view': view_questions(); break; case 'respond': respond_question(); break; default: ask_staff(); break; } function ask_staff() { global $ir; $sql = mysql_query(sprintf("SELECT * FROM `staff_questions` LEFT JOIN `users` ON (`userid` = `questionStaff`) WHERE `questionMember` = '%u' ORDER BY `questionTime` DESC LIMIT 5", $ir['userid'])); if(!mysql_num_rows($sql)) { echo 'You have not submitted a question to ask the staff at this time. '; } else { while($r = mysql_fetch_assoc($sql)) { $sent = date('d-m-Y, g:i:s A', $r['questionTime']); echo '<div id="question">[b]'.stripslashes($r['questionSubject']).' - sent at '.$sent.'[/b] [b]You asked:[/b] '.stripslashes($r['questionText']).' '; if(!$r['questionStaff']) { echo '<span style="color: #800000;">Pending responce...</span>'; } else { echo '[b]'.$r['username'].' replied:[/b] <span style="color: #008000;">'.stripslashes($r['questionResponce']).'</span>'; } echo '</div> '; } } contact_form(); } function contact_form() { global $ir; if(!isset($_POST['question'])) { echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post"> <table width="600"> <tr><th colspan="3" align="left">Ask a question:</th></tr> <tr> <td>Subject:</td> <td><input type="text" name="subject" size="50" maxlength="50" /></td> </tr> <tr> <td valign="top">Question:</td> <td><textarea rows="6" cols="60" name="question"></textarea></td> </tr> <tr><th colspan="2" align="center"><input type="submit" value="Submit" /></th></tr> </table> </form>'; } else { $question = str_replace(array("\n"), array(" "), strip_tags($_POST['question'])); $subject = str_replace(array("\n"), array(" "), strip_tags($_POST['subject'])); mysql_query(sprintf("INSERT INTO `staff_questions` (`questionId`, `questionMember`, `questionSubject`, `questionText`, `questionTime`) VALUES ('NULL', '%u', '%s', '%s', '%d')", $ir['userid'], $subject, $question, time())); echo 'Your question was submitted, a responce will be given when a staff member is available.'; } } function respond_question() { global $ir; if($ir['user_level'] != '2') { echo 'You are not permitted to access this section of the page.'; } else if(!isset($_GET['id'])) { echo 'You did not choose a question to respond to.'; } else if(!isset($_POST['responce'])) { echo '<form action="'.$_SERVER['PHP_SELF'].'?page=respond&id='.$_GET['id'].'" method="post"> <table width="600"> <tr><th colspan="3" align="left">Respond to a question:</th></tr> <tr> <td>Question:</td> <td><input type="text" name="id" size="5" maxlength="5" value="'.$_GET['id'].'" /></td> </tr> <tr> <td valign="top">Responce:</td> <td><textarea rows="6" cols="60" name="responce"></textarea></td> </tr> <tr><th colspan="2" align="center"><input type="submit" value="Send responce" /></th></tr> </table> </form>'; } else { $responce = str_replace(array("\n"), array(" "), strip_tags($_POST['responce'])); mysql_query(sprintf("UPDATE `staff_questions` SET `questionStaff` = '%u', `questionResponce` = '%s' WHERE `questionId` = '%u'", $ir['userid'], $responce, abs((int) $_POST['id']))); echo 'Your responce was given to the question.'; } } function view_questions() { global $ir; $sql = mysql_query("SELECT * FROM `staff_questions` LEFT JOIN `users` ON (`userid` = `questionMember`) WHERE `questionStaff` = '0' ORDER BY `questionTime` DESC LIMIT 5"); if(!mysql_num_rows($sql)) { echo 'There are no unanswered questions at this time. '; } else { while($r = mysql_fetch_assoc($sql)) { $sent = date('d-m-Y, g:i:s A', $r['questionTime']); echo '<div id="question">[b]'.stripslashes($r['questionSubject']).' - sent at '.$sent.'[/b] [b]'.$r['username'].' asked:[/b] '.stripslashes($r['questionText']).' [url="'.$_SERVER['PHP_SELF'].'?page=respond&id='.$r['questionId'].'"]Post a responce[/url]</div> '; } } } $h->endpage(); ?>
-
Re: Battle ladder [Mccodes V2] No code required for cron, Just take that out of another cron in mccodes v2 if you want the code :) Also, I'm not too sure, I've never been good with crons tbh. A guess of what it might be: 0 0 0 0 */7 curl http://www.game.com/battle_cron.php
-
Re: Battle ladder [Mccodes V2] Thanks :)
-
I spent a while on this, haven't tested it much but should work fine ? 1:41 AM: Cron updated - fixed a minor bug in the cron. Replace the old one Run SQL: CREATE TABLE IF NOT EXISTS `battle_ladders` ( `ladderId` int(11) NOT NULL AUTO_INCREMENT, `ladderName` varchar(255) NOT NULL DEFAULT '', `ladderLevel` int(11) NOT NULL, PRIMARY KEY (`ladderId`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; CREATE TABLE IF NOT EXISTS `battle_members` ( `bmemberId` int(11) NOT NULL AUTO_INCREMENT, `bmemberUser` int(11) NOT NULL, `bmemberLadder` int(11) NOT NULL, `bmemberScore` int(11) NOT NULL, `bmemberWins` int(11) NOT NULL, `bmemberLosses` int(11) NOT NULL, PRIMARY KEY (`bmemberId`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; Create battle_ladder.php: <?php include_once ('globals.php'); switch($_GET['page']) { case 'signup': ladder_signup(); break; default: ladder_index(); break; } function ladder_index() { global $ir, $db; if(!isset($_GET['id'])) { echo '<h2>Battle Ladder</h2> [url="battle_ladder.php?page=signup"][b]Join a ladder[/b][/url] <table width="300"> <tr> <td>'; $fetch = $db->query("SELECT * FROM `battle_ladders` ORDER BY `ladderLevel` ASC"); while ($r = $db->fetch_row($fetch)) { $count ++; echo $count.'. [url="battle_ladder.php?id='.$r['ladderId'].'"]'.stripslashes($r['ladderName']).'[/url] (Level '.$r['ladderLevel'].' Required) '; } echo '</td> </tr> </table>'; } else { $fetch = $db->query(sprintf("SELECT * FROM `battle_members` LEFT JOIN `users` ON `userid` = `bmemberUser` WHERE `bmemberLadder` = '%u' ORDER BY `bmemberScore` DESC", abs((int) $_GET['id']))); if(!$db->num_rows($fetch)) { echo 'This battle ladder does not exist at this time, or there are no members using the ladder at this time.'; } else { echo '<table width="600" class="table"> <tr> <th width="10%">Rank</th> <th width="40%">Name</th> <th width="20%">Score</th> <th width="15%">Wins</th> <th width="15%">Losses</th> </tr>'; while($r = $db->fetch_row($fetch)) { $count ++; echo '<tr> <td align="center">'.$count.'</td> <td>[url="viewuser.php?u='.$r['userid'].'"]'.$r['username'].'[/url]</td> <td>'.number_format($r['bmemberScore']).'</td> <td>'.$r['bmemberWins'].'</td> <td>'.$r['bmemberLosses'].'</td> </tr>'; } } } } function ladder_signup() { global $ir, $db; if(!isset($_GET['id'])) { echo '<h2>Join a ladder</h2> You are qualified to join one of the ladders shown below. <table width="300"> <tr> <td>'; $fetch = $db->query(sprintf("SELECT * FROM `battle_ladders` WHERE `ladderLevel` <= '%d' ORDER BY `ladderLevel` ASC", $ir['level'])); while ($r = $db->fetch_row($fetch)) { echo '[url="battle_ladder.php?page=signup&id='.$r['ladderId'].'"]'.stripslashes($r['ladderName']).'[/url] '; } echo '</td> </tr> </table>'; } else { $check = $db->query(sprintf("SELECT * FROM `battle_members` WHERE `bmemberUser` = '%u'", $ir['userid'])); if($db->num_rows($check)) { echo 'You are part of another ladder at this time, wait for that to finish before joining another.'; } else { $sql = $db->query(sprintf("SELECT * FROM `battle_ladders` WHERE `ladderId` = '%u'", abs((int) $_GET['id']))); $r = $db->fetch_row($sql); if($r['ladderLevel'] > $ir['level']) { echo 'You are not experienced enough to join this ladder right now.'; } else { $db->query(sprintf("INSERT INTO `battle_members` (`bmemberId`, `bmemberUser`, `bmemberLadder`, `bmemberScore`) VALUES ('NULL','%u', '%d', '%d')", $ir['userid'], $r['ladderId'], 100)); echo 'You have signed up to the '.stripslashes($r['ladderName']).', attack other members of that ladder to increase the score.'; } } } } $h->endpage(); ?> In attackwon.php find: $db->query("INSERT INTO attacklogs VALUES('',$userid,{$_GET['ID']},'won',unix_timestamp(),$stole,'$atklog');"); Add below that: $chk_one = $db->query(sprintf("SELECT * FROM `battle_members` WHERE `bmemberUser` = '%u'", $ir['userid'])); $chk_two = $db->query(sprintf("SELECT * FROM `battle_members` WHERE `bmemberUser` = '%u'", $r['userid'])); if (mysql_num_rows($chk_one) AND mysql_num_rows($chk_two)) { $score = rand(12, 24); $db->query(sprintf("UPDATE `battle_members` SET `bmemberScore` = `bmemberScore` - '%d', `bmemberLosses` = `bmemberLosses` + '1' WHERE `bmemberUser` = '%u'", $score, $r['userid'])); $db->query(sprintf("UPDATE `battle_members` SET `bmemberScore` = `bmemberScore` + '%d', `bmemberWins` = `bmemberWins` + '1' WHERE `bmemberUser` = '%u'", $score, $ir['userid'])); echo 'You have added '.$score.' points to the score on the battle ladder, well done. '; } In attacklost.php find: $db->query("INSERT INTO attacklogs VALUES('',$userid,{$_GET['ID']},'lost',unix_timestamp(),0,'$atklog');"); Add below that: $chk_one = $db->query(sprintf("SELECT * FROM `battle_members` WHERE `bmemberUser` = '%u'", $ir['userid'])); $chk_two = $db->query(sprintf("SELECT * FROM `battle_members` WHERE `bmemberUser` = '%u'", $r['userid'])); if (mysql_num_rows($chk_one) AND mysql_num_rows($chk_two)) { $score = rand(12, 24); $db->query(sprintf("UPDATE `battle_members` SET `bmemberScore` = `bmemberScore` - '%d', `bmemberLosses` = `bmemberLosses` + '1' WHERE `bmemberUser` = '%u'", $score, $ir['userid'])); $db->query(sprintf("UPDATE `battle_members` SET `bmemberScore` = `bmemberScore` + '%d', `bmemberWins` = `bmemberWins` + '1' WHERE `bmemberUser` = '%u'", $score, $r['userid'])); echo 'You have lost '.$score.' points from the score on the battle ladder, bad luck. '; } Create battle_cron.php <?php include "config.php"; global $_CONFIG; define("MONO_ON", 1); require "class/class_db_{$_CONFIG['driver']}.php"; $db=new database; $db->configure($_CONFIG['hostname'], $_CONFIG['username'], $_CONFIG['password'], $_CONFIG['database'], $_CONFIG['persistent']); $db->connect(); $c=$db->connection_id; include "global_func.php"; $fetch = $db->query("SELECT * FROM `battle_ladders` ORDER BY `ladderLevel` ASC"); while($ft = $db->fetch_row($fetch)) { $count = 0; $sql = $db->query(sprintf("SELECT * FROM `battle_members` LEFT JOIN `users` ON `userid` = `bmemberUser` WHERE `bmemberLadder` = '%u' ORDER BY `bmemberScore` DESC LIMIT 10", $ft['ladderId'])); while($r = $db->fetch_row($sql)) { $count ++; $cash = ((((rand(500000, 750000) / 10) * $r['level']) / $count) * ($ft['ladderLevel'] + 1)); $points = ((((rand(120, 250) / 10) * $r['level']) / $count) * ($ft['ladderLevel'] + 1)); if($r['userid']) { $db->query(sprintf("UPDATE `users` SET `money` = `money` + '%d', `crystals` = `crystals` + '%d' WHERE `userid` = '%u'", $cash, $points, $r['bmemberUser'])); event_add($r['bmemberUser'], 'You have earned $'.number_format($cash).' and '.number_format($points).' Points for achieveing rank #'.$count.' in the '.$ft['ladderName'].' ladder!'); } } } $db->query("TRUNCATE TABLE battle_members;"); ?>
-
Re: [Mccodes Lite] Jobs Thanks Noelle, Sounds like a nice idea :)
-
Re: [Mccodes Lite] Jobs :P Thanks Miniman, Not sure I'll be making too many mods though, Don't have the time or patience anymore.
-
Re: [Mccodes Lite] Jobs Another screenshot (Includes specials)