Jump to content
MakeWebGames

Recommended Posts

Posted

Looking to throw a monkey wrench in the McCodes world by re-writing the lite version and giving it away. It pains me to watch so called experts here front about how great of coders they are then post a free mods with a programming style of McCodes. Am I the only one who wants to stab their eyes out when they see McCodes style programming? So the only thing I can think of is to re-write the damn thing and make it secure and FREE.

The code is based on the Lite version because that is released under the GPL so I can re-write it without breaking any laws ;) I took Nyna's db class, added my own SQLSafe method to clean SQL strings and then re-named most of the functions to work like ADODB (as that is the class I use normally but it's a memory hog). The new version also uses Smarty templates! Yes the whole site is in template files, no not header / footer quasi BS templates but actual templates you can munge and change at your desire and whim.

This version, which I'm calling McCodes LiteFU (ok it's a working title), will give any laymen the ability to start a McCodes site without having to worry about it being hacked. If I see one more post about "I've been hacked please help" and then everyone rushing to cash in I'm going to lose it. The first release will mimic the lite version, hopefully, with time allotted I will release some of the cool free mods here for the engine. My hope though is people here will pick up here with the free codes and expand it rather then the standard McCodes.

Let me be very specific here this is a new code base! Mods for lite, v1 and v2 will NOT work with this code base. Trying to secure the base McCodes or getting it to work within the mccodes structure is a fools errand, it's either start fresh or don't bother. The only thing that remains the same is the database, so if you have a lite game you could over write the code with this and it'll work.

For your preview..

travel.php (aka monorail.php in lite)

include_once '/../include/accesscontrol.php';
include_once '/../include/common.lib.php';
include_once '/../include/player.lib.php';

if( isset($_GET['to']) && isnumber($_GET['to']) ) {
$city = $db->GetRow("SELECT cityname FROM cities WHERE cityid = ? AND cityminlevel <= ?", array($_GET['to'], $player['level']));
if( empty($city) ) {
	$tpl->assign('error', 'Invalid selection made, please try again');
}
elseif( 1000 > $player['money'] ) {
	$tpl->assign('error', 'You don\'t have enough money to buy a ticket');
}
else {
	$player['money'] -= 1000;
	$db->Execute("UPDATE users SET money = ?, location = ? WHERE userid = ?",
		array($player['money'], $_GET['to'], $player['userid']));
	$tpl->assign('result', "Congratulations, you paid \$1,000 and travelled to $city[cityname] on the monorail!");
}
}

$tpl->assign('cities',
$db->GetAll('SELECT * FROM cities WHERE cityid <> ? AND cityminlevel <= ?', array($player['location'], $player['level'])));

$tpl->assign("player", $player);

$tpl->display('travel.tpl');
exit;

 

travel.tpl (template for travel page)

{include file="pageheader.tpl"}

{if $error <> ""}<p style='color: red; font-weight: bold'>{$error}</p>{/if}
{if $result <> ""}
<p style='font-weight: bold'>{$result}</p>
{else}
Welcome to the Monorail Station. It costs $1,000 for a ticket.

Where would you like to travel today?

<table width=75%>
	<tr style='background:gray'>
		<th>Name</th>
		<th>Description</th>
		<th>Min Level</th>
		<th> </th>
	</tr>
	{foreach from=$cities item=c}
	<tr>
		<td>{$c.cityname}</td>
		<td>{$c.citydesc}</td>
		<td>{$c.cityminlevel}</td>
		<td>[url='travel.php?to={$c.cityid}']Go[/url]</td>
	</tr>
	{/foreach}
</table>
{/if}

{include file="pagefooter.tpl"}

 

pageheader.tpl

template for inside the game, the outside of the game (index.php, register, login etc) pages are seperate from inside of the game

<html>
<head>
<title>Your Game Name</title>

<script>
var energy = {$player.energy};
var energy_max = {$player.maxenergy};
var will = {$player.will};
var will_max = {$player.maxwill};
var brave = {$player.brave};
var brave_max = {$player.maxbrave};
var exp = {$player.exp};
var exp_max = {$player.exp_needed};
var health = {$player.hp};
var health_max = {$player.maxhp};
</script>
{literal}
<script>
function updatestats() {
	displaybar('energy', 'Energy', parseInt(energy / energy_max * 100));
	displaybar('will', 'Will', parseInt(will / will_max * 100));
	displaybar('exp', 'EXP', parseInt(exp / exp_max * 100));
	displaybar('health', 'Health', parseInt(health / health_max * 100));

	var bpercent = parseInt(brave / brave_max * 100);
	document.getElementById('brave').innerHTML =  '[b]Brave:[/b] ' + brave + ' / ' + brave_max + '
[img=../images/bargreen.gif][img=../images/barred.gif]';
}

function displaybar(elm, label, percent) {
	document.getElementById(elm).innerHTML =  '[b]' + label + ':[/b] ' + percent + '%
[img=../images/bargreen.gif][img=../images/barred.gif]';
}
</script>	

