• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Windows Resetting player skills when they logout

Xikini

I whore myself out for likes
Senator
Premium User
Joined
Nov 17, 2010
Messages
6,798
Solutions
581
Reaction score
5,361
Been doing some research and having trouble with database queries.

I simply want to reset player skills everytime they logout..
I don't want to mess up the database.. so can someone confirm if this is a correct query?

I use uniform server

Code:
function onLogout(cid)
   addEvent(db.executeQuery, 1, "UPDATE `players` SET `maglevel` = 0 WHERE `id` = " .. getPlayerGUID(cid)) -- magic
   addEvent(db.executeQuery, 1, "UPDATE `player_skills` SET `0` = 10 WHERE `id` = " .. getPlayerGUID(cid)) -- fist
   addEvent(db.executeQuery, 1, "UPDATE `player_skills` SET `1` = 10 WHERE `id` = " .. getPlayerGUID(cid)) -- club
   addEvent(db.executeQuery, 1, "UPDATE `player_skills` SET `2` = 10 WHERE `id` = " .. getPlayerGUID(cid)) -- sword
   addEvent(db.executeQuery, 1, "UPDATE `player_skills` SET `3` = 10 WHERE `id` = " .. getPlayerGUID(cid)) -- axe
   addEvent(db.executeQuery, 1, "UPDATE `player_skills` SET `4` = 10 WHERE `id` = " .. getPlayerGUID(cid)) -- distance
   addEvent(db.executeQuery, 1, "UPDATE `player_skills` SET `5` = 10 WHERE `id` = " .. getPlayerGUID(cid)) -- shielding
   addEvent(db.executeQuery, 1, "UPDATE `player_skills` SET `6` = 10 WHERE `id` = " .. getPlayerGUID(cid)) -- fishing
   return true
end
 
Maybe this helps you a bit:

b2d61ff706945340048f90f8cba20a7b.png


So it looks good to me :) (But I'm not rlly good at these kind of things) don't blame me if It goes wrong.
 
Yep addEvent will help you here.
Because when player disconnects from game it will overwrite database values with the internal ones collected in TFS.
However I would like to point out that you should set the tries to 0 too. Else it might bug out next time they hit something with skilltries 10000 and on skill 10.
 
As @whitevo said you should reset the tries too. I don't know where they are stored in the server you're using so I can't tell you exactly how to. I'm sure you can work it out.

You can set all the values that are in the same table (player_skills) in one go, so your code would look like this.
Code:
function onLogout(cid)
    addEvent(db.executeQuery, 1, "UPDATE `players` SET `maglevel` = 0 WHERE `id` = " .. getPlayerGUID(cid)) -- magic
    addEvent(db.executeQuery, 1, "UPDATE `player_skills` SET `0` = 10, `1` = 10, `2` = 10, `3` = 10, `4` = 10, `5` = 10, `6` = 10 WHERE `id` = " .. getPlayerGUID(cid)) -- skills
    return true
end
 
Back
Top