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

Npc problem, jak możecie to pomóżcie :)

Verdis

Ciekawy świata.
Joined
May 28, 2012
Messages
394
Reaction score
9
Location
Poland
Jeden ziomek pomógł mi zrobić to:
Lecz trzeba dodać taką funkcję, że odpowiedz "tak" lub "nie" można napisać dopiero bo napisaniu słowa "event" i dopieto np."tak" a nie od razu spamować "tak"
Macie czas?
To pomóżcie :)

PHP:
-- ## EVENT NPC --
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 = getPlayerStorageValue(cid,5554)
local pos = {x=177,y =46,z=7}
if msgcontains(msg,'event') then
npcHandler:say('Do wejscia potrzeba 30 klow, posiadasz je?',cid)
talkState[talkUser] = 1
setPlayerStorageValue(cid,5554,1)
end
if msgcontains(msg,'nie') or msgcontains(msg,'nie') then
npcHandler:say('Nie masz smoczych klow!',cid)
end
if msgcontains(msg,'tak') or msgcontains(msg,'yes') and storage == 1 and talkState[talkUser] == 1 then
if doPlayerRemoveItem(cid,8614,40) then
npcHandler:say('Zostales przeniesiony na event!',cid)
setPlayerStorageValue(cid,5554,2)
doTeleportThing(cid,pos)
doSendMagicEffect(pos,CONST_ME_TELEPORT)
else
npcHandler:say('Wybacz nie przeniose Cie za darmo!', cid)
end
end
talkState[talkUser] = 2
return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
 
Gdy dodam to: if msgcontains(msg, 'tak') and talkState[talkUser] == 1 then to później nie działa mi albo "yes", a jak zamienię to "no"

- - - Updated - - -

Udało mi się, lecz jak zrobić, żeby tylko raz można było tylko raz/raz dziennie napisać do tego npc? coś takiego; if getPlayerStorageValue(cid, 35700) == 1 then ?
 
tak i potem np. możesz zrobić globalevent onStartup, żeby czyściło bazę danych tzn w bazie danych znalazło wszystkich tych, którzy mają storage 35700 i jeśli mają value == 1 to zmieni im na 0 lub na -1 :D

albo zrobić ten storage jako exhausted :D
 
getPlayerStorageValue dziala nie raz dziennie tylko raz na dana postać. Tutaj musisz uzyć getGlobalStorageValue
 
Nie działa ;/
PHP:
-- ## EVENT NPC -- 
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 = getPlayerStorageValue(cid,5554) 
local pos = {x=177,y =46,z=7} 
 if msgcontains(msg, 'event') then
           npcHandler:say('Do wejscia potrzeba 30 klow, posiadasz je?', cid)
            talk_state = 2
        elseif msgcontains(msg, 'tak') and talk_state == 2 then
		if doPlayerRemoveItem(cid,8614,40) then 
            if getGlobalStorageValue(cid, 35700) == -1 then
                npcHandler:say('Zostales przeniesiony na event!', cid)
				setGlobalStorageValue(cid, 35700, 2)
				doTeleportThing(cid,pos) 
				doSendMagicEffect(pos,CONST_ME_TELEPORT)
                talk_state = 0
				end
			
            else
                npcHandler:say('Posiadasz za malo klow!', cid)
                talk_state = 0
            end
        elseif msgcontains(msg, 'nie') and (talk_state >= 1 and talk_state <= 3) then
            npcHandler:say('Wybacz nie przeniose Cie za darmo!', cid)
            talk_state = 0
        end

    return true
end


npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())

Ta funkcja if getGlobalStorageValue wogóle mi nie działa ;/
 
Last edited:
Nie działa ;/
PHP:
-- ## EVENT NPC -- 
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 = getPlayerStorageValue(cid,5554) 
local pos = {x=177,y =46,z=7} 
 if msgcontains(msg, 'event') then
           npcHandler:say('Do wejscia potrzeba 30 klow, posiadasz je?', cid)
            talk_state = 2
        elseif msgcontains(msg, 'tak') and talk_state == 2 then
		if doPlayerRemoveItem(cid,8614,40) then 
            if getGlobalStorageValue(cid, 35700) == -1 then
                npcHandler:say('Zostales przeniesiony na event!', cid)
				setGlobalStorageValue(cid, 35700, 2)
				doTeleportThing(cid,pos) 
				doSendMagicEffect(pos,CONST_ME_TELEPORT)
                talk_state = 0
				end
			
            else
                npcHandler:say('Posiadasz za malo klow!', cid)
                talk_state = 0
            end
        elseif msgcontains(msg, 'nie') and (talk_state >= 1 and talk_state <= 3) then
            npcHandler:say('Wybacz nie przeniose Cie za darmo!', cid)
            talk_state = 0
        end

    return true
end


npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())

Ta funkcja if getGlobalStorageValue wogóle mi nie działa ;/

Jaki błąd
 
Przerobiłem i działa z cidem też, ale np jak zrobić, że jak np nie ma gracz danego itemku a pisze "tak" to jest wiadomość zwrotna?


PHP:
-- ## EVENT NPC -- 
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 = setGlobalStorageValue(cid, 2000)
local pos = {x=177,y =46,z=7} 
 if msgcontains(msg, 'event') then
           npcHandler:say('Do wejscia potrzeba 30 klow, posiadasz je?', cid)
            talk_state = 2
        elseif msgcontains(msg, 'tak') and talk_state == 2 then
            if getGlobalStorageValue(cid, 2000) == -1 then
				if doPlayerRemoveItem(cid,8614,40) then
                npcHandler:say('Zostales przeniesiony na event!', cid)
				setGlobalStorageValue(cid, 2000, 1)
				doTeleportThing(cid,pos) 
				doSendMagicEffect(pos,CONST_ME_TELEPORT)
                talk_state = 0
				end
            else
                npcHandler:say('Jednak wykonales dzis juz ten event!', cid)
                talk_state = 0
            end
			
			
        elseif msgcontains(msg, 'nie') and (talk_state >= 1 and talk_state <= 3) then
            npcHandler:say('Wybacz nie przeniose Cie za darmo!', cid)
            talk_state = 0
        end

    return true
end


npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
 
kurde usuń te city z globalstorage, nie rozumiesz, że cid jest niepotrzebny? widać jakoś funkcja działa, ale nie jest to potrzebne to wywal
LUA:
 if getPlayerItemCount(cid,8614) >= 40 then then
                doPlayerRemoveItem(cid,8614,40
                npcHandler:say('Zostales przeniesiony na event!', cid)
                setGlobalStorageValue(cid, 2000, 1)
                doTeleportThing(cid,pos) 
                doSendMagicEffect(pos,CONST_ME_TELEPORT)
                talk_state = 0
else
       npcHandler:say('nie masz itemow wystarczajaco duzo, wiec wyjazd', cid)
end
 
Back
Top