Posts: 235
Threads: 34
Joined: Jul 2014
Reputation:
0
Hello, what is the most correct way to save achievements? I'll do an achievement system based on kills, duel wins, etc. then I can think of 2 ways: check if they have X kills and give it the achievement (when killing someone) or using a global timer checking everyone? I would also like to save it by mysql, is it advisable to use a separate table or create inside the users table? Thanks
Posts: 1,168
Threads: 60
Joined: Dec 2016
Reputation:
0
Use a seperate table with an Primary key auto IC ID and a column which holds the users/characters ID.
You don't need a timer for that.
Kill archievement? Let's say people get an archievment at 50 kills. Then you just check under OnPlayerDeath if the killer has more than 50 kills, if so, reward them the archievement.
Posts: 558
Threads: 59
Joined: Jun 2012
Reputation:
0
You do not need a variable for every achievement. You will perform MySQL database queries to select the achievement you want to load into a variable. Then use that variable to do whatever you want. I suggest creating a method like:
LoadPlayerAchievment(playerid, achvid);
Posts: 558
Threads: 59
Joined: Jun 2012
Reputation:
0
Well, every time you create a new achievement, you create it for the player, or the player name or character name or whatever you want to use. You need to create a table that has 2 foreign keys. One foreign key that comes from your account table. A second key from the table that handles achievements with data like name, progress, etc. (This one you have to create as well)
Then you create a third table that has 2 foreign keys, like accID (or whatever you want to use), achvID
So this table will probably be named 'player_achievements' and will have as column names the next variables:
p_achvid | pID (whatever you won't use here, like: charID, accountID, playerName, accountable, etc) | achvID
Where pID, achvid is a foreign key, and p_achvid is the primary key in this table.