Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Addons and Modifications > Mys v1.3.x Mods

Notices

Reply
 
Thread Tools Display Modes
  #21  
Old 01-27-2016, 07:28 PM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 110,830
Kyttias is on a distinguished road
Default

Hmm that might actually help a lot! :3
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it.
Reply With Quote
  #22  
Old 01-27-2016, 07:53 PM
Hwona's Avatar
Hwona Hwona is offline
Member
 
Join Date: Mar 2013
Posts: 620
Gender: Female
Credits: 58,119
Hwona is on a distinguished road
Default

This should work?
Overwrite your games/hilo/sendscore.php file with this
Edit: Sorry, 1.3.4 has a different cookie file than my version (I posted my file). Replace your classes/class_cookies.php file with:
class_cookies

Last edited by Hwona; 01-28-2016 at 05:54 PM.
Reply With Quote
  #23  
Old 02-04-2016, 01:41 PM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 110,830
Kyttias is on a distinguished road
Default

MAJOR BUG WAS FIXED @ Feb 4, 1:30PM EST
If you have installed before this date, please redownload the latest copy, REPLACE sendscore.php, and DELETE all entries in the 'adopts_games' table to prevent corrupt data.

Thanks Abronsyth for reporting the bug, I apologize for the wait in getting it fixed. Let me know if for some reason the bug hasn't been fixed??????

For Wallie - the sendscore.php file has been entirely revised, but for the better (you'll see what I mean). All you have to do is change some variables near the top for the name of the game and number of plays, and this will make it easier for other game developers. I think this version is what you should use if you want to continue to cross check with cookies to prevent users from playing as other people (but I haven't been able to test it):
  Spoiler: cookie version of sendscore.php 
PHP Code:
<?php
/* What game is it, how many daily plays are there? */
$game_name "HiLo";
$number_of_plays 20;

/* This function will help sanitize input to prevent errors. */
function sanitizeInput($data) {
    
$data trim($data);
    
$data stripslashes($data);
    
$data htmlspecialchars($data);
    return 
$data;
}

/* Find when and who! */
$day date('z');
$username sanitizeInput($_POST['username']);

/* If the username matches the cookie from login, proceed, if not, throw an error: */
$cookie_name 'mysusername';
$cookievalue $_COOKIE[$cookie_name];
if (
$cookievalue != $username) {
    
$warning "Please do not exploit the system!";
    return 
$warning;
} else {
    
/* This sets up the database connection. */
    
include("../../inc/config.php");  
    
$db = new mysqli(DBHOSTDBUSERDBPASSDBNAME);
    if (
$db->connect_error) { die("Database connection failed!"); }

    
/* Grab this user's info on this game from the database. */
    
$game_data "SELECT * FROM adopts_games WHERE `username` = '{$username}' AND `game` = '{$game_name}'";
    
$result mysqli_query($db$game_data);
    
$game mysqli_fetch_array($result);

    
/* If no data is found with the user having ever played before... create some! */
    
if (!$game) {
        
$sql "INSERT INTO `adopts_games`(`plays`, `username`, `game`, `timestamp`) VALUES ('{$number_of_plays}', '{$username}', '{$game_name}', '{$day}')";
        if (
$db->query($sql) === FALSE) { echo "Error creating new game data: " $db->error; }
    }

    
/* If a score is being sent through post data, do this. */
    
if (isset($_POST['amt'])) {
        
$score sanitizeInput($_POST['amt']);
        
// If there are still plays left for today's game...
        
if ($game['plays'] > 0){
            
// Add score to user's money.
            
$sql "UPDATE adopts_users SET `money` = money + $score WHERE `username` = '{$username}'";    
            if (
$db->query($sql) === TRUE) { echo "Score updated successfully!"; } else { echo "Error updating score: " $db->error; }

            
// Reduce the number of plays left available for this game by one & updates the timestamp to reflect current day of the year.
            
$plays_left $game['plays'] - 1;
            
$sql "UPDATE adopts_games SET `plays` = '{$plays_left}', `timestamp` = '{$day}' WHERE `username` = '{$username}' AND `game` = '{$game_name}'";
            if (
$db->query($sql) === TRUE) { echo "Game data updated successfully!"; } else { echo "Error updating game data: " $db->error; }
        }
    }

    if (isset(
$_POST['plays'])) {
        
// Check if today matches the timestamp in the database.
        
if (date('z') != $game['timestamp']){
            
// If the timestamp is different, reset plays to max and update the timestamp to today.
            
$sql "UPDATE adopts_games SET `plays` = '{$number_of_plays}', `timestamp` = '{$day}' WHERE `username` = '{$username}' AND `game` = '{$game_name}'";
            if (
$db->query($sql) === TRUE) { echo "{$number_of_plays}"; } else { echo "Error updating time stamp: " $db->error; }
        } else {
            
// If the timestamp is the same, send back the state of the game.
            
if ($game['plays'] <= 0){ echo "GameOver"; } else { echo $game['plays']; } 
        }
    }

    
$db->close();

}
?>
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it.

