• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Problem z NPC

BugaS

Donżuan
Joined
Mar 12, 2009
Messages
1,219
Reaction score
9
Location
NYC
Mam sobie takiego świątecznego skrypciolka oł je:

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)
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	--[[
	REMEMBER TO SET YOUR STORAGE AS YOURSTORAGE!
	]]--
	local storage = 6690
	if(msgcontains(msg, 'quest') or msgcontains(msg, 'jajka')) then
		if(getPlayerStorageValue(cid, storage) < 1) then
			npcHandler:say("Hey, mam dla Ciebie zadanie. Dostan sie na wyspe z Wielkanocnymi Zajacami. Przynies mi 1 tysiac zielonych jajek a otrzymasz nagrode! Znikam o polnocy, spiesz sie!", cid)
			setPlayerStorageValue(cid, storage, 1)
		elseif(getPlayerStorageValue(cid, storage) == 1) then
			npcHandler:say("Znalazles je?", cid)
			talkState[talkUser] = 1
		elseif(getPlayerStorageValue(cid, storage) == 2) then
			npcHandler:say("Sorry ale ich nie znalazles. Jestes nuub", cid)
		end
	elseif(msgcontains(msg, 'tak') and talkState[talkUser] == 1) then
		if(doRemoveItem(cid, 6544, 1000) == TRUE) then
			npcHandler:say("Dzieki! Masz ode mnie 60 punktow premium w SMS SHOPIE!", cid)
local update = db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + 60 WHERE `id`= " .. getPlayerAccountId(cid) .. "; ")
			setPlayerStorageValue(cid, storage, 2)
			talkState[talkUser] = 0
		else
			npcHandler:say("Sorry ale ich nie znalazles. Jestes nuub.", cid)
			talkState[talkUser] = 0
		end
	elseif(msgcontains(msg, 'nie') and talkState[talkUser] > 0) then
		npcHandler:say("No to nie.", cid)
		talkState[talkUser] = 0
	end
	return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
.

Niestety nie dziala jak powinien:

Code:
08:41 Wielkanocny Boss: Siema GOD Apollo, wesolych swiat! Napisz jajka.
08:41 GOD Apollo [500]: jajka
08:41 Wielkanocny Boss: Znalazles je?

A gdy je sobie zrobiłem:

Code:
08:42 Wielkanocny Boss: Znalazles je?
08:42 GOD Apollo [500]: tak
08:42 Wielkanocny Boss: Sorry ale ich nie znalazles. Jestes nuub.
 
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
	local storage = 6690

	if(msgcontains(msg, 'quest') or msgcontains(msg, 'jajka')) then
		if(getPlayerStorageValue(cid, storage) < 1) then
			npcHandler:say("Hey, mam dla Ciebie zadanie. Dostan sie na wyspe z Wielkanocnymi Zajacami. Przynies mi 1 tysiac zielonych jajek a otrzymasz nagrode! Znikam o polnocy, spiesz sie!", cid)
			setPlayerStorageValue(cid, storage, 1)
		elseif(getPlayerStorageValue(cid, storage) == 1) then
			npcHandler:say("Znalazles je?", cid)
			talkState[talkUser] = 1
		elseif(getPlayerStorageValue(cid, storage) == 2) then
			npcHandler:say("Ukonczones juz to zadanie, hih heh hoh, spierdalay jush", cid)
		elseif(msgcontains(msg, 'tak') and talkState[talkUser] == 1) then
			if(getPlayerItemCount(cid, 6544) >= 1000) then
				doPlayerRemoveItem(cid, 6544, 1000)
				setPlayerStorageValue(cid, storage, 2)
				db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + 60 WHERE `id`= " .. getPlayerAccountId(cid) .. ";")
				npcHandler:say("Dzieki! Masz ode mnie 60 punktow premium w SMS SHOPIE!", cid)
			else
				npcHandler:say("Sorry ale ich nie znalazles. Jestes nuub.", cid)
			end
			talkState[talkUser] = 0
		elseif(msgcontains(msg, 'nie') and talkState[talkUser] > 0) then
			npcHandler:say("No to nie.", cid)
			talkState[talkUser] = 0
		end
	end
	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
up
10:46 Wielkanocny Boss: Siema GOD Apollo, wesolych swiat! Napisz jajka.
10:46 GOD Apollo [500]: jajka
10:46 Wielkanocny Boss: Znalazles je?

