PHP School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a PHP Expert!

Join 307,118 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,975 people online right now. Registration is fast and FREE... Join Now!




Want to make a web based game?

5 Pages V < 1 2 3 4 5 >  

Want to make a web based game?, Look no further

Rating  3
Rechocto

RE: Want To Make A Web Based Game?

4 Jan, 2009 - 02:22 AM
Post #41

D.I.C Head
**

Joined: 4 Jan, 2009
Posts: 50


My Contributions
I was without internet for 2 weeks (6 days of which I had free time) and managed to throw together a simple PHP turn-based game, I threw it up at http://thegame.no-ip.info for some people on an old forum to try out.. if enough people want me to, I'll release the source (sans my alpa/beta-phase sucky-arse forum I threw into it some weeks after making the game) along with a guide in writing it.

I guess I'll keep an eye on this thread, post here if you want me to do as I mentioned?

This post has been edited by Rechocto: 4 Jan, 2009 - 02:23 AM
User is offlineProfile CardPM
+Quote Post

kiwi2

RE: Want To Make A Web Based Game?

15 Jan, 2009 - 10:25 PM
Post #42

D.I.C Head
Group Icon

Joined: 16 Sep, 2008
Posts: 164



Thanked: 4 times
Dream Kudos: 300
My Contributions
nice keep it up, good to see someone doing something other than thinking about it!!
User is offlineProfile CardPM
+Quote Post

edu2004eu

RE: Want To Make A Web Based Game?

17 Jan, 2009 - 03:57 AM
Post #43

New D.I.C Head
Group Icon

Joined: 26 Aug, 2007
Posts: 47


Dream Kudos: 25
My Contributions
I have also made a web based game (mafia/pimp game) since my first post in here. It turned out pretty good, but the attack feature is not implemented yet. If you want to see it click the link on my signature. If you like it and want to make a similar one and stumble upon problems, PM me, I may be able to help you (but only mafia/pimp style games, cause I don't know other games).
User is offlineProfile CardPM
+Quote Post

eliphas

RE: Want To Make A Web Based Game?

20 Jan, 2009 - 02:04 AM
Post #44

New D.I.C Head
*

Joined: 20 Jan, 2009
Posts: 2

hello,
is there a place where i can find a good tutorial to create a mini map or even a grid map to make my character walking through it ?

thanks for your help,
eli
User is offlineProfile CardPM
+Quote Post

ValPaliy

RE: Want To Make A Web Based Game?

20 Jan, 2009 - 02:47 AM
Post #45

D.I.C Lover
Group Icon

Joined: 6 Dec, 2007
Posts: 1,362



Thanked: 9 times
My Contributions
Thanks, snoj!
I am playing one, and thought about creating one in the future. Will read-in later on smile.gif
User is offlineProfile CardPM
+Quote Post

Rechocto

RE: Want To Make A Web Based Game?

22 Jan, 2009 - 01:16 AM
Post #46

D.I.C Head
**

Joined: 4 Jan, 2009
Posts: 50


My Contributions
QUOTE(eliphas @ 20 Jan, 2009 - 02:04 AM) *

hello,
is there a place where i can find a good tutorial to create a mini map or even a grid map to make my character walking through it ?

thanks for your help,
eli



hrm... I once (several years ago on a computer that got fried by a lightning strike (no backup sad.gifsad.gif )) integrated a PHP site into a MUD.. it wasn't anywhere NEAR completion and only had a skeleton system up (hence why I didn't back it up), but I did have a minimap going. it was an smaug mud, and therefore based on vnums, making it easy enough to set up the map.. basically it set up a 7x7 square of squares (a table). the center square was the room your character was in. if there was an exit east the room to the right was added, etc, following exits until it left that 7x7 square then going back to the most recent room with an unexplored exit, and so on. it took a little while to parse but every room that existed in that 7x7 had a thick black border and any area where there wasnt a room had a light grey dashed border. if there was an exit "up" there was a blue "u" in the square and if there was an exit down there was a blue "d" in the square. I wanted to set it up so that if there was another player currently in that room (set something up with php sockets and the mud server to work together) then the background of the square would be green... however I did set it up so on mouseover you could see what monsters respawned in that room...

