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

[Request]Lua-Sql-Tutorial

iFur

n3wbie
Joined
Jun 10, 2009
Messages
4
Reaction score
0
Location
Germany
Hi there,

I'm planning a script, but for this I have to how I can write from my LUA-Script something in the SQL-DB and how to read it.
Could someone please write a tutorial or just name me the functions and what they can do?
I searched now for an hour and found nothing -.-

Greets
iFur
 
What is it that you're trying to achieve?

In LUA, the command for executing an SQL query is db.executeQuery, as in:

db.executeQuery("INSERT INTO `player_deaths` (`player_id`, `time`, `level`, `killed_by`, `altkilled_by`) VALUES (" .. getPlayerGUID(cid) .. ", " .. os.time() .. ", " .. getPlayerLevel(cid) .. ", " .. db.escapeString(hitKillerName) .. ", " .. db.escapeString(damageKillerName) .. ");")

That was taken from the playerdeath.lua in creaturescripts. It just adds a new column the player_deaths table. I don't know how much experience you have with SQL, there's pleanty of info out there, if you wanted to make changes to an existing entry in the table you would use UPDATE, and to retrieve data from a table use SELECT.

hope this helps.
 
Back
Top