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

Lua Npc

Jamaika

New Member
Joined
Aug 20, 2009
Messages
7
Reaction score
0
I have a problem with my npc.
I can become the item unlimited..
What i must to change when i would like become it only ones?

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,'out') then
        selfSay('Of course, the world is dangerous. I have a gift for you.', cid)
        doPlayerAddItem(cid,8704)
        getPlayerStorageValue(cid,48990,1)
	    doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have become a small potion!")
	
    elseif getPlayerStorageValue(cid,48990) == 1 then
         selfSay("You already have become the gift")
	end

    
		 
		 
    
		
		
end		
npcHandler:setCallback(CALLBACK_ONTHINK, thinkCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
LUA:
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 not npcHandler:isFocused(cid) then
		return false
	elseif msgcontains(msg,'out') then
		if getPlayerStorageValue(cid, 48990) == 1 then
			selfSay('You already have received the gift.')
		else
			selfSay('Of course, the world is dangerous. I have a gift for you.', cid)
			doPlayerAddItem(cid, 8704, 1)
			getPlayerStorageValue(cid, 48990, 1)
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You have received a small potion!')
		end
	end
	return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Back
Top