Ir para conteúdo

Tutorial 3 Em 1


1877799

Posts Recomendados

Eae Galera, esse é meu primeiro Tutorial então avaliem (:

 

1º Tutorial - Criar uma Quest (De 1 , 3+ baús)

 

Quest de Apenas 1 Baú: Crie um arquivo.lua na pasta, data > actions > scripts e cole isso nele:

 

function onUse(cid, item, frompos, item2, topos)


if item.uid == X¹ then
	if getPlayerStorageValue(cid,X²) == -1 then
		doPlayerSendTextMessage(cid,22,"Voce achou X item.")
		doPlayerAddItem(cid,ID,X³)
		setPlayerStorageValue(cid,X²,1)
	else
		doPlayerSendTextMessage(cid,22,"Bau Vazio.")
	end

end
return TRUE
end

 

Vamos agora configurar o Script

 

X - Nome do item que ganhará na quest.

 

X¹ - Aconselho a botar mais de 2000 pois será o ID da Action.

 

X² - Este numero indentifica se o player fez ou não a quest não pode ter 2 quests com esse mesmo numero.

 

ID - ID da recompensa da quest (Item).

 

X³ - Coloque "1" se for um item Não-contavel, se for um item contavel tipo Gold coloque a quantidade que você quer.

 

Agora vá no Actions.xml e adicione esta linha:

 

<action uniqueid="X¹" script="SuaQuest.lua" />

 

Modelo de Exemplo da Quest:

 

function onUse(cid, item, frompos, item2, topos)


if item.uid == 2000 then
	if getPlayerStorageValue(cid,2000) == -1 then
		doPlayerSendTextMessage(cid,22,"Voce achou uma Flame Blade")
		doPlayerAddItem(cid,8931,1)
		setPlayerStorageValue(cid,2000,1)
	else
		doPlayerSendTextMessage(cid,22,"Bau Vazio.")
	end

end
return TRUE
end

Sua Quest está feita.

 

Quest de 3 Baús: Quest estilo da POI que só pode escolher 1 dos 3 Baús, Crie um arquivo.lua na pasta, data > actions > scripts e cole isso nele:

 

-- Xtibia Tutorial

function onUse(cid, item, frompos, item2, topos)

  	if item.uid == X¹ then
  		queststatus = getPlayerStorageValue(cid,X²)
  		if queststatus == -1 then
  			doPlayerSendTextMessage(cid,22,"Voce achou X item.")
  			doPlayerAddItem(cid,ID,X³)
  			setPlayerStorageValue(cid,X²,1)
  		else
  			doPlayerSendTextMessage(cid,22,"Bau Vazio.")
  		end
  	elseif item.uid == X¹ then
  		queststatus = getPlayerStorageValue(cid,X²)
  		if queststatus == -1 then
  			doPlayerSendTextMessage(cid,22,"Voce achou X item.")
  			doPlayerAddItem(cid,ID,X³)
  			setPlayerStorageValue(cid,X²,1)
  		else
  			doPlayerSendTextMessage(cid,22,"Bau Vazio.")
  		end
  	elseif item.uid == X¹ then
  		queststatus = getPlayerStorageValue(cid,X²)
  		if queststatus == -1 then
  			doPlayerSendTextMessage(cid,22,"Voce achou X item.")
  			doPlayerAddItem(cid,ID,X³)
  			setPlayerStorageValue(cid,X²,1)
  		else
  			doPlayerSendTextMessage(cid,22,"Bau Vazio.")
  		end
else
	return 0
  	end

  	return 1
end

 

Vamos agora configurar o Script novamente

 

X - Nome do item que ganhará na quest.

 

X¹ - Aconselho a botar mais de 2000 pois será o ID da Action, como este script é de 3 baús os Uniques ID devem ser numerados diferentemente exemplo: 2001 , 2002 , 2003.

 

X² - Este numero indentifica se o player fez ou não a quest não pode ter 2 quests com esse mesmo numero, ai fica o mesmo numero para os 3 baús.

 

ID - ID da recompensa da quest (Item), Para cada baú um item diferente.

 

X³ - Coloque "1" se for um item Não-contavel, se for um item contavel tipo Gold coloque a quantidade que você quer.

 

Agora vá no Actions.xml e adicione esta linha:

 

--Sua Quest--
<action uniqueid="X¹" script="SuaQuest.lua" />
<action uniqueid="X¹" script="SuaQuest.lua" />
<action uniqueid="X¹" script="SuaQuest.lua" />
--end Sua Quest--

 

Modelo de Exemplo da Quest:

 

-- Xtibia Tutorial Exemplo

function onUse(cid, item, frompos, item2, topos)

  	if item.uid == 2001 then
  		queststatus = getPlayerStorageValue(cid,2001)
  		if queststatus == -1 then
  			doPlayerSendTextMessage(cid,22,"Voce achou uma Sprite Wand.")
  			doPlayerAddItem(cid,2453,1)
  			setPlayerStorageValue(cid,2001,1)
  		else
  			doPlayerSendTextMessage(cid,22,"Bau Vazio.")
  		end
  	elseif item.uid == 2002 then
  		queststatus = getPlayerStorageValue(cid,2001)
  		if queststatus == -1 then
  			doPlayerSendTextMessage(cid,22,"Voce achou uma Avenger.")
  			doPlayerAddItem(cid,6528,1)
  			setPlayerStorageValue(cid,2001,1)
  		else
  			doPlayerSendTextMessage(cid,22,"Bau Vazio.")
  		end
  	elseif item.uid == 2003 then
  		queststatus = getPlayerStorageValue(cid,2001)
  		if queststatus == -1 then
  			doPlayerSendTextMessage(cid,22,"Voce achou uma Arbalest.")
  			doPlayerAddItem(cid,5803,1)
  			setPlayerStorageValue(cid,2001,1)
  		else
  			doPlayerSendTextMessage(cid,22,"Bau Vazio.")
  		end
else
	return 0
  	end

  	return 1
end

 

Então no Actions.xml eu Adicionaria assim:

 

<!-- Sua Quest -->
       <action uniqueid="5610" script="SuaQuest.lua" />
       <action uniqueid="5611" script="SuaQuest.lua" />
       <action uniqueid="5612" script="SuaQuest.lua" />

 

Quest Terminada.

 

OBS: Depois de fazer isso abra o seu map editor e editei o Unique ID do baú conforme o numero que você colocou.

 

-------------------------------------------------------------------------------------------------------------------------------------------

 

2º Tutorial - Adicionar Talkactions

 

Talkactions comums: Baixe um pack de Scripts Talkactions que eu mesmo hospedei e coloque na pasta Data > Talkactions > Scripts

Pack Talkactions

Scan Virus Total

 

Agora adicione estes comandos na talkactions.xml:

 

<?xml version="1.0" encoding="UTF-8"?>
<talkactions>
<!-- Gods -->
<talkaction log="yes" words="/addskill" access="5" event="function" value="addSkill"/>
<talkaction log="yes" words="/attr" access="5" event="function" value="thingProporties"/>
<talkaction log="yes" words="/serverdiag" access="5" event="function" value="diagnostics"/>
<talkaction log="yes" words="/closeserver" access="5" event="script" value="closeopen.lua"/>
<talkaction log="yes" words="/openserver" access="5" event="script" value="closeopen.lua"/>
<talkaction log="yes" access="5" words="/shutdown" event="script" value="shutdown.lua"/>
<talkaction log="yes" access="5" words="/mode" event="script" value="mode.lua"/>

<!-- Community Managers -->
<talkaction log="yes" words="/s" access="4" event="script" value="summon.lua"/>
<talkaction log="yes" words="/n" access="4" event="script" value="creature.lua"/>
<talkaction log="yes" words="/m" access="4" event="script" value="creature.lua"/>
<talkaction log="yes" words="/reload" access="4" event="script" value="reload.lua"/>
<talkaction log="yes" words="/raid" access="4" event="script" value="raid.lua"/>
<talkaction log="yes" words="/newtype" access="4" event="script" value="newtype.lua"/>
<talkaction log="yes" words="/r" access="4" event="script" value="remove.lua"/>
<talkaction log="yes" words="/owner" access="4" event="script" value="owner.lua"/>
<talkaction log="yes" words="/i" access="4" event="script" value="createitem.lua"/>
<talkaction access="4" words="!z" event="script" value="magiceffect.lua"/>
<talkaction access="4" words="!x" event="script" value="animationeffect.lua"/>
<talkaction access="4" words="!y" event="script" value="animatedtext.lua"/>
<talkaction log="yes" access="4" words="/bc" event="script" value="broadcastclass.lua"/>
<talkaction log="yes" access="4" words="/mkick" event="script" value="masskick.lua"/>

<!-- Gamemasters -->
<talkaction log="yes" words="/ghost" access="3" event="function" value="ghost"/>
<talkaction log="yes" words="/squelch" access="3" event="script" value="gamemaster.lua"/>
<talkaction log="yes" words="/cliport" access="3" event="script" value="gamemaster.lua"/>
<talkaction log="yes" words="/t" access="3" event="script" value="teleportmaster.lua"/>
<talkaction log="yes" words="/c" access="3" event="script" value="teleporthere.lua"/>
<talkaction log="yes" words="/goto" access="3" event="script" value="teleportto.lua"/>
<talkaction log="yes" words="/a" access="3" event="script" value="teleporttiles.lua"/>
<talkaction log="yes" words="/kick" access="3" event="script" value="kick.lua"/>
<talkaction log="yes" words="/send" access="3" event="script" value="teleportsend.lua"/>
<talkaction log="yes" words="/unban" access="3" event="script" value="unban.lua"/>
<talkaction log="yes" words="/town" access="3" event="script" value="teleporttown.lua"/>
<talkaction log="yes" words="/up" access="3" event="script" value="teleportfloor.lua"/>
<talkaction log="yes" words="/down" access="3" event="script" value="teleportfloor.lua"/>
<talkaction log="yes" access="3" words="/save" event="script" value="save.lua"/>
<talkaction log="yes" access="3" words="/clean" event="script" value="clean.lua"/>
<talkaction log="yes" access="3" words="/reports" event="script" value="reports.lua"/>
<talkaction log="yes" access="3" words="/mc" event="script" value="multicheck.lua"/>
<talkaction log="yes" access="3" words="/ban" script="bantime.lua"/>

<!-- Senior Tutors -->
<talkaction log="yes" words="/notations" access="2" event="script" value="notations.lua"/>
<talkaction log="yes" words="/info" access="2" event="script" value="playerinfo.lua"/>
<talkaction log="yes" words="/gethouse" access="2" event="script" value="gethouse.lua"/>
<talkaction log="yes" access="2" words="/b" event="script" value="broadcast.lua"/>

<!-- Tutors -->
<talkaction log="yes" words="/baninfo" access="1" event="function" value="banishmentInfo"/>
<talkaction log="yes" access="1" words="!pos" event="script" value="position.lua"/>

<!-- Players -->
<talkaction words="!notice" script="notice.lua"/>	
<talkaction words="!createguild" event="function" value="guildCreate"/>
<talkaction words="!joinguild" event="function" value="guildJoin"/>
<talkaction words="!frags" event="script" value="frags.lua"/>
       <talkaction words="!ranks" script="ranking.lua"/>
<talkaction words="!buypremium" event="script" value="buypremium.lua"/>
<talkaction words="!online" event="script" value="online.lua"/>
<talkaction words="!changender" event="script" value="changender.lua"/>
<talkaction words="/uptime" event="script" value="uptime.lua"/>
<talkaction words="/deathlist" event="script" value="deathlist.lua"/>
<talkaction words="/pvp" event="script" value="pvp.lua"/>
<talkaction words="!q" event="script" value="money.lua"/>
<talkaction words="!serverinfo" event="script" value="serverinfo.lua"/>
<talkaction words="!vip" event="script" value="vip.lua"/>
<talkaction words="!spells" event="script" value="spellsinfo.lua"/>
<talkaction words="!pvp" event="script" value="pvpinfo.lua"/>
       <talkaction words="!buyhouse" filter="word-spaced" event="function" value="houseBuy"/>
       <talkaction words="!sellhouse" filter="word-spaced" event="function" value="houseSell"/>
       <talkaction words="alana sio" filter="word-spaced" event="function" value="houseKick"/>
       <talkaction words="aleta grav" filter="word-spaced" event="function" value="houseDoorList"/>
       <talkaction words="aleta sio" filter="word-spaced" event="function" value="houseGuestList"/>
       <talkaction words="aleta som" filter="word-spaced" event="function" value="houseSubOwnerList"/>
       <talkaction words="!leavehouse" filter="word-spaced" event="script" value="leavehouse.lua"/>
</talkactions>

 

Exemplo para editar uma Talkaction:

 

<talkaction log="yes" words="/addskill" access="5" event="function"

 

<talkaction log="yes" Se você usar o comando aparecerá no Log do server

words="/addskill" é oque precisa falar para executar a talkaction

access="5" , O acesso que poderá usar o comando exemplo: God, Tutor etc...

event="function" Sem definição.

 

-------------------------------------------------------------------------------------------------------------------------------------------

 

3º Tutorial - Criando um NPC (NPC que só vende , NPC que só compra.)

Npc que só vende items: Vá em Data > Npc > Scripts crie um arquivo chamado Default.lua e cole isto:

 

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

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

npcHandler:addModule(FocusModule:new())

 

Agora volte para a pasta NPC, crie um arquivo.xml e cole isto:

 

<?xml version="1.0" encoding="UTF-8"?>
<npc name="Nome do NPC" script="data/npc/scripts/default.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="143" head="0" body="126" legs="87" feet="87" addons="3"/>
<parameters>
	<parameter key="module_shop" value="1"/>
	<parameter key="message_greet" value="Ola |PLAYERNAME|. Eu vendo equipamentos. Diga {trade}."/>
	<parameter key="shop_buyable" value="backpack,1988,20;"/>
</parameters>
</npc>

 

Em

 

value="backpack,1988,20;"/>

 

é os items que o NPC irá vender.

 

NPC que só compra: na Pasta Scripts crie um arquivo chamado loot.lua e cole isto:

 

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

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

-- Don't forget npcHandler = npcHandler in the parameters. It is required for all StdModule functions!
keywordHandler:addKeyword({'helmets'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I buy royal (40k), warrior (6k), crusader (9k), crown (5k), devil (4k), chain (35gp) and iron helmets (30gp), also mystic turbans (500gp).'})
keywordHandler:addKeyword({'boots'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I buy golden boots (100k), steel boots (40k) and boots of haste (40k).'})
keywordHandler:addKeyword({'armors'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I buy golden (30k), crown (20k), knight (5k), lady (7,5k), plate (400gp), brass (200gp) and chain armors (100gp), also mpa (100k), dsm (60k) and blue robes (15k).'})
keywordHandler:addKeyword({'legs'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I buy golden (80k), crown (15k), knight (6k), plate (500gp) and brass legs (100gp).'})
keywordHandler:addKeyword({'shields'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I buy blessed (150k), great (100k), demon (40k), vampire (25k), medusa (8k), amazon (4k), crown (5k), tower (4k), dragon (3k), guardian (2k), beholder (1k), and dwarven shields (100gp), also mms (80k).'})
keywordHandler:addKeyword({'swords'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I buy giant (10k), bright (6k), fire (3k) serpent (1.5k), spike (800gp) and two handed swords (400gp), also ice rapiers (4k), magic longswords (150k), magic swords (90k), warlord swords (100k) broad swords (70gp), short swords (30gp), sabres (25gp) and swords (25gp).'})
keywordHandler:addKeyword({'axes'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I buy fire (10k), guardian halberds (7,5k) knight (2k), double (200gp) and battle axes (100gp), also dragon lances (10k), stonecutters axes (90k), halberds (200gp) and hatchets (20gp).'})
keywordHandler:addKeyword({'clubs'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I buy thunder hammers (90k), war (6k), dragon (2k) and battle hammers (60gp), also skull staffs (10k) and clerical maces (200gp).'})

npcHandler:addModule(FocusModule:new())

 

Agora volte na pasta NPC , crie um arquivo.xml e cole isto:

 

<?xml version="1.0" encoding="UTF-8"?>
<npc name="Nome do NPC" script="data/npc/scripts/loot.lua" walkinterval="2000" floorchange="0">
<health now="150" max="150"/>
<look type="133" head="78" body="86" legs="88" feet="0" addons="3"/>
<parameters>
	<parameter key="module_shop" value="1"/>
	<parameter key="message_greet" value="Ola |PLAYERNAME|. Eu Compro Swords, Clubs, Axes, Helmets, Boots, Legs, Shields e Armors."/>
	<parameter key="shop_sellable" value="royal helmet,2498,40000;warrior helmet,2475,6000;crusader helmet,2497,9000;crown helmet,2491,5000;devil helmet,2462,4000;mystic turban,2663,500;chain helmet,2458,35;iron helmet,2459,30;steel boots,2645,60000;boots of haste,2195,40000;golden boots,2646,100000;magic plate armor,2472,100000;dragon scale mail,2492,60000;demon armor,2494,90000;golden armor,2466,30000;crown armor,2487,20000;knight armor,2476,5000;blue robe,2656,15000;lady armor,2500,2500;plate armor,2463,400;brass armor,2465,200;chain armor,2464,100;golden legs,2470,80000;crown legs,2488,15000;knight legs,2477,6000;plate legs,2647,500;brass legs,2487,100;mastermind shield,2514,80000;demon shield,2520,40000;blessed shield,2523,150000;great shield,2522,100000;vampire shield,2534,25000;medusa shield,2536,8000;amazon shield,2537,4000;crown shield,2519,5000;tower shield,2528,4000;guardian shield,2515,200;beholder shield,2518,1500;dwarven shield,2525,100;magic longsword,2390,150000;warlord sword,2408,100000;magic sword,2400,90000;giant sword,2393,10000;bright sword,2407,6000;ice rapier,2396,4000;fire sword,2392,3000;serpent sword,2409,1500;spike sword,2383,800;two handed sword,2377,400;broad sword,2413,70;short sword,2406,30;sword,2376,25;dragon lance,2414,10000;stonecutter axe,2431,90000;guardian halberd,2427,7500;fire axe,2432,10000;knight axe,2430,2000;double axe,2387,200;halberd,2381,200;battle axe,2378,100;hatchet,2388,20;war hammer,2391,6000;thunder hammer,2421,90000;skull staff,2436,1000;dragon hammer,2434,2000;clerical mace,2423,200;battle hammer,2417,60;mace,2398,30;"/>
</parameters>
</npc>

 

O NPC que compra já está configurado com vários items para comprar.

 

 

Creditos 100% Meu

Bom. Avaliem :icon1:

Editado por NoHeAD
Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...