$page = "Congratulations. You have defeated the ".$monsterrow["name"].".<br />You gain $exp experience. $warnexp <br />You gain $gold gold. $warngold <br /><br />";
if (rand(1,30) == 1) {
$dropquery = doquery("SELECT * FROM {{table}} WHERE mlevel <= '".$monsterrow["level"]."' ORDER BY RAND() LIMIT 1", "drops");
$droprow = mysql_fetch_array($dropquery);
$dropcode = "dropcode='".$droprow["id"]."',";
$page .= "This monster has dropped an item. <a href=\"index.php?do=fielddrop\">Click here</a> to reveal and equip the item, or you may also move on and continue <a href=\"index.php\">exploring</a>.";
} else {
$dropcode = "";
$page .= "You can now continue <a href=\"index.php\">exploring</a>.";
}
$title = "Victory!";
}
}
$updatequery = doquery("UPDATE {{table}} SET level='$newlevel',maxhp='$newhp',maxmp='$newmp',maxtp='$newtp',strength='$newstrength',dexterity='$newdexterity',attackpower='$newattack',defensepower='$newdefense', $newspell currentfight='0',currentmonster='0',currentmonsterhp='0',currentmonstersleep='0',currentmonsterimmune='0',currentuberdamage='0',currentuberdefense='0',$dropcode experience='$newexp',gold='$newgold' WHERE id='".$userrow["id"]."' LIMIT 1", "users");
display($page, $title);
}
Hey guys, could someone help me with this modification to the above script?
I want to do something (probably an if/else statement)
In the above coding, do you see the line:
$page .= "You can now continue <a href=\"index.php\">exploring</a>
Well, I want to give the players the option to do the above or do this:
$page .= "<form action=index.php?do=fightmonster method=post><input type=submit value='Atack New Monster' name=monster1></form>
However, this is where it gets tricky.. the script above automatically updates the query with:
$updatequery = doquery("UPDATE {{table}} SET level='$newlevel',maxhp='$newhp',maxmp='$newmp',maxtp='$newtp',strength='$newstrength',dexterity='$newdexterity',attackpower='$newattack',defensepower='$newdefense', $newspell currentfight='0',currentmonster='0',currentmonsterhp='0',currentmonstersleep='0',currentmonsterimmune='0',currentuberdamage='0',currentuberdefense='0',$dropcode experience='$newexp',gold='$newgold' WHERE id='".$userrow["id"]."' LIMIT 1", "users");
Nothing out of the ordinary.. just updating the database right?
Well in order to run the below code:
$page .= "<form action=index.php?do=fightmonster method=post><input type=submit value='Atack New Monster' name=monster1></form>
I have to some how make this run first:
$fieldquery = doquery("SELECT * FROM {{table}} WHERE latitude='".$userrow["latitude"]."' AND longitude='".$userrow["longitude"]."' LIMIT 1", "fields");
$fieldrow = mysql_fetch_array($fieldquery);
$monsterquery = doquery("SELECT * FROM {{table}} WHERE id='".$fieldrow["fieldmonster1id"]."' LIMIT 1", "monsters");
$monsterrow = mysql_fetch_array($monsterquery);
//Set To fight
doquery("UPDATE {{table}} SET currentaction='Atacking Monster' WHERE id=".$userrow["id"], "users");
doquery("UPDATE {{table}} SET currentfight='2' WHERE id=".$userrow["id"], "users");
doquery("UPDATE {{table}} SET currentmonster='".$fieldrow["fieldmonster1id"]."' WHERE id=".$userrow["id"], "users");
My guess is to:
Update table with original query script
then
ask users to Fight or Continue explore (use if/else statement)
If Fight, then set script
If Continue, die?
How could this be done?