Last edited by Kyttias; 02-04-2016 at 01:49 PM.
Reply With Quote
  #24  
Old 02-04-2016, 03:15 PM
Abronsyth's Avatar
Abronsyth Abronsyth is offline
A Headache Embodied
 
Join Date: Aug 2011
Location: NY
Posts: 1,011
Gender: Male
Credits: 133,075
Abronsyth is on a distinguished road
Default

I'm glad you were able to get it fixed! Thank you for sharing :)
__________________
My Mods Site (1.3.4, 2020 Mods)
Reply With Quote
  #25  
Old 02-16-2016, 08:07 AM
gunpowdercat gunpowdercat is offline
Member
 
Join Date: Feb 2016
Posts: 29
Gender: Female
Credits: 1,919
gunpowdercat is on a distinguished road
Default

I did all of what it said to do before I could follow the link to get to the game-- issue is, it just redirects me to my homepage. How do I fix this? I uploaded the files, it successfully worked- but mysite.com/hilo just redirects me.
Reply With Quote
  #26  
Old 02-16-2016, 10:42 AM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 110,830
Kyttias is on a distinguished road
Default

Can you confirm for me that /hilo.php, ../view/hiloview.php, and ../games/.htaccess exist for me in their proper directories? If any of these files are missing or out of place it would cause a redirect.
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it.
Reply With Quote
  #27  
Old 02-16-2016, 10:51 AM
gunpowdercat gunpowdercat is offline
Member
 
Join Date: Feb 2016
Posts: 29
Gender: Female
Credits: 1,919
gunpowdercat is on a distinguished road
Default

Quote:
Originally Posted by Kyttias View Post
Can you confirm for me that /hilo.php, ../view/hiloview.php, and ../games/.htaccess exist for me in their proper directories? If any of these files are missing or out of place it would cause a redirect.

I ended up figuring it out--- Everything works, except, after 1 play, the cards/numbers completely disappear. Everything is in the correct spot.
http://prntscr.com/a41iu5
Reply With Quote
  #28  
Old 02-16-2016, 11:03 AM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 110,830
Kyttias is on a distinguished road
Default

Well... you've modified the base files by changing the number of plays. Did you at least confirm it was working before you started tinkering with it?
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it.
Reply With Quote
  #29  
Old 02-16-2016, 11:56 AM
gunpowdercat gunpowdercat is offline
Member
 
Join Date: Feb 2016
Posts: 29
Gender: Female
Credits: 1,919
gunpowdercat is on a distinguished road
Default

Quote:
Originally Posted by Kyttias View Post
Well... you've modified the base files by changing the number of plays. Did you at least confirm it was working before you started tinkering with it?
Yes; I also changed it back to make sure that wasnt the issue.
Reply With Quote
  #30  
