DragonPrime - LoGD Resource Community
Welcome Guest
  • Good morning, Guest.
    Please log in, or register.
  • December 19, 2018, 07:35:45 AM
Home Forums News Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
Search

Pages: [1]   Go Down
  Print  
Author Topic: hungery and thirsty  (Read 2576 times)
0 Members and 1 Guest are viewing this topic.
keith
Guest
« on: March 19, 2004, 05:06:03 PM »

I just started coding php and I am trying to make it where you can starve. every day you loose 10 hungry points and 10 thirsty point when they get to 0 this should happen. I put checkfood() at the end of the newday function. I put this code in common.php but every day it say thinks the if is true. I already made it subtract 10 of both every day and put the hungry and thirsty in the mysql database and made the default 100 and 50 and it shows them with every thing in vital info. On my server instead of dying you get put in prison.

function checkfood(){
if ($session['user']['hungry']<=1 || $session['user']['thirsty']<=1){
output("`n`nYou realize you haven't had anything to eat in a long time. Suddenly, men in black suits");
output("run at you. You try to fight them off, but you lack the strength because of your hunger.`n");
output("They take you to the prison. `n`n");
output("They strip you of your gold but only half your gems because you");
output("kept them hidden in a secret pocket.");
$session['user']['turns']==0;
$session['user']['hitpoints']== 0;
$session['user']['gold']==0;
$takegems=$session['user']['gems']*.5;
$session['user']['gems']-=$takegems;
$session['user']['alive']=false;
addnav("Go to the Prison","prison.php");
addnews($session['user']['name']." was carried away by kidnapers because he almost starved!");
}
}
Logged
anpera
Guest
« Reply #1 on: March 19, 2004, 07:00:28 PM »

Try adding

global $session;

right after

function checkfood(){

Else "$session" is unknowen in this function and so "if ($session['user']['hungry']<=1 || $session['user']['thirsty']<=1)" always is true. Wink

Logged
keith
Guest
« Reply #2 on: March 19, 2004, 09:41:20 PM »

that works thanks  Smiley
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  


*
DragonPrime Notices
Play LoGD on Dragonprime

Support Us
No funds raised yet this year
Your help is greatly appreciated!
Recent Topics
DragonPrime LoGD
Who's Online
100 Guests, 0 Users
Home Forums News Downloads Login Register Advanced Search