• 01-04.05.2026 - DOUBLE EXP / SKILL EVENT!

NPC Lottery Ticket

Status
Zamknięty.

Szumek

Advanced User
Zarejestrowany
Dołączył
Luty 26, 2009
Posty
212
Liczba reakcji
20
<npc name="Sandra" script="data/npc/scripts/vials2.lua" walkinterval="2000" floorchange="0" access="5" level="1" maglevel="1">
<health now="100" max="100"/>
<look type="140" head="57" body="59" legs="40" feet="76" addons="0"/>
<parameters>
</parameters>
</npc>

Skrypty o nazwie vials2:
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
addon_need_premium = 'Sorry, you need a premium account to get addons.', cid
addon_have_already = 'Sorry, you already have this addon.', cid
addon_have_not_items = 'Sorry, you don\'t have these items.', cid
addon_give = 'Here you are.', cid
player_gold = getPlayerItemCount(cid,2148)
player_plat = getPlayerItemCount(cid,2152)*100
player_crys = getPlayerItemCount(cid,2160)*10000
player_money = player_gold + player_plat + player_crys
if msgcontains(msg, 'help') then
selfSay('You can here change items{empty great potion flask}, {empty strong potion flask}, {empty potion flask}.?', cid)
elseif msgcontains(msg, 'empty great potion flask') then
if getPlayerItemCount(cid,7635) >= 100 then
selfSay('Did you bring me the 100 empty great potion flask ?', cid)
talk_state = 1
else
selfSay('I need a 100 empty great potion flask, to give you lottery ticket. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 1 then
talk_state = 0
if getPlayerItemCount(cid,7635) >= 100 then
if doPlayerRemoveItem(cid,7635, 100) == TRUE then
doPlayerAddItem(cid, 5957, 1)
selfSay('Here u are.', cid)
end
else
selfSay(havent_item)
end
elseif msgcontains(msg, 'empty strong potion flask') then
if getPlayerItemCount(cid,2393) >=100 then
selfSay('Did you bring me the 100 empty strong potion flask ?', cid)
talk_state = 2
else
selfSay('I need a 100 empty strong potion flask to give you the lottery ticket. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 2 then
talk_state = 0
if getPlayerItemCount(cid,7634) >= 100 then
if doPlayerRemoveItem(cid,7634,100) == 100 then
selfSay(addon_give)
doPlayerAddItem(cid,5947,1)
end
else
selfSay(havent_item)
end
elseif msgcontains(msg, 'empty potion flask') then
if getPlayerItemCount(cid,7636) >= 100 then
selfSay('Did you bring me 100 empty potion flask ?', cid)
talk_state = 3
else
selfSay('I need empty potion flask, to give you the lottery ticket. Come back when you have them.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 3 then
talk_state = 0
if getPlayerItemCount(cid,7636) >= 100 then
if doPlayerRemoveItem(cid,7636,100) == 100 then
doPlayerAddItem(cid,5947,1)
selfSay('Here u are.', cid)
end
else
selfSay(havent_item)
end

elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) then
selfSay('Ok than.')
talk_state = 0
end
-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())


Wymieniamy poszczeg?lne potiony :
empty strong potion flask
empty potion flask
empty great potion flask
100 na lottery ticket

Lottery Ticket : http://tibia.net.pl/actions/136131-lottery-ticket.html#post433365

Je?li pomog?em mo?esz da? reputa ale nie musisz ;) Pozdro
 
Odp: NPC Lottery Ticket

ten npc nie dzia?a nie reaguje nawet na hi:down:
 
Odp: NPC Lottery Ticket

NPC nie chodzi tyle Ci powiem musisz nowego wstawi?.

//reklama usuni?ta
 
Ostatnio edytowane przez moderatora:
Odp: NPC Lottery Ticket

mo?e spr?buj ten skrypt
skrypt na kupowaniu potwora. Dokladniej mowiac cos jak utevo res tylko ,ze za kase. I nawed knight moze kupic owego potworka. Wystarczy nacisnac na dzwignie W tym przypadku ELF!
Skrypt dziala nastepujaco gdy jakis gracz nacisnie na dzwignie I bedzie chcial przyzwac potworka to pierwszy raz kupi go za darmo aby uzyskac taki efekt uzylem StorageValue . Gdy ten sam gracz bedzie chcial drugi raz kupic potworka to bedzie juz musial zaplacic . Gdy ma malo pieniedzy (NoCost) - minimalna cena) I mu starczy to stworzy sie dla niego potworek o zmniejszonym zyciu (doCreatureAddHealth) np. -80). Gdy gracz bedzie chcial kupic stworka z pelnym zyciem bedzie musial zabulic wiecej (Cost)
Musze uprzedzic jednak ze niektore potworki sluchaja sie gracza gdy maj? zmniejszone hp lub wcale sie nie sluchaj? :/
(np.slime,minotaur,hero,orc shaman,)
Przynajmniej na moim silniku:
The Forgotten Server - Version 0.2 (Mystic Spirit).
A wiec zaczynamy:
Wchodzimy w data/actions/scripts I tworzymy plik o nazwie potworek.lua Do niego wklejamy:

