Zmiana profesji za item.

Status
Zamknięty.

Batonek

Senior User
Zarejestrowany
Dołączył
Kwiecień 26, 2008
Posty
605
Liczba reakcji
25
Siema. Poszukuj? NPC kt?ry zmienia nam profesj?, je?eli damy mu item. Z tym ?e je?eli profesja ma id 1 - to mo?e sobie wybra? czy chce sobie zmieni? na 2, czy 3 (odpowiednie nazwy sam wprowadz? ;-)). Je?eli ma id 4 - to mo?e zmieni? na 5 lub 6, a je?eli jego profesja ma id 7 - to mo?e zmieni? na 8 lub 9.
Z g?ry dzi?ki za pomoc,
pozdrawiam.
 
Odp: Zmiana profesji za item.

Wiem, wiem, nieefektywnie napisany...
Nie testowa?em, ale s?dz? i? powinien dzia?a?.
PHP:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local voc = {}
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 s = getPlayerStorageValue(cid, storage)
        if(not npcHandler:isFocused(cid)) then
                return false
        end
        local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_PRIVATE and 0 or cid
		local voc = 6000
local ilosc = 1
local item = 2160
local storage = 5000
	if msgcontains(msg, 'promocja') then
		if getPlayerItemCount(cid, item) >= ilosc and getPlayerStorageValue(storage) == -1 then
			if getPlayerVocation(cid) == 1 then
				selfSay("Jaka chcesz otrzymac profesje?", second, cid)
				talkState[talkUser] = 1
			elseif getPlayerVocation(cid) == 4 then
				selfSay("Jaka chcesz otrzymac profesje?", second, cid)
				talkState[talkUser] = 2
			elseif getPlayerVocation(cid) == 7 then
				selfSay("Jaka chcesz otrzymac profesje?", second, cid)
				talkState[talkUser] = 3
			end
		end
	elseif msgcontains(msg, 'numer 2') then
		if talkState[talkUser] == 1 then
			doPlayerSetVocation(cid, 2)
			selfSay("Profesja numer 2", second, cid)
			doPlayerRemoveItem(cid, item, ilosc)
			setPlayerStorageValue(cid, storage, 1)
		end
	elseif msgcontains(msg, 'numer 3') then
		if talkState[talkUser] == 1 then
			doPlayerSetVocation(cid, 3)
			selfSay("Profesja numer 3", second, cid)
			doPlayerRemoveItem(cid, item, ilosc)
			setPlayerStorageValue(cid, storage, 1)
		end
	elseif msgcontains(msg, 'numer 5') then
		if talkState[talkUser] == 2 then
			doPlayerSetVocation(cid, 5)
			selfSay("Profesja numer 5", second, cid)
			doPlayerRemoveItem(cid, item, ilosc)
			setPlayerStorageValue(cid, storage, 1)
		end
	elseif msgcontains(msg, 'numer 6') then
		if talkState[talkUser] == 2 then
			doPlayerSetVocation(cid, 6)
			selfSay("Profesja numer 6", second, cid)
			doPlayerRemoveItem(cid, item, ilosc)
			setPlayerStorageValue(cid, storage, 1)
		end
	elseif msgcontains(msg, 'numer 8') then
		if talkState[talkUser] == 3 then
			doPlayerSetVocation(cid, 8)
			selfSay("Profesja numer 8", second, cid)
			doPlayerRemoveItem(cid, item, ilosc)
			setPlayerStorageValue(cid, storage, 1)
		end
	elseif msgcontains(msg, 'numer 9') then
		if talkState[talkUser] == 3 then
			doPlayerSetVocation(cid, 9)
			selfSay("Profesja numer 9", second, cid)
			doPlayerRemoveItem(cid, item, ilosc)
			setPlayerStorageValue(cid, storage, 1)
		end	
	end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Status
Zamknięty.
Back
Do góry