waqmaz
Member
- Joined
- Jun 17, 2015
- Messages
- 203
- Reaction score
- 11
[15/08/2016 17:45:39] [Error - Npc interface]
[15/08/2016 17:45:39] data/npc/scripts/bank.luanCreatureSay
[15/08/2016 17:45:39] Description:
[15/08/2016 17:45:39] data/npc/lib/npc.lua:54: attempt to index local 'keyword' (a number value)
[15/08/2016 17:45:39] stack traceback:
[15/08/2016 17:45:39] data/npc/lib/npc.lua:54: in function 'msgcontains'
[15/08/2016 17:45:39] data/npc/scripts/bankerrothschild.lua:135: in function 'callback'
[15/08/2016 17:45:39] data/npc/lib/npcsystem/npchandler.lua:390: in function 'onCreatureSay'
[15/08/2016 17:45:39] data/npc/scripts/bankerrothschild.lua:52: in function <data/npc/scripts/bank.lua:52>
Why this code throws the error above? The error appears instead "
msg..''does not exist'" only when the code can't find the player.
Code:
if msgcontains(msg, selectPlayerName(msg)) then
if getPlayerGUIDByName(selectPlayerName(msg)) ~= 0 then
selfSay('Nick exists: '..msg, cid)
else
selfSay(msg..' does not exist.', cid)
end
This is a function i use:
Code:
function selectPlayerName(name)
local result = db.getResult("SELECT `name` FROM `players` WHERE `name` = "..db.escapeString(name))
if (result:getID() ~= -1) then
local return_name = result:getDataString('name')
result:free()
return return_name
end
return 0
end