• 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!

db.query question

klepacz

New Member
Joined
Aug 12, 2015
Messages
35
Reaction score
0
I made short script in login.lua to update db every login.
Code:
local playerGuid = player:getGuid()
db.query("UPDATE `players` SET `maglevel`=60  where `id`="..playerGuid)

And it works good just for the first character logged on server. If i change character to another or relog query seems not to execute. Can you explain to me why ?

EDIT.
Problem is different
Query is successfully changing DB values, but character still have the old ones.
How to reload them ? i need to reload all skills, maglvl
 
Last edited:
I made short script in login.lua to update db every login.
Code:
local playerGuid = player:getGuid()
db.query("UPDATE `players` SET `maglevel`=60  where `id`="..playerGuid)

And it works good just for the first character logged on server. If i change character to another or relog query seems not to execute. Can you explain to me why ?
If you are changing all of the players magic level to 60 then you don't need a where clause.

Since we don't know the structure of the script we won't be able to find you a solution, the only thing we can do for you is guess.
 
Tried db.executequery? Does it change anything ?
Doesn't work.

If you are changing all of the players magic level to 60 then you don't need a where clause.

Since we don't know the structure of the script we won't be able to find you a solution, the only thing we can do for you is guess.
I don't wanna change all the players ( this is just a sample I used to understand how query works, I'll add correct conditions later)
Lines of code in the first post are the only one I've added to original login.lua from official tfs 1.2, just above welcome message. The problem is that query execute just for the first player logged in game after server start (all the other lines executes every login)

Ok, i've figured out that the problem is different.
Query is successfully changing DB values, but character still have the old ones.
Example.
- Im loggin on character with 100 mlvl
- query changes mlvl of this char to 60 in DB
- refresh DB - mlvl =60 (good)
- but character still have 100 mlvl ingame

And i know why it like that. When i log in mlvl=100, query change it to 60, but when i log out character is saving to the current ingame stats - 100 mlvl

Any ideas how to fix it ?
 
Last edited by a moderator:
Ok, i've figured out that the problem is different.
Query is successfully changing DB values, but character still have the old ones.
Example.
- Im loggin on character with 100 mlvl
- query changes mlvl of this char to 60 in DB
- refresh DB - mlvl =60 (good)
- but character still have 100 mlvl ingame
The player is loaded already, it wont change anything if you change the value in the db.
If you want to change this you have to change it onLogout
 
The player is loaded already, it wont change anything if you change the value in the db.
If you want to change this you have to change it onLogout
I've edited my last post. I know it, but its going to set stats for new characters -> it can't be set with onLogout

I also don't see any lua function to load character from db or set magic level / skills to specific value
 
Last edited:
Back
Top