I'm trying to add a steal crystals mod to attak won. can someone please tell me what i am doing wrong here?
else
{
$stole=(int) (rand($r['money']/500,$r['money']/20));
$stolec=(int)(rand($r['crystals']/100,$r['crystals']/10));
$randnumer= rand(20,30);
$hosptime = (int) $randnumer;
$loseruser = $r['userid'];
$winneruser = $ir['userid'];
$winnerusername = $ir['username'];
$reasonhosp = 'Attacked by ';
$reasonhosp .= '
$reasonhosp .= $winneruser;
$reasonhosp .= '>';
$reasonhosp .= $winnerusername;
$reasonhosp .= '.';
mysql_query("UPDATE users SET hosptime=$hosptime WHERE userid=$loseruser",$c);
mysql_query("UPDATE users SET hospreason='$reasonhosp' WHERE userid=$loseruser",$c);
print "You beat {$r['username']} and stole \$$stole";
$qe=$r['level']*$r['level']*$r['level'];
$expgain=rand($qe/4,$qe/2);
$expperc=(int) ($expgain/$ir['exp_needed']*100);
print " and gained $expperc% EXP!";
mysql_query("UPDATE users SET exp=exp+$expgain,money=money+$stole WHERE userid=$userid",$c);
mysql_query("UPDATE users SET crystals=crystals+$stolec WHERE userid=$userid",$c);
mysql_query("UPDATE users SET hp=1,money=money-$stole WHERE userid={$r['userid']}",$c);
mysql_query("UPDATE users SET crystals=crystals-$stolec WHERE userid={$r['userid']}",$c);
event_add($r['userid'],"{$ir['username']} attacked you and stole $stole, and $stolec crystal(s).",$c);
//event_add($r['userid'],"{$ir['username']} attacked you and stole $stole.",$c);
$atklog=mysql_escape_string($_SESSION['attacklog']);
mysql_query("INSERT INTO attacklogs VALUES('',$userid,{$_GET['ID']},'won',unix_timestamp(),$stole,'$atklog');",$c);
$_SESSION['attackwon']=0;