What's new

Problem og?lny

Status
Not open for further replies.

Arts18

Signed...
Joined
May 7, 2009
Messages
2,888
Reaction score
231
Age
33
Og?lnie mo?na powiedzie? tak, wali si? wszystko.

Oto dialog :
Code:
17:12 Stanley: Welcome, Debil! I have been expecting you.
17:12 Debil [17691: mission
17:12 Stanley: Swietnie, plaga tych potworow zostala powstrzmana. Czas abys pomogl mi wyczyscic stajnie. Jak wiesz konie sa naprawde wrazliwe na brod, tylko to je powstrzyma przed wielkim zamieszaniem
17:12 Debil [17691: yes
17:12 Stanley: Konie beda Tobie wdzieczne. To do roboty!
17:12 Debil [17691: mission
17:12 Stanley: Na pewno?
17:12 Debil [17691: yes
17:12 Stanley: Nie wykonales zadania, wroc jak posprzatasz
17:13 Stanley: How rude!
17:14 Debil [17691: hi
17:14 Stanley: Welcome, Debil! I have been expecting you.
17:14 Debil [17691: mission

Przed wykonaniem zadania NPC dzia?a bez zarzutu, tylko w ostatnim talkState nie odpowiada na keyword no, ale to mniejsza o to, w og?le gdy wykonamy zadanie to NPC wcale nie reaguj?.

Sprz?tanie :
Code:
local aid = {2300, 2301, 2302,2303, 2304}

function onUse(cid, item, fromPosition, itemEx, toPosition)

if isInArray(aid, itemEx.actionid) and getPlayerStorageValue(cid, 4448) ==1 then
 if getCreatureStorage(cid, itemEx.actionid) ~= 1 then
  doSendMagicEffect(toPosition,3)
  if 1 == math.random(1,4) then
   doCreatureSetStorage(cid, itemEx.actionid, 1)
  end
 else
  doPlayerSendCancel(cid, "Idz czyscic kolejne miejsce, to juz jest wystarczajaco czyste")
 end
     
 for i = 2300, 2304 do
  if getCreatureStorage(cid, i) == 1 then
   setPlayerStorageValue(cid, 4449, i)
  end
 if getCreatureStorage(cid, 4449) == aid[#aid] then
  doPlayerSendCancel(cid, "Wyczysciles stajnie, wroc do stajennego i odbierz nagrode")
  setPlayerStorageValue(cid, 4448, 2)
 end
 end
end
return true
end

NPC :

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
 
--- clean ------ 
        if msgcontains(msg, 'mission') or msgcontains(msg, 'missions') then
                if getPlayerStorageValue(cid, 4448) == - 1 then
                        selfSay("Swietnie, plaga tych potworow zostala powstrzmana. Czas abys pomogl mi wyczyscic stajnie. Jak wiesz konie sa naprawde wrazliwe na brod, tylko to je powstrzyma przed wielkim zamieszaniem", cid)
                        talkState[talkUser] = 2
                elseif getPlayerStorageValue(cid, 4448) == 1 then
                        selfSay("Na pewno?", cid)
                        talkState[talkUser] = 22   
                end     
        elseif msgcontains(msg, 'yes') and talkState[talkUser] == 2 then
                selfSay("Konie beda Tobie wdzieczne. To do roboty!", cid)
                setPlayerStorageValue(cid, 4448,1 )
        elseif msgcontains(msg, 'no') and talkState[talkUser] == 2 then
           selfSay("Spadaj", cid)
           talkState[talkUser] = 1
        elseif msgcontains(msg, 'yes') and talkState[talkUser] == 22 then
                if getPlayerStorageValue(cid, 4448) == 2 then
                        selfSay("Brawo, teraz wystarczy, ze poszukasz gdzies zaginiony bicz. Pamietaj, zeby dobrze traktowac konia", cid)
                        setPlayerStorageValue(cid, 1005, 1)
                        setPlayerStorageValue(cid, 4448, 2)
                else
                        selfSay("Nie wykonales zadania, wroc jak posprzatasz", cid)
                end 
                talkState[talkUser] = 1
        elseif msgcontains(msg, 'no') and talkState[talkUser] == 22 then
                selfSay("Ech..", cid)
                talkState[talkUser] = 1
        end
        return true 
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Prosz? o pomoc.

@edit.
Keyword no przed wykonaniem zadania - actions dzia?a.
 
Joined
Jan 6, 2011
Messages
552
Reaction score
65
Odp: Problem og?lny

Npc:
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
	
	if(msgcontains(msg, 'mission')) then
		if(getPlayerStorageValue(cid, 4448) < 1) then
			selfSay('Swietnie, plaga tych potworow zostala powstrzmana. Czas abys pomogl mi wyczyscic stajnie. Jak wiesz konie sa naprawde wrazliwe na brod, tylko to je powstrzyma przed wielkim zamieszaniem', cid)
			talkState[talkUser] = 1
		elseif(getPlayerStorageValue(cid, 4448) == 1 or getPlayerStorageValue(cid, 4448) == 2) then
			selfSay('Na pewno?', cid)
			talkState[talkUser] = 2
		elseif(getPlayerStorageValue(cid, 4448) == 3) then
			selfSay('Wykonales to zadanie.', cid)
		end
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
		selfSay('Konie beda Tobie wdzieczne. To do roboty!', cid)
		setPlayerStorageValue(cid, 4448, 1)
		talkState[talkUser] = 0
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 2) then
		if(getPlayerStorageValue(cid, 4448) == 2) then
			selfSay('Brawo, teraz wystarczy, ze poszukasz gdzies zaginiony bicz. Pamietaj, zeby dobrze traktowac konia', cid)
            setPlayerStorageValue(cid, 1005, 1)
            setPlayerStorageValue(cid, 4448, 3) -- bylo 2 (?)
			talkState[talkUser] = 0
		else
			selfSay('Nie wykonales zadania, wroc jak posprzatasz!', cid)
		end
	elseif(msgcontains(msg, 'no') and (talkState[talkUser] == 2 or talkState[talkUser] == 1)) then
		selfSay('Echh...', cid)
		talkState[talkUser] = 0
	end
	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Powinno dzia?a?.
 
Last edited:

Arts18

Signed...
Joined
May 7, 2009
Messages
2,888
Reaction score
231
Age
33
Odp: Problem og?lny

Wszystko dzia?a. Zamykam :)
 
Status
Not open for further replies.
Top