agar.io-clone icon indicating copy to clipboard operation
agar.io-clone copied to clipboard

Level system

Open CoderJoeW opened this issue 8 years ago • 6 comments

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

CoderJoeW avatar Nov 27 '16 11:11 CoderJoeW

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.

vikramdurai avatar Dec 09 '16 10:12 vikramdurai

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>);

CoderJoeW avatar Dec 09 '16 23:12 CoderJoeW

is this still being worked on?

Dve4Ever avatar May 13 '19 20:05 Dve4Ever

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

CoderJoeW avatar May 20 '19 14:05 CoderJoeW

Ok, and could you add my version to the demo list? The link is 'https://devooooyt.com' @flaminggenius

Dve4Ever avatar May 22 '19 14:05 Dve4Ever

@Dve4Ever You can submit a pull request with yours added to the list

CoderJoeW avatar Jun 05 '19 22:06 CoderJoeW