Jump to content
MakeWebGames

Recommended Posts

Posted

I wasn't sure where to post this, move if needed.

Ok, I have been asked alot about how to convert a v1 mod to a v2 mod so I decided to post this, hope it helps out.

This is much easier than most think.

Ok, first, open the v1 mod you wish to convert and find:

require "global_func.php";
if($_SESSION['loggedin']==0) { header("Location: login.php");exit; }
$userid=$_SESSION['userid'];
require "header.php";
$h = new headers;
$h->startheaders();
include "mysql.php";
global $c;
$is=mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid",$c) or die(mysql_error());
$ir=mysql_fetch_array($is);
check_level();
$fm=money_formatter($ir['money']);
$lv=date('F j, Y, g:i a',$ir['laston']);
$h->userdata($ir,$lv,$fm);
$h->menuarea();

 

and replace it with this:

include "globals.php";

 

and you're done.

most of you know that the sql querys in v2 are written differently than in v1, but that doesnt matter, the usual mysql_query will work just the same, there is no need to change it.

  • Replies 52
  • Created
  • Last Reply

Top Posters In This Topic

Posted

Re: Tutorial: v1 - v2 Conversion

Not being mean..just putting up a simpler thing..

Convert V1 to V2

To convert from v1 to v2 you will need to 4 things. This is best done in Notepad. Pressing Ctrl + H WILL help you a lot!

In the v1 version of the code find:

session_start();
require "global_func.php";
if($_SESSION['loggedin']==0) { header("Location: login.php");exit; }
$userid=$_SESSION['userid'];
require "header.php";
$h = new headers;
$h->startheaders();
include "mysql.php";
global $c;
$is=mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid",$c) or die(mysql_error());
$ir=mysql_fetch_array($is);
check_level();
$fm=money_formatter($ir['money']);
$cm=money_formatter($ir['crystals'],'');
$lv=date('F j, Y, g:i a',$ir['laston']);
$h->userdata($ir,$lv,$fm,$cm);
$h->menuarea();

 

And change it to

 

include "globals.php";

 

Then find all the places where it says:

 

mysql_query

 

And change to:

 

$db->query

 

Then you're done!

Feel free to contact me..

[email protected]

Posted

Re: Tutorial: v1 - v2 Conversion

 

You dont need to change the querys for a v1 mod to work with v2, thats a needless step

As true as this is, what many coder/programmers don't realise is that it's actually *much* safer to use the $db->query string instead of the mysql_query.. So..

v1

session_start();
require "global_func.php";
if($_SESSION['loggedin']==0) { header("Location: login.php");exit; }
$userid=$_SESSION['userid'];
require "header.php";
$h = new headers;
$h->startheaders();
include "mysql.php";
global $c;
$is=mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid",$c) or die(mysql_error());
$ir=mysql_fetch_array($is);
check_level();
$fm=money_formatter($ir['money']);
$cm=money_formatter($ir['crystals'],'');
$lv=date('F j, Y, g:i a',$ir['laston']);
$h->userdata($ir,$lv,$fm,$cm);
$h->menuarea();

 

v2

include "globals.php";

 

-----------

v1

mysql_

 

v2

$db->

 

------------

v1

fetch_array

 

v2

fetch_row

 

Much safer to use it that way.

  • 4 weeks later...
Posted

Re: Tutorial: v1 - v2 Conversion

I think its good to keep bumping this so it is easier to find for new coders. :wink:. But a db query is supposed to be more secure but thats only what I've heard.

Posted

Re: Tutorial: v1 - v2 Conversion

um what about using the class method is safer than the using the built in msyql_query function?

function query($query)

{

$this->last_query=$query;

$this->num_queries++;

$this->result=mysql_query($this->last_query, $this->connection_id) or $this->query_error();

return $this->result;

}

as you can see, it's just doing a mysql_query inside a class. Nothing, absolutely nothing safer about that bro man. :mrgreen:

  • 3 weeks later...
  • 2 weeks later...
  • 2 weeks later...
  • 2 weeks later...
  • 2 weeks later...
Posted

Re: Tutorial: v1 - v2 Conversion

I would say adding an href would be the easiest thing - Having said that, I know 2 people who can't even do that yet they have 3 sites on the run - one of which is a .com!

Posted

Re: Tutorial: v1 - v2 Conversion

 

I would say adding an href would be the easiest thing - Having said that, I know 2 people who can't even do that yet they have 3 sites on the run - one of which is a .com!

umm..magic i do know how to do href links lol that was like a week ago that i didnt no

Posted

Re: Tutorial: v1 - v2 Conversion

 

TheJoker, do you always have to put your stuff in highlighted?

no i just felt like spicing things up a bit XD

  • 2 weeks later...
Posted

Re: Tutorial: v1 - v2 Conversion

That just sucks the fun out of the forums then dosnt it if everyone was as plain as that i dont think anyone would have any fun let the guy have is higlights Cos Its Cool

  • 3 weeks later...
Posted

Re: Tutorial: v1 - v2 Conversion

i dunno if i should be posting this in here but i have a major problem with mccodes v2 when you commit a crim your exp bar doesnt move but it does when you attack can anyone help?

Posted

Re: Tutorial: v1 - v2 Conversion

 

i dunno if i should be posting this in here but i have a major problem with mccodes v2 when you commit a crim your exp bar doesnt move but it does when you attack can anyone help?

i had v2 and i dont have that prob its best now days if people code ther own engine

idk why but its just best cause mccode lite sucks v1 sucks v2 decent lol

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