Antes de ler o tópico, certifique-se de que está no X-Tibia!
Olá, sou Chain e vim mostrar para os integrantes do X-Tibia o Sell'On'Click System.. feito por MIM!
Esse script é o seguinte.. ele vende um item ao clicar no mesmo, por exemplo.. estou em minha hunt, mas aí nao quero parar pra ir vender os itens... então eu clico nele e Puff.. item vendido...
Legal, não ? Apesar de estragar todo o RPG em um server '.
Se você estiver interessado.. Mãos a obra!
Tutorial:
1° Vá em "Data/actions/scripts", copie um arquivo e cole, renomeie-o para sell.lua..
Ao fazer isso, substitua o conteúdo dele por:
--Sell'on'Click system by Chain!function onUse(cid, item, frompos, item2, topos)
---------------------------Configuration---------------------------
podevender = getPlayerStorageValue(cid,4578)
---------------------------End of Configs---------------------------
if item.itemid == 2493 and podevender == 1 then
doRemoveItem(item.uid,1)
doPlayerAddItem(cid,2160,10)
doPlayerSendTextMessage(cid,22,"Voce vendeu seu demon helmet")
else
doPlayerSendTextMessage(cid,22,"Para vender itens clicando neles, fale com o npc Contrato de SellOnClick.")
end
if item.itemid == 2498 and podevender == 1 then
doPlayerSendTextMessage(cid,22,"Voce vendeu seu RH")
doRemoveItem(item.uid,1)
doPlayerAddItem(cid,2160,4)
end
if item.itemid == 2475 and podevender == 1 then
doPlayerSendTextMessage(cid,22,"Voce vendeu seu Warrior Helmet")
doRemoveItem(item.uid,1)
doPlayerAddItem(cid,2152,60)
end
if item.itemid == 2497 and podevender == 1 then
doPlayerSendTextMessage(cid,22,"Voce vendeu seu Crusader Helmet")
doRemoveItem(item.uid,1)
doPlayerAddItem(cid,2152,90)
end
if item.itemid == 2645 and podevender == 1 then
doPlayerSendTextMessage(cid,22,"Voce vendeu sua Steel Boots")
doRemoveItem(item.uid,1)
doPlayerAddItem(cid,2160,4)
end
if item.itemid == 2195 and podevender == 1 then
doPlayerSendTextMessage(cid,22,"Voce vendeu sua BOH")
doRemoveItem(item.uid,1)
doPlayerAddItem(cid,2160,4)
end
if item.itemid == 2646 and podevender == 1 then
doPlayerSendTextMessage(cid,22,"Voce vendeu sua Golden Boots")
doRemoveItem(item.uid,1)
doPlayerAddItem(cid,2160,10)
end
if item.itemid == 2472 and podevender == 1 then
doPlayerSendTextMessage(cid,22,"Voce vendeu sua MPA")
doRemoveItem(item.uid,1)
doPlayerAddItem(cid,2160,10)
else
end
if item.itemid == 2492 and podevender == 1 then
doPlayerSendTextMessage(cid,22,"Voce vendeu sua DSM")
doRemoveItem(item.uid,1)
doPlayerAddItem(cid,2160,6)
end
if item.itemid == 2494 and podevender == 1 then
doPlayerSendTextMessage(cid,22,"Voce vendeu sua Demon Armor")
doRemoveItem(item.uid,1)
doPlayerAddItem(cid,2160,9)
end
if item.itemid == 2466 and podevender == 1 then
doPlayerSendTextMessage(cid,22,"Voce vendeu sua Golden Armor")
doRemoveItem(item.uid,1)
doPlayerAddItem(cid,2160,3)
end
if item.itemid == 2487 and podevender == 1 then
doPlayerSendTextMessage(cid,22,"Voce vendeu sua Crown Armor")
doRemoveItem(item.uid,1)
doPlayerAddItem(cid,2160,2)
end
if item.itemid == 2476 and podevender == 1 then
doPlayerSendTextMessage(cid,22,"Voce vendeu sua Knight Armor")
doRemoveItem(item.uid,1)
doPlayerAddItem(cid,2152,50)
end
if item.itemid == 2656 and podevender == 1 then
doPlayerSendTextMessage(cid,22,"Voce vendeu sua Blue Robe")
doRemoveItem(item.uid,1)
doPlayerAddItem(cid,2152,50)
doPlayerAddItem(cid,2160,1)
end
if item.itemid == 2470 and podevender == 1 then
doPlayerSendTextMessage(cid,22,"Voce vendeu sua G-Legs")
doRemoveItem(item.uid,1)
doPlayerAddItem(cid,2160,8)
end
if item.itemid == 2488 and podevender == 1 then
doPlayerSendTextMessage(cid,22,"Voce vendeu sua Crown Legs")
doPlayerAddItem(cid,2152,50)
doPlayerAddItem(cid,2160,1)
end
if item.itemid == 2477 and podevender == 1 then
doPlayerSendTextMessage(cid,22,"Voce vendeu sua K-Legs")
doPlayerAddItem(cid,2152,60)
doPlayerAddItem(cid,2160,0)
--para adicionar mais itens visite: http://www.xtibia.com/forum/Sell-on-click-...851#entry580851
end
end
2° Vá em uma pasta anterior e abra o arquivo Actions.xml como bloco de notas..
3° Adicione as seguintes linhas:
[codebox]
<!-- Sell'On'Click By Chain -->
<action itemid="2493" script="sell.lua" />
<action itemid="2498" script="sell.lua" />
<action itemid="2475" script="sell.lua" />
<action itemid="2497" script="sell.lua" />
<action itemid="2645" script="sell.lua" />
<action itemid="2195" script="sell.lua" />
<action itemid="2646" script="sell.lua" />
<action itemid="2472" script="sell.lua" />
<action itemid="2494" script="sell.lua" />
<action itemid="2466" script="sell.lua" />
<action itemid="2487" script="sell.lua" />
<action itemid="2476" script="sell.lua" />
<action itemid="2656" script="sell.lua" />
<action itemid="2470" script="sell.lua" />
<action itemid="2488" script="sell.lua" />
<action itemid="2477" script="sell.lua" />
Prontinho, script feito...
Agora vamos fazer um npc que habilita as pessoas a usarem o Sell'On'Click!
Vá em "data/npc/" e copie um arquivo, cole-o e renomeie para contrato de sellonclick.xml, abra-o apague tudo e coloque isso:
[codebox]
<?xml version="1.0"?>
<npc name="Contrato de SellOnClick" script="data/npc/scripts/sellonclick.lua" access="5" lookdir="2">
<mana now="800" max="800"/>
<health now="200" max="200"/>
<look type="132" head="78" body="88" legs="0" feet="88"/>
</npc>
Após isso, entre na pasta "data/npc/script" e copie qualquer arquivo e renomeie como sellonclick.lua, depois abra-o e coloque o seguinte:
[codebox]
local focus = 0local talk_start = 0
local target = 0
local following = false
local attacking = false
function onThingMove(creature, thing, oldpos, oldstackpos)
end
function onCreatureAppear(creature)
end
function onCreatureDisappear(cid, pos)
if focus == cid then
selfSay('Adeus')
focus = 0
talk_start = 0
end
end
function onCreatureTurn(creature)
end
function msgcontains(txt, str)
return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
end
function onCreatureSay(cid, type, msg)
msg = string.lower(msg)
if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
selfSay('Oi ' .. getCreatureName(cid) .. ' sou o npc que da o contrato de SellOnClick, para mais infos diga: contrato... E para cancelar um contrato feito dica: cancelar ')
focus = cid
talk_start = os.clock()
elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('Pera, ' .. getCreatureName(cid) .. '! Ja tem alguem lendo o contrato')
elseif focus == cid then
talk_start = os.clock()
if msgcontains(msg, 'contrato') or msgcontains(msg, 'sell') then
selfSay('O SellOnClick, se baseia no seguinte, voce clica em um item, e o mesmo é vendido automaticamente! Para aceitar o contrato diga :aceito')
if msgcontains(msg, 'cancelar') or msgcontains(msg, 'cancel') then
selfSay('Seu contrato foi cancelado!')
setPlayerStorageValue(cid,4578,-1)
elseif msgcontains(msg, 'aceito') then
setPlayerStorageValue(cid,4578,1)
selfSay('Ok ' .. getCreatureName(cid) .. '... Seu contrato foi aceito!')
else
selfSay('Ok ' .. getCreatureName(cid) .. '... Seu contrato nao foi aceito!, caso queira aceitar, relogue seu char e fale comigo denovo!')
end
end
if focus ~= 0 then
if getDistanceToCreature(focus) > 5 then
selfSay('Tchauzinho!')
focus = 0
end
end
end
[u][size=4][color=#0000FF]Agora vou ensinar um TUTORIAL de como adicionar itens ao banco de dados[/color][/size]:[/u]
no arquivo "Sell.lua"
adicione isso:
elseif item.itemid == [color=#FF0000]ID_DO_ITEM[/color] and podevender == 1 thendoPlayerSendTextMessage(cid,22,"[color=#FF0000]Mensagem que vai aparecer após a venda[/color]")
doRemoveItem(item.uid,1)
doPlayerAddItem(cid,2148,[color=#FF0000]quantidade_de_golds[/color])
doPlayerAddItem(cid,2152,[color=#FF0000]quantidade_de_platinum[/color])
doPlayerAddItem(cid,2160,[color=#FF0000]quantidade_de_crystal[/color])
E então, vá no actions.xml e adicione:
<action itemid="[color=#FF0000]ID_DO_ITEM[/color]" script="sell.lua" />
[size=6][color=#0000FF]Ei, você que gostou do tópico, contribua com ele.. faça seus packs de banco de dados utilizando o tutorial acima e poste aqui nesse tópico![/color][/size]
[color=#FF0000][u]E a partir daqui, ficarão os créditos e as packs de cada um que contribuir ao tópico!
[/u][/color]
[/b]