this is somewhat irrelevant, but I believe it is the type of system your wanting to integrate into your game, yes? how does your game work? I'm guessing you have an X and Y value in your charactor data, and a database containing room descriptions, exits, and x\y values (something like how a MUD works) or file names x-y.php dynamically created where you can create rooms easilly?


elaborate on how location data and areas are set up in your game and I may be able to help you.

This post has been edited by Rechocto: 22 Jan, 2009 - 01:19 AM
User is offlineProfile CardPM
+Quote Post

eliphas

RE: Want To Make A Web Based Game?

22 Jan, 2009 - 01:24 AM
Post #47

New D.I.C Head
*

Joined: 20 Jan, 2009
Posts: 2

hello,
you are absolutly right, since I post i manage to create a map based on x,y as each place and character have there own coordinate. I build the image with GDlibrairy, and make the character move with left right/right , up/down . preety easy at the end of the day . i forgoti have a few coffees too.

but your idea ofsocket in a MUD looks interesting though. icon_up.gif


QUOTE(Rechocto @ 22 Jan, 2009 - 01:16 AM) *

QUOTE(eliphas @ 20 Jan, 2009 - 02:04 AM) *

hello,
is there a place where i can find a good tutorial to create a mini map or even a grid map to make my character walking through it ?

thanks for your help,
eli



hrm... I once (several years ago on a computer that got fried by a lightning strike (no backup sad.gifsad.gif )) integrated a PHP site into a MUD.. it wasn't anywhere NEAR completion and only had a skeleton system up (hence why I didn't back it up), but I did have a minimap going. it was an smaug mud, and therefore based on vnums, making it easy enough to set up the map.. basically it set up a 7x7 square of squares (a table). the center square was the room your character was in. if there was an exit east the room to the right was added, etc, following exits until it left that 7x7 square then going back to the most recent room with an unexplored exit, and so on. it took a little while to parse but every room that existed in that 7x7 had a thick black border and any area where there wasnt a room had a light grey dashed border. if there was an exit "up" there was a blue "u" in the square and if there was an exit down there was a blue "d" in the square. I wanted to set it up so that if there was another player currently in that room (set something up with php sockets and the mud server to work together) then the background of the square would be green... however I did set it up so on mouseover you could see what monsters respawned in that room...

this is somewhat irrelevant, but I believe it is the type of system your wanting to integrate into your game, yes? how does your game work? I'm guessing you have an X and Y value in your charactor data, and a database containing room descriptions, exits, and x\y values (something like how a MUD works) or file names x-y.php dynamically created where you can create rooms easilly?


elaborate on how location data and areas are set up in your game and I may be able to help you.


User is offlineProfile CardPM
+Quote Post

Lt. Winters

RE: Want To Make A Web Based Game?

22 Jan, 2009 - 06:40 PM
Post #48

New D.I.C Head
*

Joined: 20 Jan, 2009
Posts: 17

I have a quick question. Do I need to buy anythings like a domain or something on the internet to start my game?
User is offlineProfile CardPM
+Quote Post

Auzzie

RE: Want To Make A Web Based Game?

22 Jan, 2009 - 06:48 PM
Post #49

D.I.C Regular
Group Icon

Joined: 20 Jan, 2009
Posts: 395



Thanked: 20 times
Dream Kudos: 175
My Contributions
it does help but some free php hosts let you have subdomains, to buy a domain though costs virtually nothing a year smile.gif
User is offlineProfile CardPM
+Quote Post

PunkRocker277

RE: Want To Make A Web Based Game?

28 Jan, 2009 - 03:51 PM
Post #50

D.I.C Head
**

Joined: 7 Jan, 2009
Posts: 66


My Contributions
I'm in the process of programming the battle system for my web based game and one problem I ran to was that I'm not sure how to make an attack only cause damage a percent of the time.

Would this work?:
CODE

<?php
$perecent = 60;

$rand = rand(1,100);

if ($rand <= $percent) {
     echo "The attack worked!";
}
else {
     echo "The attack failed";
}
?>


Can anyone help me?

This post has been edited by PunkRocker277: 28 Jan, 2009 - 04:14 PM
User is offlineProfile CardPM
+Quote Post

Auzzie

RE: Want To Make A Web Based Game?

28 Jan, 2009 - 03:56 PM
Post #51

D.I.C Regular
Group Icon

Joined: 20 Jan, 2009
Posts: 395



Thanked: 20 times
Dream Kudos: 175
My Contributions
Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Please post like this:

Thank you for helping us helping you.

Google helps though wink2.gif and maybe you want to look up rand()

This post has been edited by Auzzie: 28 Jan, 2009 - 03:56 PM
User is offlineProfile CardPM
+Quote Post

PunkRocker277

RE: Want To Make A Web Based Game?

28 Jan, 2009 - 04:14 PM
Post #52

D.I.C Head
**

Joined: 7 Jan, 2009
Posts: 66


My Contributions
Sorry about that.
I updated my post. =D
User is offlineProfile CardPM
+Quote Post

Auzzie

RE: Want To Make A Web Based Game?

28 Jan, 2009 - 04:23 PM
Post #53

D.I.C Regular
Group Icon

Joined: 20 Jan, 2009
Posts: 395



Thanked: 20 times
Dream Kudos: 175
My Contributions
That code is a very basic example of what you are after, yes
User is offlineProfile CardPM
+Quote Post

PunkRocker277

RE: Want To Make A Web Based Game?

28 Jan, 2009 - 06:40 PM
Post #54

D.I.C Head
**

Joined: 7 Jan, 2009
Posts: 66


My Contributions
Thanks a lot. happy.gif
User is offlineProfile CardPM
+Quote Post

PunkRocker277

RE: Want To Make A Web Based Game?

1 Feb, 2009 - 10:20 AM
Post #55

D.I.C Head
**

Joined: 7 Jan, 2009
Posts: 66


My Contributions
Hey guys I'm having a problem with my battle system script.
When the opponent attacks it doesn't update my hp on the database and I can't find the problem.

Here is the script:
CODE

<?php
#run_battle.php
error_reporting(E_ALL);
#require connection file
require_once 'include/db-conn.php';

#require functions file
require_once 'include/functions.php';

#set the action variable
$act = $_GET['act'];

#set the attack number variable
$num = $_GET['num'];

#set date
$date = date('m-d-y h:i a');


#get the battle's info
$get_battle = mysql_fetch_array(mysql_query("SELECT * FROM `Battles` WHERE `UserID` = '$_COOKIE[UserID]' AND `Active` = 'Yes'"));

#get the logged-in user's info
$user = User($_COOKIE['UserID']);

#get the opponent's info
$opp = User($get_battle['OpponentID']);

#get the user's teams's info
$user_starter = Slot($_COOKIE['UserID'], 1);
$user_slot2 = Slot($_COOKIE['UserID'], 2);
$user_slot3 = Slot($_COOKIE['UserID'], 3);
$user_slot4 = Slot($_COOKIE['UserID'], 4);
$user_slot5 = Slot($_COOKIE['UserID'], 5);
$user_slot6 = Slot($_COOKIE['UserID'], 6);

#get the opponent's starter's info
$opp_starter = Slot($get_battle['OpponentID'], 1);

#get user's attack info
$attack1 = Attack($user_starter['Attack_1']);
$attack2 = Attack($user_starter['Attack_2']);
$attack3 = Attack($user_starter['Attack_3']);
$attack4 = Attack($user_starter['Attack_4']);

#get opponent's attack info
$oattack1 = Attack($opp_starter['Attack_1']);
$oattack2 = Attack($opp_starter['Attack_2']);
$oattack3 = Attack($opp_starter['Attack_3']);
$oattack4 = Attack($opp_starter['Attack_4']);

#set some vars for the functions
$exp = $user_starter['Pkmn_Exp'];
$exp2 = $user_starter['Pkmn_Exp2'];
$level = $user_starter['Pkmn_Level'];
$hp = $user_starter['Pkmn_HP'];
$ohp = $get_battle['OppHP'];
$log = $get_battle['Log'];

