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

Doplayer add item doesnt work :/

Johanz

New Member
Joined
Dec 31, 2008
Messages
188
Reaction score
1
Using the Marina npc so i can get some silk yarns, she only takes my giant spider silk and gives nothing back in return. what might be wrong? Had doPlayerAddItem before, didn't work either :S
Code:
local talk_state = 0

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

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 msgcontains(msg, 'silk yarn') then
              if getPlayerItemCount(cid,5879) >= 10 then
                    if doPlayerRemoveItem(cid,5879,10) == 1 then
                              selfSay('Ew... gooey... there you go. .')
                              PlayerAddItem(cid,5886,1)
                    end
              else
                    selfSay('Ew... gooey... you dont have required items. ')
                    talk_state = 0
              end
     elseif msgcontains(msg, 'no') then
              selfSay('Ok.. Good bye then!!')
              talk_state = 0
     end

return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Edit:
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

if(msgcontains(msg, 'silk yarn') then
if getPlayerItemCount(cid,5879) >= 10 then
if doPlayerRemoveItem(cid,5879,10) == 1 then
selfSay('Ew... gooey... there you go. .')
doPlayerAddItem(cid,5886,1)
end
else
selfSay('Ew... gooey... you dont have required items. ')
talk_state = 0
end
elseif msgcontains(msg, 'no') then
selfSay('Ok.. Good bye then!!')
talk_state = 0
end

return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Maybe now? if not im clueless
 
Last edited:
Edit:
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


if msgcontains(msg, 'silk yarn') then
if getPlayerItemCount(cid,5879) >= 10 then
if doPlayerRemoveItem(cid,5879,10) == 1 then
selfSay('Ew... gooey... there you go. .')
doPlayerAddItem(cid,5886,1)
end
else
selfSay('Ew... gooey... you dont have required items. ')
talk_state = 0
end
elseif msgcontains(msg, 'no') then
selfSay('Ok.. Good bye then!!')
talk_state = 0
end

return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
should be working now

Wont work :/ here's my console error.

buggmarina.jpg
 
Back
Top