Two simple Sql functions, getPlayerAccount(name) and getAccountType(id).
I don't think I need to explain what they do.
They can be used for example...to make talkactions only for certain accounts or certain accountypes, or maybe a spy rune that shows the account number too...etc
And they can be easily edited to make them get other attributes like email...
getPlayerAccount is already in TFS 0.3 as getPlayerAccountId and getPlayerAccount and account types are not used anymore.
Add this in global.lua
If you are using TFS 0.3, this may be useful:
getAccountGroup(accid)
I don't think I need to explain what they do.
They can be used for example...to make talkactions only for certain accounts or certain accountypes, or maybe a spy rune that shows the account number too...etc
And they can be easily edited to make them get other attributes like email...
getPlayerAccount is already in TFS 0.3 as getPlayerAccountId and getPlayerAccount and account types are not used anymore.
Add this in global.lua
PHP:
function [B]getPlayerAccount[/B](name)
dofile("./config.lua")
if sqlType == "mysql" then
env = assert(luasql.mysql())
con = assert(env:connect(mysqlDatabase, mysqlUser, mysqlPass, mysqlHost, mysqlPort))
else -- sqlite
env = assert(luasql.sqlite3())
con = assert(env:connect(sqliteDatabase))
end
local nametodb = escapeString(name)
result_plr = assert(con:execute("SELECT `account_id` FROM `players` WHERE `name` = '" .. nametodb .. "';"))
player = result_plr:fetch({}, "a")
local players = 0
while player do
players = players + 1
account = tonumber(player.account_id)
player = result_plr:fetch (player, "a")
end
con:close()
env:close()
return account
end
PHP:
function [B]getAccountType[/B](id)
dofile("./config.lua")
if sqlType == "mysql" then
env = assert(luasql.mysql())
con = assert(env:connect(mysqlDatabase, mysqlUser, mysqlPass, mysqlHost, mysqlPort))
else -- sqlite
env = assert(luasql.sqlite3())
con = assert(env:connect(sqliteDatabase))
end
result_plr = assert(con:execute("SELECT `id`, `type` FROM `accounts` WHERE `id` = '" .. id .. "';"))
account = result_plr:fetch({}, "a")
local accounts = 0
while account do
accounts = accounts + 1
acctype = tonumber(account.type)
account = result_plr:fetch (account, "a")
end
con:close()
env:close()
return acctype
end
getAccountGroup(accid)
PHP:
function getAccountGroup(accid)
if type(accid) ~= 'number' then
debugPrint("getAccountGroup: Invalid account number.")
return LUA_ERROR
end
local accdata = db.getResult("SELECT `id`, `group_id` FROM `accounts` WHERE `id` = " .. accid .. ";")
if(accdata:getID() ~= -1) then
local accgroup = accdata:getDataInt("group_id")
accdata:free()
return accgroup
else
debugPrint("getAccountGroup: Account doesn\'t exists.")
return LUA_ERROR
end
end
Last edited: