Alright.. First thing's first.. I set up a cron and it's pointing to the right directory.. I had the server host config it since it wasn't working for me right.. For whatever reason, the files I use have the include which contains the DB info to connect to DB. Whenever the cron runs it sends me an error msg saying:
Parse error: syntax error, unexpected $end in /home/leavscom/public_html/includes/cfiles/attack.php on line 1134
Now I've tried editing this script in every way and it always shows that line as the error.. The last line is just a ?> at the end of the code.. If that error doesn't show up it comes up with an error that says "cannot connect "nobody @ leavscom" to db or something of that nature.. This is the code..
{some parts are cut short because it was to long to paste}
<?php
/*************************************************************************************************************************/
// Settings
$rank = nrank; // Name of Global User Rank- Default nrank
$search = nickname; // Name of variable you want to search- Default nickname
/*************************************************************************************************************************/
// Opens Database
include '../../includes/config.php';
if (!($game=@mysql_connect($gamedbhost,$gamedbuser,$gamedbpassword))) {
print "Failed to connect to the $gamename database, please seek admin assistance<br>";
exit;
}
function took_shot ($varvictim,$attacker,$type,$id,$damage){
global $prefix;
$time=time();
$query= "INSERT INTO $prefix.personal_news (`to`, `message`, `timestamp`, `status`) VALUES ('$varvictim', 'As you were sitting on your couch, $attacker shot you through the window!', '$time', '')";
$result=mysql_query($query) or die(mysql_error());
mysql_query("UPDATE $prefix.adv_stats SET shotsreceived=shotsreceived+'1' WHERE nickname='".$varvictim."'");
mysql_query("UPDATE $prefix.adv_stats SET shotstaken=shotstaken+'1' WHERE nickname='".$attacker."'");
$query= "INSERT INTO $prefix.personal_news (`to`, `message`, `timestamp`, `status`) VALUES ('$attacker', 'You went round to ".$varvictim."s home. You shot them through the window!', '$time', '')";
$result=mysql_query($query) or die(mysql_error());
$query= "INSERT INTO $prefix.tw_shots (`id`, `victim`, `attacker`, `type`,`shot_id`,`timestamp`,`attack_type`) VALUES ('','$varvictim','$attacker', '$type', '$id', '$time', 'Normal Skin Shot')";
$result=mysql_query($query) or die(mysql_error());
$query= "UPDATE user_skills set level_health=level_health-'$damage' where nickname='$varvictim'";
$result=mysql_query($query) or die(mysql_error());
$query= "UPDATE user_characters set attacked='$time', item_thug=item_thug-'$killed' where nickname='$varvictim'";
$result=mysql_query($query) or die(mysql_error());
///This line errors out as well at times
$attack = mysql_query("SELECT * FROM attack_que ORDER BY time DESC;");
while ($attacks = mysql_fetch_array($attack))
{
$r = mysql_fetch_array(mysql_query("SELECT * FROM user_skills where nickname='$attacks[attacker]'")) or die(mysql_error());
$attacks[ga]=$r[skill_gunaccuracy];
if($attacks[weapon]=='3'){
if($attacks[ga]>69 and $attacks[ga]<101){
$rand=rand(1,4);
if($rand=='1'){
$shots='5';
$damage='25';
}
else
{
$shots='10';
$damage='30';
}
}
if($attacks[ga]<69 and $attacks[ga]>30){
$rand=rand(1,4);
if($rand==1){
$shots='10';
$damage='25';
}
else{
$shots='5';
$damage='20';
}
}
if($attacks[ga]>5 and $attacks[ga]<30){
$rand=rand(1,3);
if($rand=='1'){
$shots='2';
$damage='5';
}
elseif($rand=='2'){
$shots='1';
$damage='3';
}
else
{
$shots='0';
$damage='0';
}
}
}
if($attacks[weapon]=='4'){
if($attacks[ga]>69 and $attacks[ga]<101){
$rand=rand(1,4);
if($rand=='1'){
$shots='5';
$damage='25';
}
else
{
$shots='10';
$damage='30';
}
}
if($attacks[ga]<69 and $attacks[ga]>30){
$rand=rand(1,4);
if($rand==1){
$shots='10';
$damage='25';
}
else{
$shots='5';
$damage='20';
}
}
if($attacks[ga]>5 and $attacks[ga]<30){
$rand=rand(1,3);
if($rand=='1'){
$shots='2';
$damage='5';
}
elseif($rand=='2'){
$shots='1';
$damage='3';
}
else
{
$shots='0';
$damage='0';
}
}
}
if($attacks[weapon]=='2'){
if($attacks[ga]>69 and $attacks[ga]<101){
$rand=rand(1,4);
if($rand=='1'){
$shots='5';
$damage='30';
}
else
{
$shots='2';
$damage='25';
}
}
if($attacks[ga]<69 and $attacks[ga]>30){
$rand=rand(1,4);
if($rand==1){
$shots='5';
$damage='30';
}
else{
$shots='2';
$damage='25';
}
}
if($attacks[ga]>5 and $attacks[ga]<30){
$rand=rand(1,4);
if($rand=='1'){
$shots='1';
$damage='5';
}
else
{
$shots='0';
$damage='0';
}
}
}
if($attacks[weapon]=='1'){
if($attacks[ga]>69 and $attacks[ga]<101){
$rand=rand(1,4);
if($rand=='1'){
$shots='5';
$damage='20';
}
else
{
$shots='2';
$damage='15';
}
}
if($attacks[ga]<69 and $attacks[ga]>30){
$rand=rand(1,4);
if($rand==1){
$shots='5';
$damage='20';
}
else{
$shots='2';
$damage='15';
}
}
if($attacks[ga]>5 and $attacks[ga]<30){
$rand=rand(1,4);
if($rand<'3'){
$shots='1';
$damage='5';
}
else
{
$shots='0';
$damage='0';
}
}
}
$victim = mysql_fetch_array(mysql_query("SELECT * FROM user_characters where nickname='$attacks[victim]'")) or die(mysql_error());
$attacker = mysql_fetch_array(mysql_query("SELECT * FROM user_characters where nickname='$attacks[attacker]'")) or die(mysql_error());
$victim_p = mysql_fetch_array(mysql_query("SELECT * FROM user_profiles where nickname='$attacks[victim]'")) or die(mysql_error());
$victim_h = mysql_fetch_array(mysql_query("SELECT * FROM user_skills where nickname='$attacks[victim]'")) or die(mysql_error());
$time=time();
$la=$time-30;
$laa=$time-3600;
$online=$time-120;
if($victim_p[lastactive]==$online && $victim[attacked]==$la){
$query= "INSERT INTO $prefix.personal_news (`to`, `message`, `timestamp`, `status`) VALUES ('$attacks[attacker]', 'Sorry, You can only shoot once per minute.', '$time', '')";
$result=mysql_query($query) or die(mysql_error());
$query= "DELETE from attack_que where id='$attacks[id]'";
$result=mysql_query($query) or die(mysql_error());
$sql="UPDATE user_characters SET tokens=tokens+'70' WHERE nickname='$attacks[attacker]'";
mysql_query($sql);
}
elseif($victim_p[lastactive]==$online && $victim[attacked]==$laa)
{
$timeleft = $victim[attacked] - time();
$days = floor($timeleft/86400);
$timeleft -= $days*86400;
$hours = floor($timeleft/3600);
$timeleft -= $hours*3600;
$minutes = floor($timeleft/60);
$timeleft -= $minutes*60;
$query= "INSERT INTO $prefix.personal_news (`to`, `message`, `timestamp`, `status`) VALUES ('$attacks[attacker]', 'Sorry, $attacks[victim] is currently hiding, try again in <b>$minutes</b> Minutes and <b>$timeleft</b> Seconds.', '$time', '')";
$result=mysql_query($query) or die(mysql_error());
$query="DELETE from attack_que where id='$attacks[id]'";
$result=mysql_query($query) or die(mysql_error());
$sql="UPDATE user_characters SET tokens=tokens+'70' WHERE nickname='$attacks[attacker]'";
mysql_query($sql);
}
else
{
$whack_cost_money=15000; // cost per whack attempt
$whack_cost_tokens=70; // how many tokens per whack attempt make sure to update the que too
$kk=$victim[bodyguards_health];
$kevlar=$kk-$damage;
$time=time();
$random=rand(1,100);
if($attacks[weapon]==4)
{
$random=$random+20;
$query="UPDATE $prefix.user_characters SET weapon='0', jammed='' WHERE nickname='" . $attacks["attacker"] . "'";
$result=mysql_query($query);
}
$hp=$victim_h[level_health]-$damage;
$dealt='';
if($random<=5 and $victim[bodyguards]!=0){
$type='2';
bg_lost($attacks[victim],$attacks[attacker],$type,$attacks[id]);
$dealt='yes';
}
elseif($victim[bodyguards]!=0 and $kevlar>=1 and $dealt!='yes'){
bg_shot($attacks[victim],$attacks[attacker],1,$attacks[id],$damage);
}
elseif($kevlar<=0 and $victim[bodyguards]>=1 and $dealt!='yes'){
$type='1';
bg_lost($attacks[victim],$attacks[attacker],$type,$attacks[id]);
$dealt='yes';
}
elseif($random<=5 and $victim[bodyguards]==0){
$type='1';
dead($attacks[victim],$attacks[attacker],$attacks[death],$type,$attacks[id]);
$query= "INSERT INTO $prefix.tw_kills (`id`, `victim`, `killer`, `timestamp`, `info`) VALUES ('', '$attacks[victim]', '$attacks[attacker]'
, '$time', 'HeadShot')";
$result=mysql_query($query) or die(mysql_error());
}
else
{
if($hp>=1 and $victim[bodyguards]=='0'){
took_shot($attacks[victim],$attacks[attacker],1,$attacks[id],$damage);
}
else
{
$type='2';
dead($attacks[victim],$attacks[attacker],$attacks[death],$type,$attacks[id]);
$query= "INSERT INTO $prefix.tw_kills (`id`, `victim`, `killer`, `timestamp`, `info`) VALUES ('', '$attacks[victim]', '$attacks[attacker]'
, '$time', 'Normal Kill')";
$result=mysql_query($query) or die(mysql_error());
}
}
?>
MOD EDIT: [PHP] bbcode tags added.