AV

Descontar Gold Ao Usar A Action.

Por Avohai, 18 de mar. de 2011 em Archived

otserv
tibia
script
7
803
AvohaiA
18 de março de 2011 às 08:35

E ai pessoal, estou precisando de uma ajuda pois de scripts não entendo muita coisa.

 

Gostaria que ao dar use em certa action do meu servidor, fosse descontado uma certa quantia em dinheiro do player, porém se ele estiver com tal item no inventario esse gold não seria descontado.

Tem como fazer? :thumbsupsmiley:

 

Grande abraço a todos!

VodkartV
18 de março de 2011 às 10:24

Tem como fazer?

 

 

SIM,tem,você poderia colocar a sua action para que fosse implementada,ou ainda você nem crio ela?

AvohaiA
18 de março de 2011 às 12:09

Ja criei, só que na verdade eu não sei se posso postar ela aqui pois peguei ela em outro fórum, é o Train System do Mock, será que tem problema?

 

Bom, acho que nao há problema se eu não tirar os créditos

Segue:

 

--Script by mock the bear

--Config

local SPEED = 200

local PLAYERSPEED = 250

--End

local RAILS = {7121, 7122, 7123, 7124, 7125, 7126, 7127, 7128, 7129, 7130} --Thxy rails itemid by nord :p

local CART = {[0] = 7132, [2] = 7132, [3] =7131, [1] =7131}

local CONFIG = {

[7121] = 0,[7122] = 0,

[7123] = {EAST, SOUTH},

[7124] = {WEST, SOUTH},

[7125] = {EAST, NORTH},

[7126] = {WEST, NORTH},

[7127] = 0,[7128] = 0,

[7129] = 0,[7130] = 0,

--Random

}

local reverse = {[0] = 2, 3, 0, 1} -- All that table was made by nord.

local function moveTrain(cid, frompos, direc)

local tab

if not isPlayer(cid) then

return

end

local pos = getCreaturePosition(cid)

local rar = findRail(pos)

if not rar then

doPlayerSetNoMove(cid, false)

doRemoveCondition(cid, CONDITION_OUTFIT)

doChangeSpeed(cid, -PLAYERSPEED)

doMoveCreature(cid, direc)

else

tab = CONFIG[rar]

if tab and type(tab) == 'table' then

direc = tab[tab[1] == reverse[direc] and 2 or 1] -- by nord here

end

doSetItemOutfit(cid, CART[direc], -1)

doMoveCreature(cid, direc)

addEvent(moveTrain, SPEED, cid, pos,direc)

end

end

function findRail(p)

local p_ = {x=p.x, y=p.y, z=p.z}

for i=0,10 do

p_.stackpos = i

local t = getTileThingByPos(p_)

if isInArray(RAILS, t.itemid) then

return t.itemid,t.uid

end

end

end

function onUse(cid, item, frompos) --Script by mock the bear

if hasCondition(cid, CONDITION_OUTFIT) or (item.actionid < 500 and item.actionid > 503) then

return false

end

doTeleportThing(cid, frompos, false)

doPlayerSetNoMove(cid, true)

doChangeSpeed(cid, PLAYERSPEED)

addEvent(moveTrain, SPEED, cid, frompos, item.actionid-500)

return true

end

 

Se conseguir fazer serei eternamente grato :thumbsupsmiley:

Editado Março 18 por Avohai

VodkartV
18 de março de 2011 às 12:12

não não,posta ai,não tem problema algum,só se fosse ripping ou se ele nçao tivesse autorizado mesmo.

AvohaiA
18 de março de 2011 às 12:19

Certo, ja editei meu post ali de cima.

 

______

Foi mal pelo flood, mais é que eu editei antes de você responder, então...

Editado Março 18 por Avohai

VodkartV
18 de março de 2011 às 13:03

--Script by mock the bear
--Config
local SPEED = 200
local PLAYERSPEED = 250
--End
local RAILS = {7121, 7122, 7123, 7124, 7125, 7126, 7127, 7128, 7129, 7130} --Thxy rails itemid by nord 
local CART = {[0] = 7132, [2] = 7132, [3] =7131, [1] =7131}
local CONFIG = {
[7121] = 0,[7122] = 0,
[7123] = {EAST, SOUTH},
[7124] = {WEST, SOUTH},
[7125] = {EAST, NORTH},
[7126] = {WEST, NORTH},
[7127] = 0,[7128] = 0,
[7129] = 0,[7130] = 0,
--Random
}
local reverse = {[0] = 2, 3, 0, 1} -- All that table was made by nord.
local function moveTrain(cid, frompos, direc)
local tab
if not isPlayer(cid) then
return
end
local pos = getCreaturePosition(cid)
local rar = findRail(pos)
if not rar then
doPlayerSetNoMove(cid, false)
doRemoveCondition(cid, CONDITION_OUTFIT)
doChangeSpeed(cid, -PLAYERSPEED)
doMoveCreature(cid, direc)
else
tab = CONFIG[rar]
if tab and type(tab) == 'table' then
direc = tab[tab[1] == reverse[direc] and 2 or 1] -- by nord here
end
doSetItemOutfit(cid, CART[direc], -1)
doMoveCreature(cid, direc)
addEvent(moveTrain, SPEED, cid, pos,direc)
end
end
function findRail(p)
local p_ = {x=p.x, y=p.y, z=p.z}
for i=0,10 do
p_.stackpos = i
local t = getTileThingByPos(p_)
if isInArray(RAILS, t.itemid) then
return t.itemid,t.uid
end
end
end
function onUse(cid, item, frompos) --Script by mock the bear
local id,price = 2322,300000
if hasCondition(cid, CONDITION_OUTFIT) or (item.actionid < 500 and item.actionid > 503) then
return false
elseif getPlayerItemCount(cid, id) <= 0 and doPlayerRemoveMoney(cid, price) == FALSE then
doPlayerSendCancel(cid,"Você precisa de "..price.." para andar.")
return false
end
doTeleportThing(cid, frompos, false)
doPlayerSetNoMove(cid, true)
doChangeSpeed(cid, PLAYERSPEED)
addEvent(moveTrain, SPEED, cid, frompos, item.actionid-500)
return true
end

 

edita essa parte

 

local id,price = 2322,300000

 

id do item,preço

AvohaiA
18 de março de 2011 às 19:10

Nossa, exatamente o que eu queria.

Vodkart muito obrigado mesmo, me respondeu super rapido e funcionou perfeitamente. Te devo essa! :thumbsupsmiley2: