Dev
Members-
Content count
5 -
Joined
-
Last visited
-
Days Won
10
Dev last won the day on February 8 2018
Dev had the most liked content!
Community Reputation
2 NeutralAbout Dev
-
Rank
Newbie
Development
-
Programming
Php, html, nodejs, css
-
Hi people, in this tutorial we are going to add a leaderboard system where we will display the total scores in a table which you earned by playing some games which give you score. First of all, we need to make some service-side changes and then move onto the web-side changes. This is a simple system, so first open your database and click the table 'penguins' and create a column named 'score', make sure it's INT(Integer) and also has a default value, '0'. Next, we would want to update that 'score' column whenever they play a mini-game so what we will do is go to the following folder: /Houdini/Houdini/Handlers/Games/ and open the __init__.py file. Well, I had to use the MYSQL module because I couldn't really understand sqlalchemy and MYSQLdb module seemed easy, so yeah. If you don't have the module, install it using the following command: pip install MySQLdb After that in the file, import this import MySQLdb after import math, time Now, we need to use the module so paste this code after the maxScorePerMinute = { array db = MySQLdb.connect(host="localhost", user="root", passwd="pass", db="houdini", autocommit=True) cur = db.cursor() Find the def handleSendGameOver(self, data): function and inside if self.server.stampGroups.isStampRoom(self.room.Id): after coinsEarned = determineCoinsEarned(self.room.Id, data.Score) add this: ID1 = self.user.ID cur.execute("UPDATE penguins SET score = score + %s WHERE ID = %s " % (data.Score, ID1)) Do the same for the next else statement: http://prntscr.com/ibb3b4 Restart Houdini, now onto the web-server part. <html> <head> <title>Leaderboard</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> </head> <center><h1>TOP 10 Score Leaderboard</h1></center> <center> <?php $db = new mysqli('localhost','root','pass','houdini'); if ($db->connect_error) { die('Error : ('. $db->connect_errno .') '. $db->connect_error); } $results = $db->query("SELECT username, score FROM penguins ORDER BY score DESC LIMIT 10"); echo "<table border='1' <tr> <th>Username</th> <th>Score</th> </tr>"; while($row = $results->fetch_array()) { echo '<tr>'; echo '<td>'.$row["username"].'</td>'; echo '<td>'.$row["score"].'</td>'; echo '</tr>'; } echo '</table>'; $db->close(); ?> </center> </body> </html> You can change the LIMIT 10 to whatever number you like. So, whenever someone plays a game their score will get updated and it will display on the leaderboard. Thanks, Dev.
-
That he was more professional in knifing people after that he got...
-
This tutorial is only for AS2. Things you need: 1. Flash cs6 2. Any decompiler will do For this tutorial I am going to use SoThink decompiler. Select any room and decompile it and open it in Flash CS6 http://prntscr.com/c23e5d You'll see a layer named 'Script Layer' edit the white frame by right-clicking on it and then click Actions http://prntscr.com/c23evs You should see the actionscript after clicking Actions, after that scroll down until you dont find triggers_mc._visible = false; When found add this code before it: var music = new Sound(this); music.loadSound("3.mp3", true); music.onSoundComplete = function () { music.start(); } http://prntscr.com/c23gm5 When done export the file by executing Ctrl + Alt + Shift + S on your keyboard. Make sure the file is a mp3 file and also make sure it is uploaded at your /play/ directory as it will only load songs from the play directory. Enjoy!
-
A happy little nickrobat...
-
Hi peeps! I've been in the community since four years and it has been a really fun experience so far, and my only purpose for joining this forum is to contribute towards the community and help the community grow. I've created many projects within these four years and some of the active ones are: Loungecp.us -> A social network and a CPPSHub. CPPSNews -> A news site for the community. PenguinUtopia -> An upcoming CPPS CPPSBot -> Coming soon. However, I plan on creating more projects to help the community grow. The programming languages I know are: 1. PHP 2. NodeJS 3. Html 4. CSS I plan on learning more programming languages; the next one would probably be python. Nice meeting you all, I hope to contribute more and make this community a fun place. On the other hand, is solero back yet?