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

Solved NPC Error

Status
Not open for further replies.

azzkaban

Monster Maker
Joined
Feb 23, 2010
Messages
1,101
Reaction score
194
Location
Iquique Chile
Error:

[17/8/2013 11:29:50] [Error - NpcScript Interface]
[17/8/2013 11:29:51] data/npc/scripts/Baiak NPC/Mercenaryold mission.lua:eek:nCreatureSay
[17/8/2013 11:29:51] Description:
[17/8/2013 11:29:51] data/npc/scripts/Baiak NPC/Mercenaryold mission.lua:28: attempt to call global 'doPlayeraddItem' (a nil value)
[17/8/2013 11:29:51] stack traceback:
[17/8/2013 11:29:51] data/npc/scripts/Baiak NPC/Mercenaryold mission.lua:28: in function 'callback'
[17/8/2013 11:29:51] data/npc/lib/npcsystem/npchandler.lua:456: in function 'onCreatureSay'
[17/8/2013 11:29:51] data/npc/scripts/Baiak NPC/Mercenaryold mission.lua:7: in function <data/npc/scripts/Baiak NPC/Mercenaryold mission.lua:7>



Script:
Lua:
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
if(msgcontains(msg, 'trabajo')) then
selfSay('Muy bien! Ya quieres comenzar la {primera} mision?', cid)
end
---------------------------------------------------------
if(msgcontains(msg, 'primera')) then
selfSay('Muy bien, traeme 4 {Golden Armor}.', cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, 'golden armor') and talkState[talkUser] == 1) then
if (getPlayerStorageValue(cid,100) > 0) then
selfSay('Felicitaciones! Completaste la mision!', cid)
else
if(doPlayerRemoveItem(cid, 2466, 4) == TRUE) then
setPlayerStorageValue(cid,100,1)
doPlayerAddExperience(cid,10000)
doPlayeraddItem(cid, 2470, 1)
selfSay('Muy bien! Tu inicias la {segunda} mision.. (Tu recibes 10000 puntos de experiencia y una Golden Legs)', cid)
else
selfSay('Tu necesitas mas items.', cid)
end
end
return true
end
---------------------------------------------------------
if(msgcontains(msg, 'segunda')) then
selfSay('Ahora traememe 20 {Demonrage Sword}.', cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, 'Demonrage Sword') and talkState[talkUser] == 1) then
if (getPlayerStorageValue(cid,101) > 0) then
selfSay('Tu completaste la mision, veo que no debo seguir subestimandote.', cid)
else
if(doPlayerRemoveItem(cid, 7382, 20) == TRUE) then
setPlayerStorageValue(cid,101,1)
doPlayerAddExperience(cid,20000)
doPlayeraddItem(cid, 8926, 1)
selfSay('Tu inicias la {tercera} mision... (Tu recibes 20000 puntos de experiencia y un Demonwing Axe)', cid)
else
selfSay('Tu necesitas mas items.', cid)
end
end
return true
end
---------------------------------------------------------
if(msgcontains(msg, 'tercera')) then
selfSay('Veo que eres muy poderoso y por esa razon te pedire que me traigas 2 {orshabaal brain}."', cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, 'orshabaal brain') and talkState[talkUser] == 1) then
if (getPlayerStorageValue(cid,102) > 0) then
selfSay('Lo completaste!', cid)
else
if(doPlayerRemoveItem(cid, 5808, 2) == TRUE) then
setPlayerStorageValue(cid,102,1)
doPlayerAddExperience(cid,40000)
doPlayeraddItem(cid, 7422, 1)
selfSay('Felicitaciones! Tu completaste todas las misiones, Eres un buen Mercenario. (hehe) (Tu recibes 40000 puntos de experiencia y una Jade Hammer.)', cid)
else
selfSay('Tu necesitas mas items.', cid)
end
end
return true
end


end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
The 'a' in doPlayeraddItem needs to be capitalized. So, it should be doPlayerAddItem, not doPlayeraddItem.

Lua:
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
if(msgcontains(msg, 'trabajo')) then
selfSay('Muy bien! Ya quieres comenzar la {primera} mision?', cid)
end
---------------------------------------------------------
if(msgcontains(msg, 'primera')) then
selfSay('Muy bien, traeme 4 {Golden Armor}.', cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, 'golden armor') and talkState[talkUser] == 1) then
if (getPlayerStorageValue(cid,100) > 0) then
selfSay('Felicitaciones! Completaste la mision!', cid)
else
if(doPlayerRemoveItem(cid, 2466, 4) == TRUE) then
setPlayerStorageValue(cid,100,1)
doPlayerAddExperience(cid,10000)
doPlayerAddItem(cid, 2470, 1)
selfSay('Muy bien! Tu inicias la {segunda} mision.. (Tu recibes 10000 puntos de experiencia y una Golden Legs)', cid)
else
selfSay('Tu necesitas mas items.', cid)
end
end
return true
end
---------------------------------------------------------
if(msgcontains(msg, 'segunda')) then
selfSay('Ahora traememe 20 {Demonrage Sword}.', cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, 'Demonrage Sword') and talkState[talkUser] == 1) then
if (getPlayerStorageValue(cid,101) > 0) then
selfSay('Tu completaste la mision, veo que no debo seguir subestimandote.', cid)
else
if(doPlayerRemoveItem(cid, 7382, 20) == TRUE) then
setPlayerStorageValue(cid,101,1)
doPlayerAddExperience(cid,20000)
doPlayerAddItem(cid, 8926, 1)
selfSay('Tu inicias la {tercera} mision... (Tu recibes 20000 puntos de experiencia y un Demonwing Axe)', cid)
else
selfSay('Tu necesitas mas items.', cid)
end
end
return true
end
---------------------------------------------------------
if(msgcontains(msg, 'tercera')) then
selfSay('Veo que eres muy poderoso y por esa razon te pedire que me traigas 2 {orshabaal brain}."', cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, 'orshabaal brain') and talkState[talkUser] == 1) then
if (getPlayerStorageValue(cid,102) > 0) then
selfSay('Lo completaste!', cid)
else
if(doPlayerRemoveItem(cid, 5808, 2) == TRUE) then
setPlayerStorageValue(cid,102,1)
doPlayerAddExperience(cid,40000)
doPlayerAddItem(cid, 7422, 1)
selfSay('Felicitaciones! Tu completaste todas las misiones, Eres un buen Mercenario. (hehe) (Tu recibes 40000 puntos de experiencia y una Jade Hammer.)', cid)
else
selfSay('Tu necesitas mas items.', cid)
end
end
return true
end
 
 
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Status
Not open for further replies.
Back
Top