agar.io-clone
agar.io-clone copied to clipboard
Level system
I can implement the database for a level system but I would need someone to code it into the game so how this would work
in the database
tableName->users
fields->id,name,level,xp
pool.query ("SELECT * FROM users WHERE name='currentPlayer.name'", function (err,rows){ if (err) throw err; var user = rows; });
This will store the following in the variable user
[{id:1,name:'player',level:'1',xp:'1'}]
Now data can be accessed using
var playerLevel = parseInt (user[0].level);
Now playerLevel is equal to 1
It's a pretty straightforward process and sql and database management has always been one of my specialties and I would be happy to implement the database for this as long as someone can actually out it into the game
Wow! Nice! I'll try implementing a function like this:
function levelUp (playerName) {
tableName->users
fields->id,name,level,xp
pool.query ("SELECT * FROM users WHERE name="'playerName'" function (err,rows){ if (err) throw err; var user = rows; });
}
I haven't had much experience coming out of Python so if you find bugs please report.
from what ive been working on recently in a different branch you could use this
function getInfo(){ client.query("SELECT * FROM users WHERE uid='<USER_ID>'", function(err,res){ if(err){ console.log(err); } infoArray = res; } }
now set that to your users info
var level = infoArray["level"];
send to database
client.query("UPDATE users (name,level,xp) VALUES (name=<USER_NAME>,level=<USER_LEVEL>,xp=<USER_XP>);
is this still being worked on?
I wish I could spend more time on it but I really don't have the time the foundation for this exist in the current project but a full level system would still need to be worked out @Dve4Ever
Ok, and could you add my version to the demo list? The link is 'https://devooooyt.com' @flaminggenius
@Dve4Ever You can submit a pull request with yours added to the list