<style>
body { font-family:helvetica, arial, geneva, sans-serif;font-size:12;color: black;
  scrollbar-base-color: #005B70;
  scrollbar-arrow-color: #F3960B;
  scrollbar-DarkShadow-Color: #000000; }
a:visited,a:active,a:hover,a:link { color: black;text-decoration: none; }
table,tr,td { font-family:helvetica, arial, geneva, sans-serif;font-size: 12; }
img { border:none; }
textarea { font-family:helvetica, arial, geneva, sans-serif;font-size:12;color: black; }
</style>
{/literal}
</head>
<body bgcolor='#C3C3C3' onLoad='updatestats()'>
<table width=100%>
	<tr>
		<td>[img=../images/logo.png]</td>
		<td>
			[b]Name:[/b] {$player.username} 

			[b]Money:[/b] {$player.money|number_format}

			[b]Level:[/b] {$player.level}

			[b]Crystals: {$player.crystals}[/b] 

			[[url='logout.php']Emergency Logout[/url]]
		</td>
		<td>
			<span id='energy'></span>

			<span id='will'></span>

			<span id='brave'></span>

			<span id='exp'></span>

			<span id='health'></span>

		</td>
	</tr>
</table>

<table width=100%>
<tr>
	<td width=150 valign='top'>
		{include file=menu.tpl}
	</td>
	<td valign='top'>

 

pageheader.tpl is a work in progress. The final release will put the javascript and CSS into there own files for better caching.

Posted

Re: Monkey Wrench

Well from what I see you wrote a nice part of what you want to achieve basically and this could be better than MC Code V2 for the final product. For the version name I'd think it sounds good.. :lol: Just off the top of my head maybe you could call it Codestryke's Lite, but hey ho just an idea. I like the idea you would like people to adapt and make mods for it (Hopefully secure and bugless). I do think this recode could be better as well, I'd think CE should and hopefully will make a board for these codes and hopefully your codes will encourage new mod writers and hopefully new Website Developers who can learn from a high standard. I will personally use these code's to adapt and better my current coding standards, so from where I currently see your actually doing more than stopping say "Help! My game has been hax0rd! :cry: ".

I would like to wish the best of luck to you and thank you for a very nice contribution.

Posted

Re: Monkey Wrench

Yes, I'd say I just hit the 50% done mark yesterday. Whats done:

Front End:

index.php

register.php

welcome.php

Main Game:

crimes.php (merge of criminal.php / docrime.php)

estate.php

explore.php

gym.php

index.php

news.php (announcements.php)

travel.php (monorail.php)

Backend:

account.lib.php (for account_create, account_login, account_delete)

accesscontrol.php (checks session, ip init's player id)

common.lib.php (common routines, smarty, db inits)

config.game.php (defines for all in game options)

config.server.php (defines for the server paths, url etc)

player.lib.php (player loading)

xcdb.lib.php (database class)

All templates for the above done as well. Like I said it's based off the lite version so it's still very retarded for signup with no email validation and if you don't enter one it dumps out with the 'problem with account' error message.

Still to do:

crons

attack

events

fed jail

inventory

items

mailbox

preferences

search

send cash

userlist

user online

view user

I've put off most of the list based coding till I found a javascript table sorting library. Finally found one yesterday that seems like it'll work very nicely, has a small foot print and works with the GPL license http://www.kryogenix.org/code/browser/sorttable/

Posted

Re: Monkey Wrench

Have you got an online build for this? what you already have done seems like quite a lot. It would be a good idea to go for jQuery for any javascript. There are a few good data table plug-ins and my fav is

http://www.datatables.net/

You can paginate, search and order with a single plugin.

Posted

Re: Monkey Wrench

No I don't have a time line yet, still working on it as much as I can (I don't get to code much during the week). This weekend I started working on the admin/staff panel, mostly trying to get a scripting system to work (ala phpBB) for installing mods. Mod authors can then create a simple script that can be bundled with there mod for easy installation. The staff/admin panel is NOT integrated in the game like standard McCodes, it's in it's own directory and uses Apache's built in login system (ala PHP_AUTH_USER).

Couple of screen shots from this mornings work...

Basic Summary screen in the staff / admin panel:

mcadmin-preview1.png

Lite doesn't come with a bank so I wrote one and have been using it for testing:

mcadmin-preview2.png

  • 3 weeks later...
Posted

Re: Monkey Wrench

Have been looking at smartys template thing i like it :)

$smarty->assign("username", "lols");

or mccode way lol

$smarty->assign("username", $ir['username']);

 

I think i can get a hang of this :P

  • 2 weeks later...
Posted

Re: Monkey Wrench

For the travel.tpl..

<?php //Only for colors!!
{foreach from=$cities item=c}
     <tr>
        <td>{$c.cityname}</td>
        <td>{$c.citydesc}</td>
        <td>{$c.cityminlevel}</td>
        <td>[url='travel.php?to={$c.cityid}']Go[/url]</td>
     </tr>
     {/foreach}

I would do.

<?php //Only for colors!!
{foreach from=$cities item=c}
 <tr style="background-color: {cycle values="#ddddd, #eeeee"}">
   <td>{$c.cityname|escape}</td>
   <td>{$c.citydesc|escape}</td>
   <td>{$c.cityminlevel|number_format}</td>
   <td>[url="travel.php?to={$c.cityid}"]Go[/url]</td>
  </tr>
{foreachelse}
  <tr style="text-align: center;">
    <td colspan="4">There are no cities to travel to!</td>
  </tr>
{/foreach}

 

Yeah i know a bit of smarty now, have it installed on one of my sites and using it :P

Join the conversation

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

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