;/
 
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)
        local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
        --[[
        REMEMBER TO SET YOUR STORAGE AS YOURSTORAGE!
        ]]--
        local storage = 6690
        if(msgcontains(msg, 'quest') or msgcontains(msg, 'jajka')) then
                if(getPlayerStorageValue(cid, storage) < 1) then
                        npcHandler:say("Hey, mam dla Ciebie zadanie. Dostan sie na wyspe z Wielkanocnymi Zajacami. Przynies mi 1 tysiac zielonych jajek a otrzymasz nagrode! Znikam o polnocy, spiesz sie!", cid)
                        setPlayerStorageValue(cid, storage, 1)
                elseif(getPlayerStorageValue(cid, storage) == 1) then
                        npcHandler:say("Znalazles je?", cid)
                        talkState[talkUser] = 1
						if(msgcontains(msg, 'tak') and talkState[talkUser] == 1) then
                if(doRemoveItem(cid, 6544, 1000) == TRUE) then
                        npcHandler:say("Dzieki! Masz ode mnie 60 punktow premium w SMS SHOPIE!", cid)
local update = db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + 60 WHERE `id`= " .. getPlayerAccountId(cid) .. "; ")
                        setPlayerStorageValue(cid, storage, 2)
                        talkState[talkUser] = 0
                else
                        npcHandler:say("Sorry ale ich nie znalazles. Jestes nuub.", cid)
                        talkState[talkUser] = 0
                end
        elseif(msgcontains(msg, 'nie') and talkState[talkUser] > 0) then
                npcHandler:say("No to nie.", cid)
                talkState[talkUser] = 0
        end
                elseif(getPlayerStorageValue(cid, storage) == 2) then
                        npcHandler:say("Juz to zrobiles, mlocie", cid)
                end
        else
        return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Nie testowalem.
Jak by wywalilo jakis blad/nie dzialalo napisz.
 
Nic nie wywala.

Chyba ze ktos ma skrypt z zajaczkiem dzialajacy to chetnie kupie
 
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)
        local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
        --[[
        REMEMBER TO SET YOUR STORAGE AS YOURSTORAGE!
        ]]--
        local storage = 6690
        if(msgcontains(msg, 'quest') or msgcontains(msg, 'jajka')) then
                if(getPlayerStorageValue(cid, storage) < 1) then
                        npcHandler:say("Hey, mam dla Ciebie zadanie. Dostan sie na wyspe z Wielkanocnymi Zajacami. Przynies mi 1 tysiac zielonych jajek a otrzymasz nagrode! Znikam o polnocy, spiesz sie!", cid)
                        setPlayerStorageValue(cid, storage, 1)
                elseif(getPlayerStorageValue(cid, storage) == 1) then
                        npcHandler:say("Znalazles je?", cid)
                        talkState[talkUser] = 1
                elseif(getPlayerStorageValue(cid, storage) == 2) then
                        npcHandler:say("Sorry ale ich nie znalazles. Jestes nuub", cid)
                end
        if(msgcontains(msg, 'tak') and talkState[talkUser] == 1) then
                if(doRemoveItem(cid, 6544, 1000) == TRUE) then
                        npcHandler:say("Dzieki! Masz ode mnie 60 punktow premium w SMS SHOPIE!", cid)
local update = db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + 60 WHERE `id`= " .. getPlayerAccountId(cid) .. "; ")
                        setPlayerStorageValue(cid, storage, 2)
                        talkState[talkUser] = 0
                else
                        npcHandler:say("Sorry ale ich nie znalazles. Jestes nuub.", cid)
                        talkState[talkUser] = 0
                end
        elseif(msgcontains(msg, 'nie') and talkState[talkUser] > 0) then
                npcHandler:say("No to nie.", cid)
                talkState[talkUser] = 0
        end
        return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Jak nie bedzie dzialac to nie mam pojecia.
Nie chce mi sie myslec ;f
 
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)
        local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
        --[[
        REMEMBER TO SET YOUR STORAGE AS YOURSTORAGE!
        ]]--
        local storage = 6690
        if(msgcontains(msg, 'quest') or msgcontains(msg, 'jajka')) then
                if(getPlayerStorageValue(cid, storage) < 1) then
                        npcHandler:say("Hey, mam dla Ciebie zadanie. Dostan sie na wyspe z Wielkanocnymi Zajacami. Przynies mi 1 tysiac zielonych jajek a otrzymasz nagrode! Znikam o polnocy, spiesz sie!", cid)
                        setPlayerStorageValue(cid, storage, 1)
                elseif(getPlayerStorageValue(cid, storage) == 1) then
                        npcHandler:say("Znalazles je?", cid)
                        if(msgcontains(msg, 'tak') and talkState[talkUser] == 1) then
                if(doRemoveItem(cid, 6544, 1000) == TRUE) then
                        npcHandler:say("Dzieki! Masz ode mnie 60 punktow premium w SMS SHOPIE!", cid)
local update = db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + 60 WHERE `id`= " .. getPlayerAccountId(cid) .. "; ")
                        setPlayerStorageValue(cid, storage, 2)
                        talkState[talkUser] = 0
                else
                        npcHandler:say("Sorry ale ich nie znalazles. Jestes nuub.", cid)
                        talkState[talkUser] = 0
                end
        elseif(msgcontains(msg, 'nie') and talkState[talkUser] > 0) then
                npcHandler:say("No to nie.", cid)
                talkState[talkUser] = 0
        end
                elseif(getPlayerStorageValue(cid, storage) == 2) then
                        npcHandler:say("Sorry ale ich nie znalazles. Jestes nuub", cid)
                end
        return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Nadazasz z moja nieudolna proba pomocy?
 
