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

luaGetPlayerNameByGUID(). Player not found

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.lua:eek:nSay

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
 
Lua:
local ranks = {
['fist'] = {0},
['club'] = {1},
['sword'] = {2},
['axe'] = {3},
['distance'] = {4},
['shield'] = {5},
['fish'] = {6},
['magic'] = {7},
['level'] = {8},
}

function onSay(cid, words, param)
         local msg = string.lower(param)
         if ranks[msg] ~= nil then
            str = getHighscoreString((ranks[msg][1]))
         else
            str = getHighscoreString((8))
         end
         doShowTextDialog(cid, 6500, str)
         return TRUE
end

DIE
 
Back
Top