executeSQLQuery("CREATE TABLE IF NOT EXISTS PlayersTag (player, serial, tag, colour)")
addEventHandler("onPlayerQuit", root,
function ()
local tag = getElementData(source, "tag")
local colour = getElementData(source, "colour")
local playerName = getPlayerName(source)
local serial = getPlayerSerial(source)
local sqlTag = executeSQLQuery("SELECT tag FROM PlayersTag WHERE serial=?", serial)
if isGuestAccount(getPlayerAccount(source)) then return end
if not tag or not colour then return end
if sqlTag == 0 then
executeSQLQuery("INSERT INTO PlayersTag(player, serial, tag, colour) VALUES(?,?,?,?)", playerName, serial, tag, colour)
else
executeSQLQuery("UPDATE PlayersTag SET player=?,serial=?,tag=?,colour=? WHERE serial=?", playerName, serial, tag, colour)
end
end
)
addEventHandler("onPlayerLogin", root,
function ()
local serial = getPlayerSerial(source)
local sqlTag = executeSQLQuery("SELECT tag FROM PlayersTag WHERE serial=?", serial)
local sqlColour = executeSQLQuery("SELECT colour FROM PlayersTag WHERE serial=?", serial)
if sqlTag ~= 0 then
setElementData(source, "tag", sqlTag)
setElementData(source, "colour", sqlColour)
outputChatBox("Your tag is: "..sqlTag, source)
else
outputChatBox("You havn't a tag", source)
end
end
)