#check what attack the user is using
if (empty($num)) {
    #do nothing
}
elseif ($num == 1) {
    #set attack used var
    $attack_used = $attack1;
}
elseif ($num == 2) {
    #set attack used var
    $attack_used = $attack2;
}
elseif ($num == 3) {
    #set attack used var
    $attack_used = $attack3;
}
elseif ($num == 4) {
    #set attack used var
    $attack_used = $attack4;
}
else {
?>
    <div align="left">
    <h2>Error</h2>
    Invalid attack number.<br />
    <a href="battle.php">Go back</a>.
    </div>
<?php
    #exit page
    exit;
}


#set a function that checks if the user leveled up
function CheckExp() {
    
    if ( $exp >= $exp2) {
    
        #get new hp
        $new_exp = ($exp * ($level + 1)) / 2;

        #update the level & experience
        mysql_query("UPDATE `Pokemon` SET
        `Pkmn_Level` + '1',
        `Pkmn_Exp` = '0',
        `Pkmn_Exp2` = '$new_exp'
        WHERE `OwnerID` = '$_COOKIE[UserID]' AND `Slot` = '1'");

        #exit page
        exit;
    }
}

#set a function that checks if anyone won yet
function CheckStatus() {
    
    #globalize vars
    global $hp, $get_battle, $log, $date, $ohp, $level, $exp2, $exp;
    
    if($hp == 0) {
        
        #you lose, add 1 to battles lost
        mysql_query("UPDATE `Users` SET `Battles_Lost` + '1' WHERE `User_ID` = '$_COOKIE[UserID]'");
        mysql_query("UPDATE `Battles` SET `Results` = 'Lose' WHERE `BattleID` = '$get_battle[BattleID]'");
        
        #set log message
        $new_log = $log . '[' . $date . ']:&nbsp;The Player Lost The Battle.<br />';
        
        #change status message
        mysql_query("UPDATE `Battles` SET
        `StatusMessage` = 'You lost the battle!',
        `Log` = '$new_log'        
         WHERE `BattleID` = '$get_battle[BattleID]'");        
        #redirect user
        ?>
        <meta http-equiv='Refresh' content='0; url=battle.php' />
        <?php        
        #exit page
        exit;
    }
    elseif ($ohp == 0) {
        
        #random number
        $randExp = rand(2,10);
        
        #calculate how much exp to give the pokemon
        $exp_received = round((($exp2 * (2 / $level)) * $randExp) / 3);
        
        #give the pokemon the exp
        mysql_query("UPDATE `Pokemon` SET
        `Pkmn_HP` + '$exp_received'
        WHERE `OwnerID` = '$_COOKIE[UserID]' AND `Slot` = '1'");
        
        #you win, add 1  to battles won
        mysql_query("UPDATE `Users` Set
        `Battles_Won` + '1'
        WHERE `UserID` = '$_COOKIE[UserID]'");
        mysql_query("UPDATE `Battles` SET
        `Results` = 'Win'
        WHERE `BattleID` = '$get_battle[BattleID]'");

        #set log message
        $new_log = $log . '[' . $date . ']:&nbsp;The Player Won The Battle.<br />';
        
        #change status message
        mysql_query("UPDATE `Battles` SET
        `StatusMessage` = 'Congratulations! You won the battle!',
        `Log` = '$new_log'        
         WHERE `BattleID` = '$get_battle[BattleID]'");    
        #check if the user leveled up
        CheckExp();

        #redirect user
        ?>
        <meta http-equiv='Refresh' content='0; url=battle.php' />
        <?php        
        #exit page
        exit;
    }
}

#check what the user is trying to do
#if the user is attacking
if ($act == "attack") {

    #check which pokemon has the higher speed
    #the user gets to attack first
    if ($user_starter['Pkmn_Speed'] >= $opp_starter['Pkmn_Speed']) {
    
        #make the user attack first
        $dmg = ($user_starter['Pkmn_Attack'] * $attack_used['Attack_Power'] + $user_starter['Pkmn_Level']) / $opp_starter['Pkmn_Defence'];
        
        $accuracy = $attack_used['Accuracy'];
        
        $rand = rand(1,100);
        
        if ($rand <= $accuracy) {
             #set the "missed" variable
             $missed = false;
            
             #subract damage from hp
             $new_ohp = $get_battle['OppHP'] - $dmg;
            
             #check if the hp is under zero
             if ($new_ohp <= 0) {
                 #set $new_ohp to zero
                 $new_ohp = 0;
             }
            
             #make the opponent take damage
             mysql_query("UPDATE `Battles` SET `OppHP` = '$new_ohp' WHERE `BattleID` = '$get_battle[BattleID]'");
        
            #set log message
            $new_log = $log . '[' . $date . ']:&nbsp;The player attacked with ' . $attack_used['Attack_Name'] . ' causing <b>' . $dmg . '</b> damage to the opponent.<br />';
            
            #change status message
            mysql_query("UPDATE `Battles` SET
            `Log` = '$new_log'        
             WHERE `BattleID` = '$get_battle[BattleID]'");    
                
        }
        else {
             #set the "missed" variable
             $missed = true;
        }
        
        #check if anyone won the battle yet
        CheckStatus();
        
        #---- the opponent is now attacking ----#
    
        #set up a random attack for the opponent to use
        $randAttack = rand(1,4);
        
        #check what attack the user is using
        if ($randAttack == 1) {
            #set attack used var
            $oattack_used = $oattack1;
        }
        elseif ($randAttack == 2) {
            #set attack used var
            $oattack_used = $oattack2;
        }
        elseif ($randAttack == 3) {
            #set attack used var
            $oattack_used = $oattack3;
        }
        elseif ($randAttack == 4) {
            #set attack used var
            $oattack_used = $oattack4;
        }
        
        #make the opponent attack
        $odmg = ($opp_starter["Pkmn_Attack"] * $oattack_used["Attack_Power"] + $opp_starter["Pkmn_Level"]) / $user_starter["Pkmn_Defence"];
        
        $oaccuracy = $oattack_used["Accuracy"];
        
        $orand = rand(1,100);
        
        if ($orand <= $oaccuracy) {
             #set the "missed" variable
             $omissed = false;
            
             #subract damage from hp
             $new_hp = $user_starter["Pkmn_HP"] - $odmg;
            
             #check if the hp is under zero
             if ($new_hp <= 0) {
                 #set $new_ohp to zero
                 $new_hp = 0;
             }
            
             #make the user take damage
             mysql_query("UPDATE `Pokemon` SET `Pkmn_HP` = '$new_hp' WHERE `OwnerID` = '$_COOKIE[UserID]' AND `Slot` = '1'");
        }
        else {
             #set the "missed" variable
             $omissed = true;
        }
        
        #check if anyone won the battle yet
        CheckStatus();
        
        #check if any attack missed
        if ($missed == true) { #your attack missed
        
            $status_msg =
            'You didn\'t cause damage to the opponent because your attack missed.<br />
            Your opponent attacked with ' . $oattack_used[Attack_Name] . ' causing <b>' . $odmg . '</b> damage to the you.';
        
        }
        elseif ($omissed == true) { #the opponent's attack missed

            $status_msg =
            'You attacked with ' . $attack_used[Attack_Name] . ' causing <b>' . $dmg . '</b> damage to the opponent.<br />
            Your opponent didn\'t cause damage to the you because your attack missed.';
        
        }
        elseif ($missed == true && $omissed = true) { #both attacks missed
        
            $status_msg =
            'You didn\'t cause damage to the opponent because your attack missed.<br />
            Your opponent didn\'t cause damage to the you because your attack missed.';
            
        }    
        else { #no attacks missed
            
            $status_msg =
            'You attacked with ' . $attack_used['Attack_Name'] . ' causing <b>' . $dmg . '</b> damage to the opponent.<br />
            Your opponent attacked with ' . $oattack_used['Attack_Name'] . ' causing <b>' . $odmg . '</b> damage to the you.';
        }
        
        #change status message
        mysql_query("UPDATE `Battles` SET
        `StatusMessage` = '$status_msg'
        WHERE `BattleID` = '$get_battle[BattleID]'");    
        
    }
    #the opponent gets to attack first
    elseif ($user_starter["Pkmn_Speed"] < $opp_starter["Pkmn_Speed"]) {

        #---- the opponent is now attacking ----#
    
        #set up a random attack for the opponent to use
        $randAttack = rand(1,4);
        
        #check what attack the user is using
        if ($randAttack == 1) {
            #set attack used var
            $oattack_used = $oattack1;
        }
        elseif ($randAttack == 2) {
            #set attack used var
            $oattack_used = $oattack2;
        }
        elseif ($randAttack == 3) {
            #set attack used var
            $oattack_used = $oattack3;
        }
        elseif ($randAttack == 4) {
            #set attack used var
            $oattack_used = $oattack4;
        }
        
        #make the opponent attack
        $odmg = round(($opp_starter['Pkmn_Attack'] * $oattack_used['Attack_Power'] + $opp_starter['Pkmn_Level']) / $user_starter['Pkmn_Defence']);
        
        $oaccuracy = $oattack_used['Accuracy'];
        
        $orand = rand(1,100);
        
        if ($orand <= $oaccuracy) {
             #set the "missed" variable
             $omissed = false;
            
             #subract damage from hp
             $new_hp = $user_starter['Pkmn_HP'] - $odmg;
            
             #check if the hp is under zero
             if ($new_hp <= 0) {
                 #set $new_ohp to zero
                 $new_hp = 0;
             }
            
             #make the user take damage
             mysql_query("UPDATE `Pokemon` SET `Pkmn_HP` = '$new_hp' WHERE `OwnerID` = '$_COOKIE[UserID]' AND `Slot` = '1'");
        }
        else {
             #set the "missed" variable
             $omissed = true;
        }
        
        #check if anyone won the battle yet
        CheckStatus();
        

        #---- make the user attack ----#
        $dmg = round(($user_starter['Pkmn_Attack'] * $attack_used['Attack_Power'] + $user_starter['Pkmn_Level']) / $opp_starter['Pkmn_Defence']);
        
        $accuracy = $attack_used['Accuracy'];
        
        $rand = rand(1,100);
        
        if ($rand <= $accuracy) {
             #set the "missed" variable
             $missed = false;
            
             #subract damage from hp
             $new_ohp = $get_battle['OppHP'] - $dmg;
            
             #check if the hp is under zero
             if ($new_ohp <= 0) {
                 #set $new_ohp to zero
                 $new_ohp = 0;
             }
            
             #make the opponent take damage
             mysql_query("UPDATE `Battles` SET `OppHP` = '$new_ohp' WHERE `BattleID` = '$get_battle[BattleID]'");
        
            #set log message
            $new_log = $log . '[' . $date . ']:&nbsp;The player attacked with ' . $attack_used['Attack_Name'] . ' causing <b>' . $dmg . '</b> damage to the opponent.<br />';
            
            #change status message
            mysql_query("UPDATE `Battles` SET
            `Log` = '$new_log'        
             WHERE `BattleID` = '$get_battle[BattleID]'");    
                
        }
        else {
             #set the "missed" variable
             $missed = true;
        }
        
        #check if anyone won the battle yet
        CheckStatus();

        
        #check if any attack missed
        if ($missed == true) { #your attack missed
        
            $status_msg =
            'Your opponent attacked with ' . $oattack_used[Attack_Name] . ' causing <b>' . $odmg . '</b> damage to the you.<br />
            You didn\'t cause damage to the opponent because your attack missed.';
        
        }
        elseif ($omissed == true) { #the opponent's attack missed

            $status_msg =
            'Your opponent didn\'t cause damage to the you because your attack missed.<br />
            You attacked with ' . $attack_used[Attack_Name] . ' causing <b>' . $dmg . '</b> damage to the opponent.';
        
        }
        elseif ($missed == true && $omissed = true) { #both attacks missed
        
            $status_msg =
            'Your opponent didn\'t cause damage to the you because your attack missed.<br />
            You didn\'t cause damage to the opponent because your attack missed.';
            
        }    
        else { #no attacks missed
            
            $status_msg =
            'Your opponent attacked with ' . $oattack_used['Attack_Name'] . ' causing <b>' . $odmg . '</b> damage to the you.<br />
            You attacked with ' . $attack_used['Attack_Name'] . ' causing <b>' . $dmg . '</b> damage to the opponent.';
        }
        
        #change status message
        mysql_query("UPDATE `Battles` SET
        `StatusMessage` = '$status_msg'
        WHERE `BattleID` = '$get_battle[BattleID]'");    
    
    }
    
    #redirect user
    ?>
    <meta http-equiv='Refresh' content='0; url=battle.php' />
    <?php
    #exit page
    exit;    
}
#if the user is changing his starter pokemon
elseif ($act == "change") {


}
#if the user is running
elseif ($act == 'run') {
    
    #set log message
    $new_log = $log . '[' . $date . ']:&nbsp;The Player Ran From The Battle.<br />';
    
    #change status message
    mysql_query("UPDATE `Battles` SET
    `StatusMessage` = 'You successfully ran from the battle!',
    `Log` = '$new_log'        
     WHERE `BattleID` = '$get_battle[BattleID]'");    
    
    #deactivate the battle
    mysql_query("UPDATE `Battles` SET `Run_Status` = 'Yes' WHERE `BattleID` = '$get_battle[BattleID]'");
    
    #redirect back to the battle page
    ?>
    <meta http-equiv='Refresh' content='0; url=battle.php' />
    <?php
    exit;

}
#if the user is using an item
elseif ($act == "use_item") {


}
else {
?>
<div align="left">
<h2>Error</h2>
You shouldn't be here.<br />
<a href="index.php">Go back</a>.
</div>
<?php
}
?>

User is offlineProfile CardPM
+Quote Post

Auzzie

RE: Want To Make A Web Based Game?

1 Feb, 2009 - 01:05 PM
Post #56

D.I.C Regular
Group Icon

Joined: 20 Jan, 2009
Posts: 395



Thanked: 20 times
Dream Kudos: 175
My Contributions
First off a little tip, it might be better to post problems in the main php board, secondly after a brief glance i can see one glaring problem

CODE

mysql_query("UPDATE `Pokemon` SET `Pkmn_HP` = '$new_hp' WHERE `OwnerID` = '$_COOKIE[UserID]' AND `Slot` = '1'");

the cookie superglobal needs to be $_COOKIE['UserID'] and it is like that through all of your code. Hope it helps
User is offlineProfile CardPM
+Quote Post

PunkRocker277

RE: Want To Make A Web Based Game?

1 Feb, 2009 - 01:56 PM
Post #57

D.I.C Head
**

Joined: 7 Jan, 2009
Posts: 66


My Contributions
So I have to change: $_COOKIE[UserID] to $_COOKIE['UserID']

This post has been edited by PunkRocker277: 1 Feb, 2009 - 01:57 PM
User is offlineProfile CardPM
+Quote Post

Auzzie

RE: Want To Make A Web Based Game?

1 Feb, 2009 - 02:02 PM
Post #58

D.I.C Regular
Group Icon

Joined: 20 Jan, 2009
Posts: 395



Thanked: 20 times
Dream Kudos: 175
My Contributions
Yes that is the only glaring thing that i can see
User is offlineProfile CardPM
+Quote Post

PunkRocker277

RE: Want To Make A Web Based Game?

1 Feb, 2009 - 02:15 PM
Post #59

D.I.C Head
**

Joined: 7 Jan, 2009
Posts: 66


My Contributions
But isn't this: $_COOKIE[UserID] okay if it's in a string?
User is offlineProfile CardPM
+Quote Post

Auzzie

RE: Want To Make A Web Based Game?

1 Feb, 2009 - 02:20 PM
Post #60

D.I.C Regular
Group Icon

Joined: 20 Jan, 2009
Posts: 395



Thanked: 20 times
Dream Kudos: 175
My Contributions
not really because you are trying to access a string within the $_COOKIE array
User is offlineProfile CardPM
+Quote Post

5 Pages V < 1 2 3 4 5 >
Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 01:36PM

Live PHP Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month