Osmose
hunf hunf
- Joined
- May 15, 2009
- Messages
- 28
- Reaction score
- 0
Im writing a script to show the top 10 list for a skill in game
everything works like a charm but most times i got this warning on console
Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/top.luanSay
luaGetPlayerNameByGUID(). Player not found
searched the database for invalid players records and i found nothing wrong
here's the code
thank you in advance
everything works like a charm but most times i got this warning on console
Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/top.luanSay
luaGetPlayerNameByGUID(). Player not found
searched the database for invalid players records and i found nothing wrong
here's the code
PHP:
function onSay(cid, words, param, channel)
local dbQuery = ""
local dbSkill = ""
local name = ""
local skill = ""
local resultStr = ""
local paramSkills = {
{ "club", 1 , "Club Fighting" },
{ "sword", 2 , "Sword Fighting" },
{ "axe", 3 , "Axe Fighting" },
{ "distance", 4 , "Distance Fighting" },
{ "shield", 5 , "Shielding" },
{ "level", 6 , "Level" },
{ "ml", 7 , "Magic level" }
}
if param == "" then
doPlayerSendCancel(cid, "Usage: !top <skill>, type !help for more details.")
return true
end
for _, skillList in pairs(paramSkills) do
if param == skillList[1] then
dbSkill = skillList[2]
end
end
if dbSkill == "" then
doPlayerSendCancel(cid, "Usage: !top <skill>, type !help for more details.")
return true
elseif dbSkill == 6 then
dbQuery = "SELECT `name`, `level` FROM players ORDER BY `level` DESC LIMIT 10;"
elseif dbSkill == 7 then
dbQuery = "SELECT `name`, `maglevel` FROM players ORDER BY `maglevel` DESC LIMIT 10;"
else
dbQuery = "SELECT `player_id`, `skillid`, `value` FROM `player_skills` WHERE `skillid` = "..dbSkill.." AND `player_id` IN (SELECT id FROM players) ORDER BY `value` DESC LIMIT 10;"
end
local result = db.getResult(dbQuery)
if(result:getID() ~= -1) then
repeat
if dbSkill < 6 then
name = getPlayerNameByGUID(tonumber(result:getDataInt("player_id")))
skill = tonumber(result:getDataInt("value"))
else
name = result:getDataString("name")
if dbSkill == 6 then
skill = tonumber(result:getDataInt("level"))
else
skill = tonumber(result:getDataInt("maglevel"))
end
end
if name ~= nil and skill ~= nil then
resultStr = resultStr .. "\n"..name..": "..skill
end
until not(result:next())
result:free()
else
resultStr = "Error consulting database."
end
doPlayerPopupFYI(cid, "Top 10 list for "..paramSkills[dbSkill][3]..".\n" .. resultStr)
return true
end
thank you in advance