Jump to content
MakeWebGames

Help with mySQL


DevonNice

Recommended Posts

It seam im having trouble with creating table and such with sql

What i want to do it create a mod that allows player to purchase upgrades.

Like there will be a table and have a list of upgrades you can buy.

I have a basic idea on how i wont the sql to be writin

Like if someone purchases the first upgrade out of 10

it will be enter into the table 1.

And everyone would start off at 0

and every upgrade would make the number rise by 1

I dont know if you guys get what im saying

But if anyone wants to team up and help me with the project that would be great

I'm wanting to create a reward based system

which the upgrades would consist of

- Member having a higher chance of finding items.

- increase their Health

and others when i think of them, and think of a way to add them to the game.

Devon.

Link to comment
Share on other sites

hmm... maybe set up mod like this?

sql

CREATE TABLE IF NOT EXISTS `rewardbase` (
 `userid` int(11) NOT NULL AUTO_INCREMENT,
 `hpupgrade` int(11) NOT NULL DEFAULT '0',
 `hpupgradesdone` int(11) NOT NULL DEFAULT '0',
 PRIMARY KEY (`userid`)
) ENGINE=MyISAM;

 

You need script to insert the table info unless you do it manally so every user has a section to work with.

note: i cba to make the functions for a different table and also idk how to do LEFT JOIN querys sorry.

so i cant do it anyways. if you do it my way, just insert it into users table.

or add them to users table with this sql

alter tables users add hpupgrade int(11) not null default 0;
alter tables users add hpupgradesdone int(11) not null default 0;

 

then create file doing something like (note: im writing these functions on here from memory)

 

function hpupgrade()
{
global $h, $ir, $db, $userid;
if($ir['hpupgradedone'] == 5)
{
echo "You can only max this section out 5 times. Sorry.";
echo "[url='index']Go Home[/url]";
$h->endpage();
exit();
}
$cash = 50000;
echo "it will cost you $".number_format($cash)." to upgrade a level.";
echo "[url='?act=hpupgraded']Upgrade Now![/url]";
$h->endpage();
exit();
}
function hpupgraded()
{
global $h, $ir, $db, $userid;
if($ir['hpupgradedone'] == 5)
{
echo "You can only max this section out 5 times. Sorry.";
echo "[url='index']Go Home[/url]";
$h->endpage();
exit();
}
$cash = 50000;
$db->query("UPDATE users SET hpupgrade=hpupgrade+1, money=money-$cash WHERE userid=$userid");
echo "You have upgraded your HP counter upto ".number_format($ir['hpupgrade'])."/10 for $".number_format($cash).".";
if($ir['hpupgrade'] == 10)
{
$db->query("UPDATE users SET maxhp=maxhp+1000, hpupgrade=0, hpupgradedone=hpupgradedone+1 WHERE userid=$userid");
echo "

You have maxed out your HP counter ".number_format($ir['hpupgradedone'])."/5 times. Congratulations, you gained 1,000 more HP.";
}
$h->endpage();
exit();
}

 

if your creating new table. you have to do do alot of editing. in few files and etc. unless you know how to do LEFT JOIN querys.

hope it helps. haha. probably gonna confuse you :P

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.

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