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

Lua [LuaSQL] The basics of LuaSQL!

Can u write something about useing "UPDATE" and how to get 1 column from SQL to variable. Like:
Code:
local frags =  assert(con:execute("SELECT 'frags' FROM 'player_frags' WHERE `player_name` = " .. killerName .. "; "))
frags = frags + 1 // << [B]will it work?[/B]
//save frags in table (update) - table has columns "player_id, frags, deaths, player_name, blocked"
I want add this code (but working code, its only example what i want to do) to playerdeath.lua. Its only way to make statistics of kills on my server (e-pvp with priv accs).
Can you write code for me or explain how to do it in first post?
 
This tutorial made me confused... 0.o
explain what the different parts of the scripts does or something! 0.o

//Saphira
 
Cool, but in the windows compilation(dev-cpp) I did not find the Lua SQL libraries(dev-pack).

Can you give me a link or post here?

Thank you.
 
Again..
Can anyone write anything about "select" function in LUAsql?
in "deathlist.lua" is
local cursor = assert(con:execute("SELECT `player_id` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUIDByName(getCreatureName(cid)) .. ";"))
How can I get value of "player_id" from "cursor"? I want select all (4-5) columns from table and do something with values from this array. In PHP its easy "$resultfromDB['name_of_column']". I need it to create NPC/talkaction for my web house auction/sell system :>
 
if you have the cursor and only selected one field then I think this will work:
player_id = cursor:fetch()
 
not work with newest tfs

This article is correct only for 0.2 series that uses LuaSQL. In newer versions of TFS there are special functions for accessing database (much easier to use).

You can find those files helpful in understanding it (all located in data/ directory): lib/004-database.lua, talkactions/scripts/reports.lua, talkactions/scripts/deathlist.lua

There is also LUA_FUNCTIONS file that contains all available functions,.
 
Back
Top