Wstaw do tego twojego skryptu printy i zobacz do którego momentu się wykonuje.
 
sprawdź czy jak dasz 100 zamiast 1k jajek to będzie tak samo, jak tak to zmień jakoś te dwa teksty żeby było widać, w którym miejscu się wypierdala warunek
 
doRemoveItem == doPlayerRemoveItem ?

Powiem szczerze że nie wiem bo zawsze do takich rzeczy używam doPlayerRemoveItem

Oczywiście chodzi chodzi o ten przypadek gdy doRemoveItem skierowany jest na cid.
 
Last edited:
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)
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	--[[
	REMEMBER TO SET YOUR STORAGE AS YOURSTORAGE!
	]]--
	local storage = 5152
	if(msgcontains(msg, 'quest') or msgcontains(msg, 'jajka')) then
		if(getPlayerStorageValue(cid, storage) < 1) then
			npcHandler:say("Hey, przynies mi {999 zielonych jajek}.", cid)
			setPlayerStorageValue(cid, storage, 1)
		elseif(getPlayerStorageValue(cid, storage) == 1) then
			npcHandler:say("Masz 999 jajek dla mnie", cid)
			talkState[talkUser] = 1
		elseif(getPlayerStorageValue(cid, storage) == 2) then
			npcHandler:say("Sorry, ale nie masz.", cid)
		end
	elseif(msgcontains(msg, 'tak') and talkState[talkUser] == 1) then
		if(doPlayerRemoveItem(cid, 6544, 999) == TRUE) then
			npcHandler:say("Thanks! Masz pkty premium {350}", cid)
local update = db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + 350 WHERE `id`= " .. getPlayerAccountId(cid) .. "; ")
			setPlayerStorageValue(cid, storage, 2)
			talkState[talkUser] = 0
		else
			npcHandler:say("Sorry, nie masz ich.", cid)
			talkState[talkUser] = 0
		end
	elseif(msgcontains(msg, 'nie') and talkState[talkUser] > 0) then
		npcHandler:say("No to nie.", cid)
		talkState[talkUser] = 0
	end
	return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Teraz tego uzylem. NPC dziala teraz tak:
21:02 Wielkanocny Boss: Siema GOD Apollo, wesolych swiat! Napisz jajka.
21:02 GOD Apollo [500]: jajka
21:02 Wielkanocny Boss: Hey, przynies mi 999 zielonych jajek.
21:02 GOD Apollo [500]: bye
21:02 Wielkanocny Boss: Good bye, GOD Apollo!
21:02 GOD Apollo [500]: hi
21:02 Wielkanocny Boss: Siema GOD Apollo, wesolych swiat! Napisz jajka.
21:02 GOD Apollo [500]: jajka
21:02 Wielkanocny Boss: Masz 999 jajek dla mnie
21:02 GOD Apollo [500]: tak
21:02 Wielkanocny Boss: Sorry, nie masz ich.

//edit

Graczom podobno działa, nie wiem dlaczego mi nie. Mam je w backpacku, może szuka tylko ich w glownym bp?
 
up

Graczom działa jak maja 999 jajek a mi nie ;s

Sprawdza glowny bp? Tak tez probowalem i nic
 
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)
        local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
        --[[
        REMEMBER TO SET YOUR STORAGE AS YOURSTORAGE!
        ]]--
        local storage = 5152
        if(msgcontains(msg, 'quest') or msgcontains(msg, 'jajka')) then
                if(getPlayerStorageValue(cid, storage) < 1) then
                        npcHandler:say("Hey, przynies mi {999 zielonych jajek}.", cid)
                        setPlayerStorageValue(cid, storage, 1)
                elseif(getPlayerStorageValue(cid, storage) == 1) then
                        npcHandler:say("Masz 999 jajek dla mnie", cid)
                        talkState[talkUser] = 1
                elseif(getPlayerStorageValue(cid, storage) == 2) then
                        npcHandler:say("Sorry, ale nie masz.", cid)
                end
        elseif(msgcontains(msg, 'tak')) then
                if(doPlayerRemoveItem(cid, 6544, 999) == TRUE) then
                        npcHandler:say("Thanks! Masz pkty premium {350}", cid)
local update = db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + 350 WHERE `id`= " .. getPlayerAccountId(cid) .. "; ")
                        setPlayerStorageValue(cid, storage, 2)
                        talkState[talkUser] = 0
                else
                        npcHandler:say("Sorry, nie masz ich.", cid)
                        talkState[talkUser] = 0
                end
        elseif(msgcontains(msg, 'nie') and talkState[talkUser] > 0) then
                npcHandler:say("No to nie.", cid)
                talkState[talkUser] = 0
        end
        return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Back
Top