• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Unsafe Argument #5 NPC

Sigoles

Discord: @sigoles
Joined
Nov 20, 2015
Messages
1,209
Solutions
2
Reaction score
154
Hello, I'm having troubles with this npc, he awnser but we got error on screen
LUA:
Lua Script Error: [Npc interface]
data/npc/scripts/Grizzly Adams.lua:onCreatureSay
luaAddEvent(). Argument #5 is unsafe
stack traceback:
        [C]: in function 'addEvent'
        data/npc/lib/npcsystem/npchandler.lua:648: in function 'callback'
        data/npc/lib/npcsystem/npchandler.lua:431: in function 'onCreatureSay'
        data/npc/scripts/Grizzly Adams.lua:7: in function <data/npc/scripts/Grizzly Adams.lua:7>

Script:
hastebin

Npc handler:
hastebin

Tfs 1.3

thanks
 
Last edited by a moderator:
Solution
Okay ..
Try to remove this, thats the only addEvent you have in those 2 files you uploaded.
LUA:
       self.eventSay[focus] = addEvent(function(npcId, message, focusId)
           local npc = Npc(npcId)
           if npc == nil then
               return
           end

           local player = Player(focusId)
           if player then
               local parseInfo = {[TAG_PLAYERNAME] = player:getName(), [TAG_TIME] = getTibianTime(), [TAG_BLESSCOST] = getBlessingsCost(player:getLevel()), [TAG_PVPBLESSCOST] = getPvpBlessingCost(player:getLevel())}
               npc:say(self:parseMessage(message, parseInfo), TALKTYPE_PRIVATE_NP, false, player, npc:getPosition())
           end
       end, self.talkDelayTime * 1000, Npc().uid, message, focus)

I removed and when I say "hi" the...
There are 2 diffrences in that function compared to the one on github;
LUA:
Npc().uid
That's
LUA:
Npc():getId()
On the github repo.

Then in your script you also have this;
LUA:
local parseInfo = {[TAG_PLAYERNAME] = player:getName(), [TAG_TIME] = getTibianTime(), [TAG_BLESSCOST] = getBlessingsCost(player:getLevel()), [TAG_PVPBLESSCOST] = getPvpBlessingCost(player:getLevel())}

If that isn't used I would just download a new NPC lib from the link below and "update".


Ref; forgottenserver/npchandler.lua at master · otland/forgottenserver · GitHub
 
There are 2 diffrences in that function compared to the one on github;
LUA:
Npc().uid
That's
LUA:
Npc():getId()
On the github repo.

Then in your script you also have this;
LUA:
local parseInfo = {[TAG_PLAYERNAME] = player:getName(), [TAG_TIME] = getTibianTime(), [TAG_BLESSCOST] = getBlessingsCost(player:getLevel()), [TAG_PVPBLESSCOST] = getPvpBlessingCost(player:getLevel())}

If that isn't used I would just download a new NPC lib from the link below and "update".


Ref; forgottenserver/npchandler.lua at master · otland/forgottenserver · GitHub

thanks for reply, I updated the npchandler and still the same error:

Sqi3O9KdTMCSz2tgewYXFg.png
 
thanks for reply, I updated the npchandler and still the same error:

Sqi3O9KdTMCSz2tgewYXFg.png

Okay ..
Try to remove this, thats the only addEvent you have in those 2 files you uploaded.
LUA:
       self.eventSay[focus] = addEvent(function(npcId, message, focusId)
           local npc = Npc(npcId)
           if npc == nil then
               return
           end

           local player = Player(focusId)
           if player then
               local parseInfo = {[TAG_PLAYERNAME] = player:getName(), [TAG_TIME] = getTibianTime(), [TAG_BLESSCOST] = getBlessingsCost(player:getLevel()), [TAG_PVPBLESSCOST] = getPvpBlessingCost(player:getLevel())}
               npc:say(self:parseMessage(message, parseInfo), TALKTYPE_PRIVATE_NP, false, player, npc:getPosition())
           end
       end, self.talkDelayTime * 1000, Npc().uid, message, focus)
 
Okay ..
Try to remove this, thats the only addEvent you have in those 2 files you uploaded.
LUA:
       self.eventSay[focus] = addEvent(function(npcId, message, focusId)
           local npc = Npc(npcId)
           if npc == nil then
               return
           end

           local player = Player(focusId)
           if player then
               local parseInfo = {[TAG_PLAYERNAME] = player:getName(), [TAG_TIME] = getTibianTime(), [TAG_BLESSCOST] = getBlessingsCost(player:getLevel()), [TAG_PVPBLESSCOST] = getPvpBlessingCost(player:getLevel())}
               npc:say(self:parseMessage(message, parseInfo), TALKTYPE_PRIVATE_NP, false, player, npc:getPosition())
           end
       end, self.talkDelayTime * 1000, Npc().uid, message, focus)

I removed and when I say "hi" the npc dont awnser :eek:


The problem is not in the handler but in npc because all others are correct.

I fixed my problem, changing "player" to "cid" in the msgs, example:

LUA:
npcHandler:say("You already joined in the Paw and Fur tasks.", player)
to
LUA:
npcHandler:say("You already joined in the Paw and Fur tasks.", cid)

Thanks WibbenZ
ps. I mark the best answer in whom?
 
Last edited by a moderator:
Solution
Back
Top