-------- convince creature to Player 100% by nikolov
function onUse(cid, item, frompos, item2, topos)
local Cost = 800 --------- koszt potworka normalnego
local NoCost = 250 -------- koszt potworka o zmniejszonym hp
queststatus = getPlayerStorageValue(cid,9712)
if queststatus == -1 then
pos = getPlayerPosition(cid)
topos = {x=pos.x+3 , y=pos.y , z=pos.z}
local elf = doSummonCreature("Elf",topos)
doConvinceCreature(cid,elf)
setPlayerStorageValue(cid,9712,1)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "For next monsters you must to pay .")
else
if queststatus == 1 then
if doPlayerRemoveMoney(cid, Cost) == 1 then
pos = getPlayerPosition(cid)
topos = {x=pos.x , y=pos.y+3 , z=pos.z}
local elf = doSummonCreature("Elf",topos)
doConvinceCreature(cid,elf)
else
doPlayerSendCancel(cid, "Sorry ,but you must pay 800 gp for fine summon.")
if doPlayerRemoveMoney(cid, NoCost) == 1 then
pos = getPlayerPosition(cid)
topos = {x=pos.x , y=pos.y+3 , z=pos.z}
local elf2 = doSummonCreature("Elf",topos)
doCreatureAddHealth(elf2, -80)
doConvinceCreature(cid,elf2)
return 1
end
end
end
end
end

Teraz wchodzimy w data/movements/movements.xml i dodajemy linijki:
<action actionid="4560" script="potworek.lua" />
Nast?pnie w map edytorze ustawcie na wybrana rzecz actionid 4560
Proponuje dzwignie o id 1945 ale to wasz wybor :P
-80 ----- ile zabierze potworkowi zycia w razie posiadania mniejszej ilosci pieniedzy (NoCost)
NoCost ------- minimalna cena potworka ,gdy gracz nie ma pieniedzy (Cost) to ?eby wogle przyzwac potworka potrzebna jest ta ilosc pieniedzy – potworek b?dzie o zmniejszonym hp -80
Elf ---- Nazwa potworka
Cost ---- cena potworka
{x=pos.x , y=pos.y+3 , z=pos.z} ------ pozycja potworka
 
Odp: NPC Lottery Ticket

NPC Sandra dzia?a.
Nadawca postu powinien wy??czy? emotki w tre?ci posta.
Wielkie dzi?ki, pozdro.
 
Odp: NPC Lottery Ticket

A mo?e naprawicie tego npc , ten jest bardzo dobry :

Kod:
local keywordHandler = KeywordHandler:new()   
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
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
-- OTServ event handling functions end

function creatureSayCallback(cid, type, msg)
	-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
	if(npcHandler.focus ~= cid) then
		return false
	end

		player_gold = getPlayerItemCount(cid,2148)
		player_plat = getPlayerItemCount(cid,2152)*100
		player_crys = getPlayerItemCount(cid,2160)*10000
		player_money = player_gold + player_plat + player_crys

		if msgcontains(msg, 'job') or msgcontains(msg, 'help') then
			selfSay('I can give you a "lottery ticket" for empty vials.')
------------------------------------------------ addon ------------------------------------------------
		elseif msgcontains(msg, 'lottery ticket') then
			if isPremium(cid) then
			selfSay('Do you want to exchange great or divine empty potions?')
			talk_state = 1
				elseif msgcontains(msg, 'great') and talk_state == 1 then	
					if getPlayerItemCount(cid,7635) >= 50 then
						selfSay('Did you bring me 50 empty great potions for a lottery ticket?')
						talk_state = 2
					else
						selfSay('I need 50 empty great potions, to give you the lottery ticket. Come back when you have them.')
						talk_state = 0
					end
				elseif msgcontains(msg, 'divine') and talk_state == 1 then
					if getPlayerItemCount(cid, 7634) >= 200 then
						selfSay('Did you bring me 200 empty divine potions for a lottery ticket?')
						talk_state = 3
					else
						selfSay('I need 200 empty great potions, to give you the lottery ticket. Come back when you have them.')
						talk_state = 0
					end
				else 
					selfSay('Ok, then.')
					talk_state = 0
				end
			else
				selfSay('I will deal only with premium characters.')
				talk_state = 0
			end
------------------------------------------------ confirm yes ------------------------------------------------
		elseif msgcontains(msg, 'yes') and talk_state == 2 then
			talk_state = 0
			if getPlayerItemCount(cid,7635) >= 200 then
					if doPlayerRemoveItem(cid,2006,200) then
                    	doPlayerAddItem(cid,5957,1)
					end
			end
		elseif msgcontains(msg, 'yes') and talk_state == 3 then
			talk_state = 0
			if getPlayerItemCount(cid,7634) >= 200 then
					if doPlayerRemoveItem(cid,7634,200) then
                    	doPlayerAddItem(cid,5957,1)
					end
			end
------------------------------------------------ confirm no ------------------------------------------------
		elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 34) then
			selfSay('Ok than.')
			talk_state = 0
		end
	-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Status
Zamknięty.
Back
Do góry