-
Posts
166 -
Joined
-
Last visited
-
Days Won
1
Content Type
Profiles
Forums
Events
Everything posted by wrux
-
Well normally you would have to reload the page to see your updated energy and stuff if it's been a few minutes, this will load it automatically without having to reload.
-
This is a subtle modification. It basically just updates the details in the sidebar (energy, hp, money, mail notifications etc) using JSON. I've seen other implementations of this, just getting the entire sidebar which isn't necessary so I just created a nicer way to do it. I have written a more in-depth explanation of it on my dev blog here which explains how to install it in more detail; probably a good idea if you are relatively new. To install this modification it basically requires a few edits to the template and uploading the javascript file and php file. I do not have the latest version of mccodes, so this may be outdated for some, however feel free to update it for me :P Heres the PHP code: <?php /* App: AJAX Vitals Update Author: WRUX Date: 13 May, 2014 Game: MCCodes V2 URL: http://wrux.me/ Version: 1.0 */ session_start(); if(get_magic_quotes_gpc() == 0) { foreach($_POST as $k => $v) { $_POST[$k]=addslashes($v); } foreach($_POST as $k => $v) { $_POST[$k]=addslashes($v); } } // Config include "config.php"; global $_CONFIG; define("MONO_ON", 1); require "class/class_db_{$_CONFIG['driver']}.php"; // DB connection $db=new database; $db->configure($_CONFIG['hostname'], $_CONFIG['username'], $_CONFIG['password'], $_CONFIG['database'], $_CONFIG['persistent']); $db->connect(); $c=$db->connection_id; if(isset($_SESSION['userid']) and !empty($_SESSION['userid'])) { // Get the data and return what is required... $sql = sprintf( "SELECT `level`, `money`, `crystals`, `energy`, `maxenergy`, `will`, `maxwill`, `brave`, `maxbrave`, `hp`, `maxhp`, `new_events`, `new_mail` FROM `users` WHERE `userid` = %u;", $_SESSION['userid'] ); $db->query($sql); if($db->num_rows()) { // fetch the row and construst the return array $user_data = $db->fetch_row(); $user_data['energypercent'] = ($user_data['energy'] / $user_data['maxenergy']) * 100; $user_data['willpercent'] = ($user_data['will'] / $user_data['maxwill']) * 100; $user_data['bravepercent'] = ($user_data['brave'] / $user_data['maxbrave']) * 100; $user_data['hppercent'] = ($user_data['hp'] / $user_data['maxhp']) * 100; // construct the return array including the user data $return = array('success' => true, 'player' => $user_data); } else { // Something wrong with the session, send an error $return = array('success' => false, 'message' => 'You encountered an error'); } } else { // Something wrong with the session, send an error $return = array('success' => false, 'message' => 'There was a problem with the request'); } // Setup JSON headers header('Cache-Control: no-cache, must-revalidate'); header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); header('Content-type: application/json'); // Return the JSON object echo json_encode($return); ?> And heres the JavaScript code: $(function() { /* Update Vitals Interval Code */ function update() { $.getJSON('update_vitals.php', function(data) { if(data.success) { console.log(data); // success so update the UI // the labels are the generic updates we can automate // mail and event counts are also updated using this method $('.label').each(function() { if($(this).data('value')) { $(this).html(eval('data.player.' + $(this).data('value'))); } }); // update the bar widths $('#energy-left').width(data.player.energypercent); $('#energy-right').width(100 - data.player.energypercent); $('#will-left').width(data.player.willpercent); $('#will-right').width(100 - data.player.willpercent); $('#brave-left').width(data.player.bravepercent); $('#brave-right').width(100 - data.player.bravepercent); $('#hp-left').width(data.player.hppercent); $('#hp-right').width(100 - data.player.hppercent); } else { console.log('Update vitals critical error'); } }) .fail(function() { console.log("Update vitals critical error"); }) .always(function() { console.log( "complete" ); }); } // loop every 5 minutes setInterval(function() { update(); }, 300000); });
-
Lol they are selling it for 12.99
-
Whats this ravens, can someone fill me in please? :P
-
The amount of work required would seriously outweigh the benefits for something at most people's level. If you are creating a complex platform then it would probably be a better idea. CakePHP (and any other framework) has a very stable core and with constant updates it is a better idea to use a ready made framework. That being said, it's a great exercise in object oriented programming creating your own framework
-
CakePHP has some awesome documentation, check them out. Other frameworks such as codeignighter miss out on a lot of features but Cake is really good
-
-
I like this game, i've been on it playing too :P
-
I use wordpress for my personal blog because it's such a good platform. If your looking for something a bit different, octopress is an interesting blogging platform man. You can generate the entire thing in about 5 mins and it's not database driven, pretty cool for a lightweight system.
-
United Domains amongst a few others is one of the biggest. GoDaddy is a massive corporation so go with someone else
-
Yea so shhh about the domains your waiting on just incase, probably fine to be fair. I've got a few domains already and waiting on one pre-order at the minute. The big one for me will be the geographic extensions and .blog but most of them are out in like Q4 2015.
-
It's probably not a good idea to tell people about your pre-order, somebody else could technically still purchase it.
-
Haha well sometimes you need folders for all your stuff and things
-
Okay, so i'm at the point in my project development where i'm thinking about the mechanics and what to include so I am posting it in the projects section. I'm working on a number of apps for my game simultaneously and gangs are on that list. I'm not final on anything on my game for the 'release' but i'm slowly working towards a deadline to post a Alpha. What do you think should be on a gang system? I'm working on it and just wondering what kinda stuff aught to be added. For my Alpha release i'm planning on leaving out organised crimes and gang wars, however I think some feedback would be great (any may inspire others). I've attached a screenshot of my gang homepage section and whilst it does not show much, i'm working towards a good system. So far I have: gang tag owner/co-owner armoury vault for money and points gang level which increases the limit for members, armoury and vault noticeboard gang logs image shown to both gang members and non gang members gang background image with customisable repeat (repeat x, y or none) http://i.imgur.com/CoZmRd9.jpg
-
Code the template, you'd make a lot more on it because it looks pretty good
-
Check out webfaction.com With them you get some some sweet resources. I've got a number of python and PHP environments installed on there and theres not many shared hosting services that offer that. You can install most things on there without problems; PIP, easy_install and PEAR (for PHP) are all available and i've even installed NoSQL databases so the skys the limit I guess. ..oh and it costs like $9 a month which is peanuts.
-
Should this be classed as spam?
-
Access to $ir in a PHP script loaded with jQuery load()
wrux replied to dnenb's topic in General Discussion
I know it's not what you posted but why not load only what if required? JSON is super easy with jQuery -
That's what a webhost support is for normally. People on here won't be as useful as them
-
http://foundation.zurb.com is a really good front end framework
-
-
[MENTION=65371]sniko[/MENTION] Yea, the inactive tabs are hard to read. But most of the header looks disjointed, Adding a background colour may change that
-
It's a good idea but the layout is really washed out and hard to read; light text on light backgrounds for example
-
Why not have it parse the first bit to the file and after the / you could parse that as a query string... so /user/view/john would get translated into user.php?query=view/john and you can then parse the querystring through a bunch of code that gets the true values
-
I'm assuming you'd use a HTTP302 and this is okay for the shortrun but longterm you'd want to edit links, this is why mccodes needs a url dispatcher