J
Jeffdev
Guest
Do you have a discord or something else? I'm trying to DM the code through here but it's telling me it won't send because its "spam-like"Certainly Provide as much details as possible (and don't send me your password please )
Do you have a discord or something else? I'm trying to DM the code through here but it's telling me it won't send because its "spam-like"Certainly Provide as much details as possible (and don't send me your password please )
Weird... I would prefer if you could email it. I'll send my mail in a private message.Do you have a discord or something else? I'm trying to DM the code through here but it's telling me it won't send because its "spam-like"
and
In display.php change DESC (which stands for descending) to ASC (which stands for ascending).How simple is it to invert the leader board so lowest score (best time) is ranked first.
If the form of the score is consistent throughout the levels, then you should NOT use multiple tables. Instead, you should just add a single indexed column specifying the level that the score applies to. Then the SQL for insertion becomes:Thanks for the php ( ASC) in inverting the leader board.
Another question I have is about multiple leader boards for a game. I'll working on something that requires a leader board for 12 levels. Can this be done in one database or is it better to make 12 individual databases?
INSERT INTO OnlineHighscores VALUES (NULL, :name, :score, :level)
SELECT * FROM OnlineHighscores WHERE level = :level ORDER BY score DESC
$sql = "SELECT * FROM gamenameleaderboard WHERE level = :level ORDER BY score ASC";
$sql = "SELECT * FROM gamenameleaderboard WHERE level = 11 ORDER BY score ASC";
send score gml
===
var name = url_encode(base64_encode(string(argument0)));
var args = "name="+name+"&score="+string(argument1)+"&level="+string(argument2)+"&hash=1234";
http_post_string("http://ftp.gamename.altervista.org/OnlineHighscores/addscore.php", args);
get score gml
===
var name = url_encode(base64_encode(string(argument0)));
var args = "name="+name+"&no_lines="+string(argument1)+"&level="+string(argument2)+"&hash=1234";
get_highscores = http_post_string("http://ftp.gamename.altervista.org/OnlineHighscores/display.php", args);
<?php
// Connect to database
$db = new PDO('mysql:host=localhost;dbname=my_gamename', 'gamename');
// Check secret key, if correct, then get names and scores
$has_found = 0;
$secretKey = "1234";
if($secretKey == $_POST['hash'])
{
// Get all data from the table, ordering from best to worst
$sql = "SELECT * FROM gamenameleaderboard WHERE level = :level ORDER BY score ASC";
$stmt = $db->prepare($sql);
$stmt->execute();
// Fetch the result into a nice format EXAMPLE: 1. Guest2837 100
// no_lines is the length of the list, generally you will want a top 10
$line = 1;
$no_lines = $_POST['no_lines'];
while($row = $stmt->fetch(PDO::FETCH_ASSOC))
{
// We only want a top no_lines
if($line <= $no_lines)
{
// Check if you are in the top no_lines
if($row['name'] == $_POST['name'])
{
$has_found = 1;
}
// Echo the top no_lines list
echo $line . ".-" . $row['name'] . "-" . $row['score'] . "|";
$line += 1;
}
else
{
// When you are not in the top no_lines list, search for your record
if($has_found == 0)
{
if($row['name'] == $_POST['name'])
{
$has_found = 1;
echo $line . ".-" . $row['name'] . "-" . $row['score'] . "|";
break;
}
$line += 1;
}
else
{
break;
}
}
}
if($line <= $no_lines)
{
for($i = $line; $i<=$no_lines; $i++)
{
echo $i . ".-" . "" . "-" . "" . "|";
}
}
}
?>
<?php
// Connect to database
$db = new PDO('mysql:host=localhost;dbname=my_gamename', 'gamename');
// Check secret key, if correct, then insert name and score
$secretKey = "1234";
if($secretKey == $_POST['hash'])
{
// Prepare statement
$sql = "INSERT INTO gamenameleaderboard VALUES (NULL, :name, :score, :level)"; // Change OnlineHighscores to your game name
$stmt = $db->prepare($sql);
$stmt->bindParam(':name', $name, PDO::PARAM_STR);
$stmt->bindParam(':score', $score, PDO::PARAM_INT);
$stmt->bindParam(':level', $level, PDO::PARAM_INT);
// Get name, score and hash from URL string
$name = $_POST['name'];
$score = $_POST['score'];
$level = $_POST['level'];
// Execute statement
$stmt->execute();
echo '1';
}
else
{
echo '0';
}
?>
// Get all data from the table, ordering from best to worst
$currentlevel = $_POST['level'];
$sql = "SELECT * FROM thegamename WHERE level =$currentlevel ORDER BY score ASC";
$stmt = $db->prepare($sql);
$stmt->execute();
That works, but it's not advisable. Now you do not make use of the bindParam functions, which prevents users providing strange input.Wow, figured it out. If anyone else needs to know just change the display.php file. You'll see I had to create a variable "currentlevel" before using it in the string.
PHP:// Get all data from the table, ordering from best to worst $currentlevel = $_POST['level']; $sql = "SELECT * FROM thegamename WHERE level =$currentlevel ORDER BY score ASC"; $stmt = $db->prepare($sql); $stmt->execute();
$stmt->bindParam(':level', $level, PDO::PARAM_INT);
$level = $_POST['level'];
<?php
// Connect to database
$db = new PDO('mysql:host=localhost;dbname=id1271297_uhaszysz', 'id1271297_uhaszysz','uhaszysz11');
// Check secret key, if correct, then insert name and score
$secretKey = "1234";
if($secretKey == $_POST['hash'])
{
// Prepare statement
$sql = "INSERT INTO otest VALUES (NULL, :name, :score)"; // Change OnlineHighscores to your game name
$stmt = $db->prepare($sql);
$stmt->bindParam(':name', $name, PDO::PARAM_STR);
$stmt->bindParam(':score', $score, PDO::PARAM_INT);
// Get name, score and hash from URL string
$name = $_POST['name'];
$score = $_POST['score'];
// Execute statement
$stmt->execute();
echo '1';
}
else
{
echo '0';
}
?>
<?php
// Connect to database
$db = new PDO('mysql:host=localhost;dbname=id1271297_uhaszysz', 'id1271297_uhaszysz','uhaszysz11');
// Check secret key, if correct, then get names and scores
$has_found = 0;
$secretKey = "1234";
if($secretKey == $_POST['hash'])
{
// Get all data from the table, ordering from best to worst
$sql = "SELECT * FROM otest ORDER BY score DESC";
$stmt = $db->prepare($sql);
$stmt->execute();
// Fetch the result into a nice format EXAMPLE: 1. Guest2837 100
// no_lines is the length of the list, generally you will want a top 10
$line = 1;
$no_lines = $_POST['no_lines'];
while($row = $stmt->fetch(PDO::FETCH_ASSOC))
{
// We only want a top no_lines
if($line <= $no_lines)
{
// Check if you are in the top no_lines
if($row['name'] == $_POST['name'])
{
$has_found = 1;
}
// Echo the top no_lines list
echo $line . ".-" . $row['name'] . "-" . $row['score'] . "|";
$line += 1;
}
else
{
// When you are not in the top no_lines list, search for your record
if($has_found == 0)
{
if($row['name'] == $_POST['name'])
{
$has_found = 1;
echo $line . ".-" . $row['name'] . "-" . $row['score'] . "|";
break;
}
$line += 1;
}
else
{
break;
}
}
}
if($line <= $no_lines)
{
for($i = $line; $i<=$no_lines; $i++)
{
echo $i . ".-" . "" . "-" . "" . "|";
}
}
}
?>
Hi there,I having an issue. I downloaded your tutorial demo from the marketplace. I inserted my servers info, however when I run it , its not updating the high score list with the current in game score. It appears to just refresh the blank high score list.
This happens when using my server and also the altervista server. The database on both servers doesn't update with anything when I run your example game.
Hi there,Yeah, i got same issue. It connects to the database but high score list is empty. Could you give a hand, im very confused.
Here are how i edited php codes:
Code:<?php // Connect to database $db = new PDO('mysql:host=localhost;dbname=id1271297_uhaszysz', 'id1271297_uhaszysz',****);
Certainly. Do you have your own domain? I do, and it works perfectly so this should be working. Please contact me via PM or drop a comment here in case you need some help. Happy holidays!Also in those 2 scripts in gamemaker where you put your link can link start with https:// ??
Thank you very much! If you have some spare time, would you mind rating it in the Marketplace? https://marketplace.yoyogames.com/assets/4205/online-highscores-exampleIt may not be difficult, but it's a great start for someone just starting out.
$db = new PDO('mysql:host=localhost;dbname=id1271297_uhaszysz', 'id1271297_uhaszysz','uhaszysz11');
Aha, I didn't understand you were not using Altervista. Then it should be fine I guess. However, I want to stress again:Hello brother, ty for anwser.
In your tutorial you said if i do not use altervista then i need to add my password as a third argument. im not sure if i done this correctly.
And yes, those are my corret parameters copied from server admin panel.
in this line i put: host,db name,db username,db passwordCode:$db = new PDO('mysql:host=localhost;dbname=id1271297_uhaszysz', 'id1271297_uhaszysz','uhaszysz11');
Hi there,It seems this tutorial doesn't work anymore. The example can't load the highscore list, and I can't create an account on Altervista. It keep causing an unknown error when I try to make an account.
GMscoreboard, an online highscore servise site had been shutdown for unknown reason a few days ago as well and there's no hope for it to be repaired.
I think Steam leaderboard is the only option available now...
You can use any website, even your own (if you have one). The procedure is 100% the same, you only need to figure out where you need to put everything but that's pretty doable.I have released 5 games on steam and all of my games have online scoreboard. I was using GMscoreboard for them, but as i mentioned, the service had been shutdown all of sudden and the scoreboard doesn't work amymore. So I must fix them as soon as possible or I'll probably have to delete my games.
I looked for alternative lesderboard tutorials and this tutorial was the only one, but unfortunately trying to make an account on Altervista says "unknown error happened", No matter how many times i try it in every internet browsers (internet explorer, chrome, firefox, etc). So I thought this tutorial is not working. I searched for applying steam leaderboard as well, but I can figure out how to apply it and there's no tutotial about it.
If I can't use Altervista, is it possible to use other websites ?
In sort, two things.The script is vulnerable for a replay attack, which is described by this reaction posted below the tutorial https://forum.yoyogames.com/index.php?threads/online-highscores.4291/#post-33902 and I found the Wikipedia page also particularly helpful: https://en.wikipedia.org/wiki/Replay_attack FrostyCat, thanks for mentioning this. It appears to me that these kind of attacks are not really a problem for such simple highscore systems, and there is no simple method to prevent this. In the future, I might be improving this in the tutorial.
Yes one thing is the problem started after they used the same wifi. Since then it doesnt work with any wifi on these devices. But before that Altervista had no problem with that wifi for months.@FKProjects You are sure that all users have access to the Internet? The error IOException generally means that you have a bad internet connection.
And I have never experienced Altervista blocking particular users.
special_chars = "$&+,/:;=?@ " + '"' + "'<>#%{}|\^~[]`!";
$sql = "INSERT INTO OnlineHighscores VALUES ( :userid,:name, :score)"
ON DUPLICATE KEY UPDATE name=:name, score=:score;
///rest of the original send score script
First make sure that your user ID column is set as a primary key or has a unique constraint, then use REPLACE instead of INSERT and get rid of the ON DUPLICATE. This is not a PHP issue, this is a SQL issue.@Appsurd
yeah i get the logic behind the id and all, is the php part that is complicated
it should look like this?
Code:$sql = "INSERT INTO OnlineHighscores VALUES ( :userid,:name, :score)" ON DUPLICATE KEY UPDATE name=:name, score=:score; ///rest of the original send score script
i can't figure it out, i searched everywhere and in every post on forums they define the values in differents ways
what im trying to do the create/update scores using the same script, it creates the values in the database, and if they userid already exist it updates them, .
maybe it fails because "on duplicate key update" may not be an php function, but a sql function
i don't know
Awesome! Also many thanks to @FrostyCat to help out!so REPLACE replaces but also insert? perfect ,thank you that will solve it
edit: yeah it solve it.
yeah, i made sure to set the id to unique and primary,
I will answer your question via a private message.@Appsurd
i had a problem when i create a host on 000webhost.com
All name and score not update on my database and i always had a empty highscore table. I think the addscore.php or display.php can't connect my database. Pls show me this connect code right or wrong:
$db = new PDO('mysql:host=localhost;dbname=id10831116_game_ranking','id10831116_rophi','password');
i attach one more pic of my database
"Holy open ended questions, Batman!"Nobody talks here about GDPR: General Data Protection Regulation. How can it be integrated with the online high score system?