Pomocy Potrzebuje Skrypta!

Dark Magican

Senior User
Zarejestrowany
Dołączył
Kwiecień 13, 2009
Posty
677
Liczba reakcji
41
Ot?? potrzebuje skrypta na npc kt?ry mia? by sprzedawa? Klucz.
O podanym "aid".

Musi by? pod tibie 8.5.
On ma pisa? tak:

GRACZ(Hi)
NPC (Witam.Sprzedaje Klucz Ktory Jest Potrzebny Do Wykonania Questa(klucz)
Gracz(Klucz)
NPC(Czy napewno chcesz kupic klucz za "xxx gp" ?)
Gracz(Tak)
NPC(Prosze Oto Klucz.Zapraszam Ponownie)
Gracz(Bye)
Npc(Dowidzenia!)
Npc(Nastepny Prosze)

I to wszystko na id klucza prosz? wpisa? "9999" i na aid r?wnie? to samo...

Z g?ry thx!

PS. (Repucik Poleic)
 
Odp: Pomocy Potrzebuje Skrypta!

Witam. Huhu..! Troch? si? nam?czy?em ale jest :)

Data/NPC/Scripts/klucz.lua
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

local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)

shopModule:addBuyableItem({'Key'}, XXXX, 1, 'Keys')  -- Tam gdzie XXX wpisz ID Klucza!


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, 'Hi')
			if(getPlayerStorageValue(cid, 30002) == -1) then
				selfSay('Witam. ' .. creatureGetName(cid) .. 'Sprzedaje Klucz Ktory Jest Potrzebny Do Wykonania Questa') 
				talkState[talkUser] = 1
			end
	elseif(msgcontains(msg, 'Klucz')) then
		if(talkState[talkUser] == 1) then
			doPlayerAddItem(cid, XXXX, 1)  -- ID Klucza
			selfSay('Czy napewno chcesz kupic klucz za "xxx gp" ?', cid)
			setPlayerStorageValue(cid, 30002, 1)
		end
	elseif(msgcontains(msg, 'Tak')) then
		if(talkState[talkUser] == 1) then
			selfSay('Prosze Oto Klucz.Zapraszam Ponownie', cid)
		end
	elseif(msgcontains(msg, 'Bye')) then
		if(talkState[talkUser] == 1) then
			selfSay('Dowidzenia!', cid)
			selfSay('Nastepny Prosze!', cid)
		end

	return true
end

Data/NPC/Dziadzia Klucz.xml
PHP:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Dziadzia Klucz" script="data/npc/scripts/klucz.lua" walkinterval="2000" floorchange="0">
	<health now="100" max="100"/>
<look type="133" head="114" body="119" legs="132" feet="114" addons="0"/>
</npc>

My?l?, ?e pomog?em

Pozdrawiam. :)
 
Ostatnia edycja:
Odp: Pomocy Potrzebuje Skrypta!

Poprawi?em skrypt, kt?ry da? kolega wy?ej (by? ?le zrobiony). Ten powinien dzia?a?:
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

local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)

shopModule:addBuyableItem({'Key'}, XXXX, 1, 'Keys')  -- Tam gdzie XXX wpisz ID Klucza!


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, 'Hi')
            if(getPlayerStorageValue(cid, 30002) == -1) then
                selfSay('Witam. ' .. creatureGetName(cid) .. 'Sprzedaje Klucz Ktory Jest Potrzebny Do Wykonania Questa') 
                talkState[talkUser] = 1
            end
    elseif(msgcontains(msg, 'klucz') or msgcontains(msg, 'key')) then
        talkState[talkUser] = 2
            
            selfSay('Czy napewno chcesz kupic klucz za "xxx gp" ?', cid)

        
    elseif(msgcontains(msg, 'yes')) then
        if(talkState[talkUser] == 2) then
klucz = doPlayerAddItem(cid,9999, 1)  -- ID Klucza
doSetItemActionId(klucz.uid, 9999) -- 9999 to actionid ktore nada kluczowi
talkState[talkUser] = 1
            selfSay('Prosze Oto Klucz.Zapraszam Ponownie', cid)
        end
    elseif(msgcontains(msg, 'Bye')) then
        if(talkState[talkUser] == 1) then
            selfSay('Dowidzenia!', cid)
            selfSay('Nastepny Prosze!', cid)
        end

    return true
end
 
Back
Do góry