Denver
03-31-2007, 12:23 AM
I have quite afew prolems with people putting negative numbers in the fields and it messes with my game, for example when they buy negative mercinates it floods the market with mercinarys and it they get gold they do not deserve...
here is the code please tell me to make it so they cannot put a negative number
<?
include "vsys.php";
if ($cgi['buy_merc']){
$merc=getCommonInfo();
if ($cgi['mercs_attack']){
if ($cgi['mercs_attack']>$merc->attackSpecCount)$cgi['mercs_attack']=$merc->attackSpecCount;
$gold=$cgi['mercs_attack']*$conf["mercenaries"]["atack"]["prise"];
$user=getUserDetails($_SESSION['isLogined']," gold ");
if ($user->gold>$gold){
updateMercenary(" attackSpecCount=attackSpecCount-{$cgi['mercs_attack']} ");
updateUser($_SESSION['isLogined'], " trainedAttackMerc=trainedAttackMerc+{$cgi['mercs_attack']} , gold=gold-$gold ");
}else{
$strErr="You do not have enough money";
}
}
if ($cgi['mercs_defend']){
if ($cgi['mercs_defend']>$merc->defSpecCount)$cgi['mercs_defend']=$merc->defSpecCount;
$gold=$cgi['mercs_defend']*$conf["mercenaries"]["defence"]["prise"];
$user=getUserDetails($_SESSION['isLogined']," gold ");
if ($user->gold>$gold){
updateMercenary(" defSpecCount =defSpecCount -{$cgi['mercs_defend']} ");
updateUser($_SESSION['isLogined'], " trainedDefMerc=trainedDefMerc+{$cgi['mercs_defend']} , gold=gold-$gold ");
}else{
$strErr="You do not have enough money";
}
}
if ($cgi['mercs_general']){
if ($cgi['mercs_general']>$merc->untrainedCount)$cgi['mercs_general']=$merc->untrainedCount;
$gold=$cgi['mercs_general']*$conf["mercenaries"]["untrained"]["prise"];
$user=getUserDetails($_SESSION['isLogined']," gold ");
if ($user->gold>$gold){
updateMercenary(" untrainedCount =untrainedCount -{$cgi['mercs_general']} ");
updateUser($_SESSION['isLogined'], " untrainedMerc=untrainedMerc+{$cgi['mercs_general']} , gold=gold-$gold ");
}else{
$strErr="You do not have enough money";
}
}
header("Location: mercs.php?strErr=$strErr");
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0037)http://www.kingsofchaos.com/mercs.php -->
<HTML><HEAD><TITLE>Combat Warriors! :: Massively Multiplayer Online Role Playing Game</TITLE>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1"><!-- ZoneLabs Privacy Insertion -->
<SCRIPT language=javascript src="js/js"></SCRIPT>
<LINK href="css/common.css" type=text/css rel=stylesheet><LINK
href="css/main.css" type=text/css rel=stylesheet>
<META
content="kingsofchaos, chaos, elves, humans, dwarves, orcs, rpg, mmorpg, role playing, game, online game, text based game, armory, mercenaries, spy, attack, army, battle, recruit, spies, spy skill, weapons, messaging, sabotage, recon, intelligence, pnp, mud, games, stockade, free, browser game"
name=keywords>
<META
content="Combat Warriors is a Massively Multiplayer Online Role Playing Game. Players can choose one of four races: Orcs, Humans, Elves and Dwarves and build armies, recruit friends as officers, buy weapons, and spy and attack on each other."
name=description>
<META content="Kings of Chaos" name=author>
<SCRIPT language=javascript type=text/javascript>
<!--
function checkCR(evt) {
var evt = (evt) ? evt : ((event) ? event : null);
var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
if ((evt.keyCode == 13) && (node.type=="text")) {return false;}
}
document.onkeypress = checkCR;
//-->
</SCRIPT>
<META content="MSHTML 5.50.4522.1800" name=GENERATOR></HEAD>
<BODY text=#ffffff bgColor=#000000 leftMargin=0 topMargin=0 marginheight="0"
marginwidth="0">
<?
include "top.php";
?>
<TABLE cellSpacing=0 cellPadding=5 width="100%" border=0>
<TBODY>
<TR>
<TD class=menu_cell style="PADDING-LEFT: 15px" vAlign=top width=140>
<?
include ("left.php");
?>
</TD>
<TD style="PADDING-RIGHT: 15px; PADDING-LEFT: 15px; PADDING-TOP: 12px"
vAlign=top align=left> <? if ($cgi['strErr']){ echo "<center><font color=red>{$cgi['strErr']}</font></center>"; } ?><BR>
<H3>Mercenaries</H3>
<TABLE class=table_lines cellSpacing=0 cellPadding=6 width="380"
border=0>
<TBODY>
<TR>
<TH colSpan=2>Personnel</TH>
</TR>
<TR>
<TD><B>Trained Attack Soldiers</B></TD>
<TD align=right>
<? numecho ($user->trainedAttackSold) ?>
</TD>
</TR>
<TR>
<TD><B>Trained Attack Mercenaries</B></TD>
<TD align=right>
<? numecho ($user->trainedAttackMerc) ?>
</TD>
</TR>
<TR>
<TD><B>Trained Defense Soldiers</B></TD>
<TD align=right>
<? numecho ($user->trainedDefSold)?>
</TD>
</TR>
<TR>
<TD><B>Trained Defense Mercenaries</B></TD>
<TD align=right>
<? numecho ($user->trainedDefMerc) ?>
</TD>
</TR>
<TR>
<TD><B>Untrained Soldiers</B></TD>
<TD align=right>
<? numecho ($user->untrainedSold) ?>
</TD>
</TR>
<TR>
<TD><B>Untrained Mercenaries</B></TD>
<TD align=right>
<? numecho ($user->untrainedMerc) ?>
</TD>
</TR>
<TR>
<TD class=subh><B>Spies</B></TD>
<TD class=subh align=right>
<? numecho ($user->spies) ?>
</TD>
</TR>
<TR>
<TD><B>Total Fighting Force</B></TD>
<TD align=right>
<? numecho (getTotalFightingForce($user))?>
</TD>
</TR>
</TBODY>
</TABLE>
<P>
<?
$merc=getCommonInfo();
?>
<FORM action=mercs.php method=post>
<TABLE class=table_lines cellSpacing=0 cellPadding=6 width="100%"
border=0>
<TBODY>
<TR>
<TH align=middle colSpan=4>Buy Mercenaries</TH></TR>
<TR>
<TH class=subh align=left>Mercenary Type</TH>
<TH class=subh align=right>Cost Per Unit</TH>
<TH class=subh align=right>Quantity Available</TH>
<TH class=subh align=middle>Quantity to Buy</TH></TR>
<TR>
<TD>Attack Specialist</TD>
<TD align=right><? numecho ($conf["mercenaries"]["atack"]["prise"]) ?> Gold</TD>
<TD align=right><? numecho ($merc->attackSpecCount);?></TD>
<TD align=middle><INPUT size=3 value=0 name=mercs_attack></TD></TR>
<TR>
<TD>Defense Specialist</TD>
<TD align=right>
<? numecho ($conf["mercenaries"]["defence"]["prise"]) ?>
Gold</TD>
<TD align=right>
<? numecho ($merc->defSpecCount );?>
</TD>
<TD align=middle><INPUT size=3 value=0 name=mercs_defend></TD></TR>
<TR>
<TD>Untrained</TD>
<TD align=right>
<? numecho ($conf["mercenaries"]["untrained"]["prise"]) ?>
Gold</TD>
<TD align=right>
<? numecho ($merc->untrainedCount );?>
</TD>
<TD align=middle><INPUT size=3 value=0 name=mercs_general></TD></TR>
<TR>
<TD align=middle colSpan=4><INPUT type=submit value=Buy>
</TD></TR></TBODY></TABLE><INPUT type=hidden
value=93aa2b6a02603399396203313b45827e name=hash>
<INPUT type=hidden value=1 name=buy_merc></FORM>
<?
include ("bottom.php");
?>
</TD></TR></TBODY></TABLE>
</BODY></HTML>
here is the code please tell me to make it so they cannot put a negative number
<?
include "vsys.php";
if ($cgi['buy_merc']){
$merc=getCommonInfo();
if ($cgi['mercs_attack']){
if ($cgi['mercs_attack']>$merc->attackSpecCount)$cgi['mercs_attack']=$merc->attackSpecCount;
$gold=$cgi['mercs_attack']*$conf["mercenaries"]["atack"]["prise"];
$user=getUserDetails($_SESSION['isLogined']," gold ");
if ($user->gold>$gold){
updateMercenary(" attackSpecCount=attackSpecCount-{$cgi['mercs_attack']} ");
updateUser($_SESSION['isLogined'], " trainedAttackMerc=trainedAttackMerc+{$cgi['mercs_attack']} , gold=gold-$gold ");
}else{
$strErr="You do not have enough money";
}
}
if ($cgi['mercs_defend']){
if ($cgi['mercs_defend']>$merc->defSpecCount)$cgi['mercs_defend']=$merc->defSpecCount;
$gold=$cgi['mercs_defend']*$conf["mercenaries"]["defence"]["prise"];
$user=getUserDetails($_SESSION['isLogined']," gold ");
if ($user->gold>$gold){
updateMercenary(" defSpecCount =defSpecCount -{$cgi['mercs_defend']} ");
updateUser($_SESSION['isLogined'], " trainedDefMerc=trainedDefMerc+{$cgi['mercs_defend']} , gold=gold-$gold ");
}else{
$strErr="You do not have enough money";
}
}
if ($cgi['mercs_general']){
if ($cgi['mercs_general']>$merc->untrainedCount)$cgi['mercs_general']=$merc->untrainedCount;
$gold=$cgi['mercs_general']*$conf["mercenaries"]["untrained"]["prise"];
$user=getUserDetails($_SESSION['isLogined']," gold ");
if ($user->gold>$gold){
updateMercenary(" untrainedCount =untrainedCount -{$cgi['mercs_general']} ");
updateUser($_SESSION['isLogined'], " untrainedMerc=untrainedMerc+{$cgi['mercs_general']} , gold=gold-$gold ");
}else{
$strErr="You do not have enough money";
}
}
header("Location: mercs.php?strErr=$strErr");
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0037)http://www.kingsofchaos.com/mercs.php -->
<HTML><HEAD><TITLE>Combat Warriors! :: Massively Multiplayer Online Role Playing Game</TITLE>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1"><!-- ZoneLabs Privacy Insertion -->
<SCRIPT language=javascript src="js/js"></SCRIPT>
<LINK href="css/common.css" type=text/css rel=stylesheet><LINK
href="css/main.css" type=text/css rel=stylesheet>
<META
content="kingsofchaos, chaos, elves, humans, dwarves, orcs, rpg, mmorpg, role playing, game, online game, text based game, armory, mercenaries, spy, attack, army, battle, recruit, spies, spy skill, weapons, messaging, sabotage, recon, intelligence, pnp, mud, games, stockade, free, browser game"
name=keywords>
<META
content="Combat Warriors is a Massively Multiplayer Online Role Playing Game. Players can choose one of four races: Orcs, Humans, Elves and Dwarves and build armies, recruit friends as officers, buy weapons, and spy and attack on each other."
name=description>
<META content="Kings of Chaos" name=author>
<SCRIPT language=javascript type=text/javascript>
<!--
function checkCR(evt) {
var evt = (evt) ? evt : ((event) ? event : null);
var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
if ((evt.keyCode == 13) && (node.type=="text")) {return false;}
}
document.onkeypress = checkCR;
//-->
</SCRIPT>
<META content="MSHTML 5.50.4522.1800" name=GENERATOR></HEAD>
<BODY text=#ffffff bgColor=#000000 leftMargin=0 topMargin=0 marginheight="0"
marginwidth="0">
<?
include "top.php";
?>
<TABLE cellSpacing=0 cellPadding=5 width="100%" border=0>
<TBODY>
<TR>
<TD class=menu_cell style="PADDING-LEFT: 15px" vAlign=top width=140>
<?
include ("left.php");
?>
</TD>
<TD style="PADDING-RIGHT: 15px; PADDING-LEFT: 15px; PADDING-TOP: 12px"
vAlign=top align=left> <? if ($cgi['strErr']){ echo "<center><font color=red>{$cgi['strErr']}</font></center>"; } ?><BR>
<H3>Mercenaries</H3>
<TABLE class=table_lines cellSpacing=0 cellPadding=6 width="380"
border=0>
<TBODY>
<TR>
<TH colSpan=2>Personnel</TH>
</TR>
<TR>
<TD><B>Trained Attack Soldiers</B></TD>
<TD align=right>
<? numecho ($user->trainedAttackSold) ?>
</TD>
</TR>
<TR>
<TD><B>Trained Attack Mercenaries</B></TD>
<TD align=right>
<? numecho ($user->trainedAttackMerc) ?>
</TD>
</TR>
<TR>
<TD><B>Trained Defense Soldiers</B></TD>
<TD align=right>
<? numecho ($user->trainedDefSold)?>
</TD>
</TR>
<TR>
<TD><B>Trained Defense Mercenaries</B></TD>
<TD align=right>
<? numecho ($user->trainedDefMerc) ?>
</TD>
</TR>
<TR>
<TD><B>Untrained Soldiers</B></TD>
<TD align=right>
<? numecho ($user->untrainedSold) ?>
</TD>
</TR>
<TR>
<TD><B>Untrained Mercenaries</B></TD>
<TD align=right>
<? numecho ($user->untrainedMerc) ?>
</TD>
</TR>
<TR>
<TD class=subh><B>Spies</B></TD>
<TD class=subh align=right>
<? numecho ($user->spies) ?>
</TD>
</TR>
<TR>
<TD><B>Total Fighting Force</B></TD>
<TD align=right>
<? numecho (getTotalFightingForce($user))?>
</TD>
</TR>
</TBODY>
</TABLE>
<P>
<?
$merc=getCommonInfo();
?>
<FORM action=mercs.php method=post>
<TABLE class=table_lines cellSpacing=0 cellPadding=6 width="100%"
border=0>
<TBODY>
<TR>
<TH align=middle colSpan=4>Buy Mercenaries</TH></TR>
<TR>
<TH class=subh align=left>Mercenary Type</TH>
<TH class=subh align=right>Cost Per Unit</TH>
<TH class=subh align=right>Quantity Available</TH>
<TH class=subh align=middle>Quantity to Buy</TH></TR>
<TR>
<TD>Attack Specialist</TD>
<TD align=right><? numecho ($conf["mercenaries"]["atack"]["prise"]) ?> Gold</TD>
<TD align=right><? numecho ($merc->attackSpecCount);?></TD>
<TD align=middle><INPUT size=3 value=0 name=mercs_attack></TD></TR>
<TR>
<TD>Defense Specialist</TD>
<TD align=right>
<? numecho ($conf["mercenaries"]["defence"]["prise"]) ?>
Gold</TD>
<TD align=right>
<? numecho ($merc->defSpecCount );?>
</TD>
<TD align=middle><INPUT size=3 value=0 name=mercs_defend></TD></TR>
<TR>
<TD>Untrained</TD>
<TD align=right>
<? numecho ($conf["mercenaries"]["untrained"]["prise"]) ?>
Gold</TD>
<TD align=right>
<? numecho ($merc->untrainedCount );?>
</TD>
<TD align=middle><INPUT size=3 value=0 name=mercs_general></TD></TR>
<TR>
<TD align=middle colSpan=4><INPUT type=submit value=Buy>
</TD></TR></TBODY></TABLE><INPUT type=hidden
value=93aa2b6a02603399396203313b45827e name=hash>
<INPUT type=hidden value=1 name=buy_merc></FORM>
<?
include ("bottom.php");
?>
</TD></TR></TBODY></TABLE>
</BODY></HTML>