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

[Help] Lua Script Error for NPC's

tanii

Empire-war.com
Joined
Jan 16, 2015
Messages
383
Solutions
1
Reaction score
12
Hello Otlanders i got this error on npc script how i can solv?
0.3.6 8.6
Error is:

PHP:
[23/06/2015 15:11:18] [Error - Npc interface]
[23/06/2015 15:11:18] data/npc/scripts/darkskull.lua:onCreatureSay
[23/06/2015 15:11:18] Description:
[23/06/2015 15:11:18] data/npc/scripts/darkskull.lua:19: attempt to perform arithmetic on field '?' (a nil value)
[23/06/2015 15:11:18] stack traceback:
[23/06/2015 15:11:18]    data/npc/scripts/darkskull.lua:19: in function 'callback'
[23/06/2015 15:11:18]    data/npc/lib/npcsystem/npchandler.lua:390: in function 'onCreatureSay'
[23/06/2015 15:11:18]    data/npc/scripts/darkskull.lua:8: in function <data/npc/scripts/darkskull.lua:8>

Script

PHP:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end

function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end

local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

local erexo, sthl, sfbp = {10,50,100}, 59349, 24321
local killValue = erexo[sthl] - getPlayerStorageValue(cid, 29303)
if(msgcontains(msg, 'mission')) then
if getPlayerStorageValue(cid, sfbp) < 1 then
for i = 1, #erexo do
if getPlayerStorageValue(cid, sthl) < 1 then
setPlayerStorageValue(cid, sthl, 1)
end

if getPlayerStorageValue(cid, sthl) == i then
setPlayerStorageValue(cid, sfbp, 1)
setPlayerStorageValue(cid, 29303, 0)
selfSay('Lets see, you want a mission? Oke, kill ' .. erexo .. ' players for me', cid)
talkState[talkUser] = 0
return true
end
selfSay('I dont have more missions for you.', cid)
talkState[talkUser] = 0
end

else
selfSay('You did not complete my last mission? Go and kill ' .. killValue .. ' players more', cid)
talkState[talkUser] = 0
end
end

return true
end



npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())
 
see it:

local erexo, sthl, sfbp = {10,50,100}, 59349, 24321
local killValue = erexo[sthl] - getPlayerStorageValue(cid, 29303)

=

local killValue = erexo[{10,50,100}] - getPlayerStorageValue(cid, 29303)


verification Wrong

remake code please
 
i tested and still error! Help me pls

[23/06/2015 15:52:45] [Error - Npc interface]
[23/06/2015 15:52:45] data/npc/scripts/darkskull.lua:eek:nCreatureSay
[23/06/2015 15:52:45] Description:
[23/06/2015 15:52:45] data/npc/scripts/darkskull.lua:19: attempt to index global 'erexo' (a nil value)
[23/06/2015 15:52:45] stack traceback:
[23/06/2015 15:52:45] data/npc/scripts/darkskull.lua:19: in function 'callback'
[23/06/2015 15:52:45] data/npc/lib/npcsystem/npchandler.lua:390: in function 'onCreatureSay'
[23/06/2015 15:52:45] data/npc/scripts/darkskull.lua:8: in function <data/npc/scripts/darkskull.lua:8>

see it:

local erexo, sthl, sfbp = {10,50,100}, 59349, 24321
local killValue = erexo[sthl] - getPlayerStorageValue(cid, 29303)

=

local killValue = erexo[{10,50,100}] - getPlayerStorageValue(cid, 29303)


verification Wrong

remake code please
can u help me pls if u can?
 
Last edited by a moderator:
in other words,

local killValue = nil - storagevalue

you only got erexo[1], erexo[2] and erexo[3]

but what you are trying to get is: erexo[59349]

the scripit not working when i say mission i got that erros so i cant chose mission
 
Last edited:
this is still buggy, but at least should somewhat work.

Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end

function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end

local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

local erexo, sthl, sfbp = {10,50,100}, 59349, 24321
if(msgcontains(msg, 'mission')) then
if getPlayerStorageValue(cid, sfbp) < 1 then
for i = 1, #erexo do
if getPlayerStorageValue(cid, sthl) < 1 then
setPlayerStorageValue(cid, sthl, 1)
end

if getPlayerStorageValue(cid, sthl) == i then
setPlayerStorageValue(cid, sfbp, 1)
setPlayerStorageValue(cid, 29303, 0)
selfSay('Lets see, you want a mission? Oke, kill ' .. erexo[i] .. ' players for me', cid)
talkState[talkUser] = 0
return true
end
selfSay('I dont have more missions for you.', cid)
talkState[talkUser] = 0
end

else
local killValue = erexo[i] - getPlayerStorageValue(cid, 29303)
selfSay('You did not complete my last mission? Go and kill ' .. killValue .. ' players more', cid)
talkState[talkUser] = 0
end
end

return true
end



npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())
 
this is still buggy, but at least should somewhat work.

Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end

function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end

local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

local erexo, sthl, sfbp = {10,50,100}, 59349, 24321
if(msgcontains(msg, 'mission')) then
if getPlayerStorageValue(cid, sfbp) < 1 then
for i = 1, #erexo do
if getPlayerStorageValue(cid, sthl) < 1 then
setPlayerStorageValue(cid, sthl, 1)
end

if getPlayerStorageValue(cid, sthl) == i then
setPlayerStorageValue(cid, sfbp, 1)
setPlayerStorageValue(cid, 29303, 0)
selfSay('Lets see, you want a mission? Oke, kill ' .. erexo[i] .. ' players for me', cid)
talkState[talkUser] = 0
return true
end
selfSay('I dont have more missions for you.', cid)
talkState[talkUser] = 0
end

else
local killValue = erexo[i] - getPlayerStorageValue(cid, 29303)
selfSay('You did not complete my last mission? Go and kill ' .. killValue .. ' players more', cid)
talkState[talkUser] = 0
end
end

return true
end



npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

Bro can u make any script like this funtions for 8.6 and wihout bugs pls
 
Back
Top