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

Solved TFS 0.3.6 db.executeQuery (Sqlite)

filipus

Member
Joined
Dec 31, 2010
Messages
229
Reaction score
12
I was looking fora db.executeQuery that could update the player on the database to a certain level, no skulls, in a certain position, etc...
I have this but it isn't working :/

Code:
db.executeQuery("UPDATE `players` SET `level` = `".. newlevel .."`,`experience` = `".. newexp .."`,`skull` = `".. newskulls .."`,`skulltime` = `"..newskulls.."`,`posx` = `"..posicionX.."`,`posy` = `"..posicionY.."`,`posz` = `"..posicionZ.."` WHERE `id` = `".. playerid .."`;")
 
I was looking fora db.executeQuery that could update the player on the database to a certain level, no skulls, in a certain position, etc...
I have this but it isn't working :/

Code:
db.executeQuery("UPDATE `players` SET `level` = `".. newlevel .."`,`experience` = `".. newexp .."`,`skull` = `".. newskulls .."`,`skulltime` = `"..newskulls.."`,`posx` = `"..posicionX.."`,`posy` = `"..posicionY.."`,`posz` = `"..posicionZ.."` WHERE `id` = `".. playerid .."`;")

Try with
Code:
db.executeQuery("UPDATE `players` SET `level` = ".. newlevel ..",`experience` = ".. newexp ..",`skull` = ".. newskulls ..",`skulltime` = "..newskulls..",`posx` = "..posicionX..",`posy` = "..posicionY..",`posz` = "..posicionZ.." WHERE `id` = ".. playerid ..";")

or if not working

Code:
db.executeQuery("UPDATE `players` SET `level` = '".. newlevel .."',`experience` = '".. newexp .."',`skull` = '".. newskulls .."',`skulltime` = '"..newskulls.."',`posx` = '"..posicionX.."',`posy` = '"..posicionY.."',`posz` = '"..posicionZ.."' WHERE `id` = '".. playerid .."';")

What u did in your script is that you mark with `` around the values, `` should be around columns, tables etc.
 
None of them work (I had actually tried all those ways also haha).

I know the function is being called because I added a
Code:
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "THIS WORKS GRAWW")
And it prints the message when the player dies (its a onDeath function). Now, I have no idea why it isn't running the query. I wrote it on the SQLite interface itself and it updates all tables so... I don't know ):::
 
None of them work (I had actually tried all those ways also haha).

I know the function is being called because I added a
Code:
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "THIS WORKS GRAWW")
And it prints the message when the player dies (its a onDeath function). Now, I have no idea why it isn't running the query. I wrote it on the SQLite interface itself and it updates all tables so... I don't know ):::

Have you tried with db.query instead of db.executeQuery?
 
@_CorneX_
I have. It doesn't recognize db.query (says its a nil value), possibly because I'm using TFS 0.3.6. But Im not sure that is the reason.

Someone said the query didn't go because you can't execute a query on a dead player. It that true or... ?
 
@_CorneX_
I have. It doesn't recognize db.query (says its a nil value), possibly because I'm using TFS 0.3.6. But Im not sure that is the reason.

Someone said the query didn't go because you can't execute a query on a dead player. It that true or... ?

Actually I am not sure about it, of course you should be able to execute a query onDeath.
But it is hard to say, without to see the whole script.
 
@_CorneX_

It has the complete script here. Already changed all the obvious errors (login name, execuTeQuery, etc...)
http://otland.net/threads/tfs-0-3-6-isnt-calling-a-script.210861/

Thanks for helping btw.

I saw in other thread that db.Query gave u a nil value. It should, because remove the db.Query to db.query .. (db.query is anyway for 0.4 I think)
Anyhow, I am not sure how TFS communicate with Sqlite. Never even tried it.

I think the query looks ok, but you can always try to change the query just for test in lua like:

Code:
db.executeQuery("UPDATE `players` SET `level` = 1,`experience` = 1,`skull` = 1,`skulltime` = 1,`posx` = 1,`posy` = 1,`posz` = 1 WHERE `id` = JUST_INSERT_A_PLAYERID")

Read the query and change the values, not use any lua variable just use pure digits.
Change JUST_INSERT_A_PLAYERID to an valid player id that exist in DB.

If not working, then it seems like it not communicate with the database at all? xD
 
Ok, tried it. It isn't connecting to the DB at all.
That is super weird, because all the players and values and etc are from the DB itself.
Anyone knows why?

Any tricks to solve this @_CorneX_ ? @Ninja
 
Code:
function onDeath(cid, corpse)
     local playerid = getPlayerGUID(cid)
     addEvent(db.executeQuery, 1, "UPDATE `players` SET `level` = 61,`experience` = 3428000,`skull` = 0,`skulltime` = 0,`posx` = 100,`posy` = 100,`posz` = 7 WHERE `id` = "..playerid.."")
     return true
end
 
Code:
function onDeath(cid, corpse)
     local playerid = getPlayerGUID(cid)
     addEvent(db.executeQuery, 1, "UPDATE `players` SET `level` = 61,`experience` = 3428000,`skull` = 0,`skulltime` = 0,`posx` = 100,`posy` = 100,`posz` = 7 WHERE `id` = "..playerid.."")
     return true
end

HAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
HAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
HAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

IT WORKSSSSS <3333333

Thank you so much!

Could you explain me why? Why does it go with an addEven and not with a normal db.executequery?

Man, I could even pay you now, Im so happy! thanks
 
You can't update things from players when the player is online, with death, the player is still online for a short time.
 
Last edited:
Back
Top