Old 02-16-2016, 12:37 PM
NobodysHero's Avatar
NobodysHero NobodysHero is offline
Co-Owner of MystFell
 
Join Date: Nov 2013
Posts: 144
Gender: Female
Credits: 21,760
NobodysHero is on a distinguished road
Default Same issue: No Longer Displays Cards After 1st Turn.

I have that same issue. The only file I changed was the hilo_non.js to update the amount of money offered. Also, doesn't appear that my score is updating? Having the same issue with the Word Scramble game, which used your coding as a foundation.

Below is my hilo_non.js file and some screenshots for reference and piece of mind. Didn't included view and index file screenshots, but both are placed appropriately.

Code:

PHP Code:
$(function() {
    
checkPlays();
});

var 
plays 20;
var 
score 0;
var 
first Math.floor(Math.random()*16);

$(
'.first').html(first);

$(
'.guess').click(function(){
  if (
plays >= 0){
    var 
second Math.floor(Math.random()*16);
    $(
'.second').html(second);
    if ($(
this).hasClass('higher')){
      if (
first <= second){
        
resultIs('correct'second);
        
sendScore(150);
      } else {
        
resultIs('incorrect'second);
        
sendScore(0);
      }
    }
    if ($(
this).hasClass('lower')){
      if (
first >= second){
        
resultIs('correct'second);
        
sendScore(150);
      } else {
        
resultIs('incorrect'second);
        
sendScore(0);
      }
    }
  }
});

function 
resultIs(resultsecond){
  $(
'.result').html(result);
  $(
'.result').fadeIn(1000, function(){
    $(
'.first').fadeOut(500);
      $(
'.second').fadeOut(500, function(){    
      $(
'.first').html(second);
      
first second;
      
plays plays 1;
      $(
'.first').fadeIn(500);
      $(
'.second').html('?');
      $(
'.second').fadeIn(500);      
      $(
'.plays').html(plays);
      if (
result == 'correct'){
        
score score 150;
        
current parseFloat(window.parent.$('.money').text());
        
window.parent.$('.money').fadeTo(1000.1);
        
window.parent.$('.money').text((current score));
        
window.parent.$('.money').fadeTo(1001);
      }
      $(
'.score').html(score);
      if (
plays <= 0){
        
disableGame();
      }
    });
  }); 
  $(
'.result').fadeOut(500);
}

function 
sendScore(amt) {
  var 
values = {
    
'username': $("#username").text(),
    
'amt'amt
  
};
  $.
ajax({
    
url"sendscore.php",
    
type"POST",
    
datavalues,
  }).
done(function(status){
    if (
status == "GameOver"){
      
disableGame();
    } else {
      $(
'.plays').html(status);
      
plays status;
    }
  });
}

function 
disableGame(){
  $(
'.plays').html("0");
  $(
'.guess').off('click');
  $(
'.guess').css'cursor''not-allowed' );
  $(
'.arrow-box').fadeTo('slow'0.3);
  $(
'.first').html('game');
  $(
'.second').html('over');
  $(
'.finalscore').html("<b>Plays Left Today:</b> 0 of 20<h2>See You Tomorrow!</h2>");
}

function 
checkPlays(){
  var 
values = {
    
'username': $("#username").text(),
    
'plays''check'
  
};
  $.
ajax({
    
url"sendscore.php",
    
type"POST",
    
datavalues,
  }).
done(function(status){
    if (
status == "GameOver"){
      
disableGame();
    } else {
      $(
'.plays').html(status);
      
plays status;
    }
  });

Screenshots:




Reply With Quote
Reply

Tags
ajax, game, higher or lower, javascript


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 11:09 AM.

Currently Active Users: 711 (0 members and 711 guests)
Threads: 4,081, Posts: 32,031, Members: 2,016
Welcome to our newest members, jolob.
BETA





What's New?

What's Hot?

What's Popular?


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636