whitevo
Feeling good, thats what I do.
Ok, so i wanted to add feature to my game what collects data about player achivements and failures against the bosslike creatures I have on my server.
This way players have something to compare themselves, how well they are doing in PVE envoirment.
Query is now ready and working like i wanted
This way players have something to compare themselves, how well they are doing in PVE envoirment.
Query is now ready and working like i wanted
Code:
for x=1, #spectators do
highscore(spectators[x]:getAccountId(), monsterName, spectators[x]:getVocation():getName())
end
Code:
function highscore(accID, monster, vocation)
local results = db.storeQuery("SELECT * FROM highscores WHERE account_id = "..accID.." AND vocation = '"..vocation.."' AND monster = '"..monster.."'")
if not results then
db.query("INSERT INTO highscores(account_id, vocation, monster) VALUES ("..accID..", '"..vocation.."', '"..monster.."')")
end
local tempAttempts = db.storeQuery("SELECT attempts, kills, deaths FROM highscores WHERE account_id = "..accID.." AND vocation = '"..vocation.."' AND monster = '"..monster.."'")
local attempts = result.getDataInt(tempAttempts, "attempts")
local kills = result.getDataInt(tempAttempts, "kills")
local lastAttempt = 0
if kills == 0 then lastAttempt = 1 end
db.query("UPDATE highscores SET attempts = "..attempts+(lastAttempt).. ", kills = "..kills+(1).." WHERE account_id = "..accID.." AND vocation = '"..vocation.."' AND monster = '"..monster.."'")
end
Last edited: