SC
pedido

Potion System

Por ScythePhantom, 15 de out. de 2013 em Scripts

resolvido
19
3.1k
lucasfgxL
16 de outubro de 2013 às 13:24

Usuário acima, embora seu script possa ser funcional, a base que ele forneceu é muito superior e, por favor, use spoilers para postar códigos grandes.

 

 

local Potion = {

 
type = "",
healmin = 0,
healmax = 0,
vocations = {},
emptyid = 0,
}
 
function Potion:new(type, healmin, healmax, vocations, emptyid, uid)
local potions = {
type = type,
healmin = tonumber(healmin),
healmax = tonumber(healmax),
vocations = vocations,
uid = 0,
}
 
return setmetatable(potions, {__index = self})
end
 
function Potion:heal(cid)
if self.vocations ~= "all" and not isInArray(self.vocations, getPlayerVocation(cid)) then
doPlayerSendCancel(cid, "This vocation cannot use this potion.") return false
elseif self.type == "health" then
doCreatureAddHealth(cid, math.random(self.healmin, self.healmax))
elseif self.type == "mana" then
doPlayerAddMana(cid, math.random(self.healmin, self.healmax))
end
doCreatureSay(cid, "Aaaah...", TALKTYPE_MONSTER)
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_BLUE)
return true
end
 
Pots = {
[8704] = Potion:new("health", 50, 100, "all", 7636),
[7618] = Potion:new("health", 100, 200, "all", 7636),
[7588] = Potion:new("health", 200, 400, {3, 4, 7, 8}, 7634),
[7591] = Potion:new("health", 600, 800, {4, 8}, 7635),
[8473] = Potion:new("health", 900, 1200, {4, 8}, 7635),
[8472] = Potion:new("health", 900, 950, {3, 7}, 7635),
[7620] = Potion:new("mana", 90, 150, "all", 7636),
[7589] = Potion:new("mana", 190, 250, {1, 2, 5, 6}, 7634),
[7590] = Potion:new("mana", 300, 400, {1, 2, 5, 6}, 7635),
}
 
function onUse(cid, item, position, itemEx)
if not isPlayer(itemEx.uid) then
doPlayerSendCancel(cid, "Use only in players.")
return true
end
local Potions = Pots[item.itemid]
Potions.uid = item.uid
if Potions:heal(itemEx.uid) then
	doRemoveItem(item.uid, 1)
end
return true

end

 

 

 

Testa mais esse aqui se quiser manter, agora deve funcionar.

nada ve cara eu testei no meu e funciono os 2 o dele e o meu.

ScythePhantomS
16 de outubro de 2013 às 13:26

Perfeito Omega, reputado, e o outro brother também por ter ajudado, obrigado.

OmegaO
16 de outubro de 2013 às 13:32

Tópico movido para a seção de dúvidas e pedidos resolvidos.

lucasfgxL
16 de outubro de 2013 às 13:43

Perfeito Omega, reputado, e o outro brother também por ter ajudado, obrigado.

vlw mano mdr.gif .

mais foi mal aew se eu n ajudei.worriedsmiley.gif