Jump to content

Close
Photo

High Score Games Not Registering


  • Please log in to reply

#1
caleymad

Posted 25 March 2013 - 11:42 AM

caleymad

    Newbie

  • Gamer
  • 3 posts
  • Gender:Male
I've written my own arcade script, and I've tried to add high score games, but they wont register.

When I click Submit score on any of the games (I've tried Autobahn, Bombay Taxi and Air Hockey), none of them do anything. Each of the games has it's v32game.txt and Air Hockey has its other text file, but nothing happens!

EDIT 1: Following further investigation, I've noticed none of the games are calling do=verifyscore. Can anyone see the fault?

EDIT 2: I've also discovered that non v32 games aren't calling the ?do=newscore either. I've uploaded the game archery2000BH.swf to the /gameswf directory. I've tried the arcade both with SEO friendly urls (/play/id/game-name) and regular URLS (index.php?do=play&id=id), but I can't get it working. What's the problem?

Here's my code:
<?php
// some stuff removed ($_GET['do'] == the following):
// High Score Submission
case 'newscore':
case 'verifyscore':
case 'savescore':
// game id
$id = intval($_SESSION['yesHighScoreGameId']);
// get game info
$q = "SELECT title,score_type FROM `games` WHERE id='$id' AND scores_enabled = 1 LIMIT 1;";
$q = $sql->query($q);
$qc ++; // Query Count
// no results?
if($q->num_rows != 0){
// are we verifying score?
if($_GET['do'] == 'verifyscore'){
// We need to do this for score saving
$_SESSION['scoreRandom1'] = mt_rand(1,1000);
$_SESSION['scoreRandom2'] = mt_rand(1,1000);
$_SESSION['verify_score'] = array($_SESSION['scoreRandom1'], $_SESSION['scoreRandom2'], time());
// output this stuff
echo '&randchar='. $_SESSION['scoreRandom1'] .'&randchar2='. $_SESSION['scoreRandom2'] .'&savescore=1&blah=OK';
exit();
}
// logged in?
if($_SESSION['yesUserId'] > 0){
// Get results
$r = $q->fetch_assoc();
// whats the score?
$score = (float)(!empty($_POST['score']) ? $_POST['score'] : $_POST['gscore']);
// whats the game?
$game = (!empty($_POST['gname']) ? $_POST['gname'] : $_POST['game_name']);
$game = $sql->real_escape_string($game);
// v32 file stuff
if(is_file('arcade/gamedata/'.$game.'/v32game.txt')){
// set the control score
$controlscore = (float)($score * $_SESSION['scoreRandom1'] ^ $_SESSION['scoreRandom2']);
if($_POST['enscore'] != $controlscore OR !isset($_SESSION['scoreRandom1']) OR !isset($_SESSION['scoreRandom2'])){
// unset this stuff
unset($_SESSION['scoreRandom1']);
unset($_SESSION['scoreRandom2']);
// we wont be saving the score :-)
header('Location: index.php?do=errorsavescore&error=cheat');
exit();
}
}
// unset this stuff
unset($_SESSION['scoreRandom1']);
unset($_SESSION['scoreRandom2']);
// score cannot be 0
if($score == 0){
exit();
}
// Do we already have a score? If so, we need to update it because we cannot have more than one score. that's simply stupidity!
$sq = "SELECT id,score FROM `scores` WHERE gid='$id' AND uid='$uid' LIMIT 1;";
$sq = $sql->query($sq);
$qc ++; // query count
// do we have one?
if($sq->num_rows > 0){
// yes
$sr = $sq->fetch_assoc();
// is it bigger?
if($sr['score'] > $score AND $r['score_type'] == 'ASC' OR $sr['score'] < $score AND $r['score_type'] == 'DES'){
// yes
$sid = $sr['id'];
// update
$sq1 = "UPDATE `scores` SET score='$score', datetime='".time()."' WHERE id='$sid' LIMIT 1;";
$sql->query($sq1);
$qc ++; // query count
// msg
$msg = 'beat';
$msg_type = 'sucess';
}else{
// we did not beat it :(
$msg = 'previous';
$msg_type = 'info';
}
}else{
// no
$q = "INSERT INTO `scores`(uid,gid,datetime,score)
VALUES('$uid','$id','".time()."','$score')";
$sql->query($q);
$qc ++; // query count
// new score...
$msg = 'new';
$msg_type = 'success';
}
// now, what's the message?
switch($msg){
case 'beat':
$msg = '<strong>Score Beaten!</strong> Congratulations, you\'ve beaten your previous high score!';
break;
case 'previous':
$msg = 'You did not beat your previous high score for this game.';
break;
case 'new':
$msg = '<strong>New Score!</strong> Congratulations, your new high score has been added!';
break;
default:
$msg = 'ERROR';
$msg_type = 'error';
break;
}
// show content
$content = '<p class='.$msg_type.'">'.$msg.'<br /><br /><a href="/high-scores/'.$id.'">Check your high score compared to the rest!</a>';
}else{
// error
$content = '<p class="error">You must be logged in before you can submit a score!</p>';
}
}else{
// error
$content = '<p class="error">This game does not exist, or is not high score enabled: '.$id.'</p>';
}
// title
$title = 'Submit Score';
break;
// some stuff removed
?>


Can anyone assist me? I'm really struggling to see whats wrong when I compare it to other scripts.

Edited by caleymad, 25 March 2013 - 05:34 PM.


#2
caleymad

Posted 25 March 2013 - 07:00 PM

caleymad

    Newbie

  • Gamer
  • 3 posts
  • Gender:Male
I managed to resolve this issue.

Turns out it was the flash embed code I was using. I used a different flash embed, and it worked fine. What a silly error! :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users