ScythePhantom 83 Postado Outubro 15, 2013 Share Postado Outubro 15, 2013 (editado) #Edit, resolvido. Editado Dezembro 4, 2013 por ScythePhantom Link para o comentário https://xtibia.com/forum/topic/222702-potion-system/ Compartilhar em outros sites More sharing options...
0 kttallan 319 Postado Outubro 15, 2013 Share Postado Outubro 15, 2013 tente esse 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 true 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", 8704), [7618] = Potion:new("health", 100, 200, "all", 7618), [7588] = Potion:new("health", 200, 400, {3, 4, 7, 8}, 7588), [7591] = Potion:new("health", 600, 800, {4, 8}, 7591), [8473] = Potion:new("health", 900, 1200, {4, 8}, 8473), [8472] = Potion:new("health", 900, 950, {3, 7}, 8472), [7620] = Potion:new("mana", 90, 150, "all", 7620), [7589] = Potion:new("mana", 190, 250, {1, 2, 5, 6}, 7589), [7590] = Potion:new("mana", 300, 400, {1, 2, 5, 6}, 7590), } 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 Potions:heal(itemEx.uid) return true end Link para o comentário https://xtibia.com/forum/topic/222702-potion-system/#findComment-1572718 Compartilhar em outros sites More sharing options...
0 ScythePhantom 83 Postado Outubro 15, 2013 Autor Share Postado Outubro 15, 2013 Ainda não, eu quero que ele gaste, porém que não fique o empty, assim ainda está infinita. Link para o comentário https://xtibia.com/forum/topic/222702-potion-system/#findComment-1572727 Compartilhar em outros sites More sharing options...
0 kttallan 319 Postado Outubro 15, 2013 Share Postado Outubro 15, 2013 use doRemoveItem(uid, 1) no scripter.. Link para o comentário https://xtibia.com/forum/topic/222702-potion-system/#findComment-1572763 Compartilhar em outros sites More sharing options...
0 Omega 377 Postado Outubro 16, 2013 Share Postado Outubro 16, 2013 Como o cara aí disse, deve funcionar assim: 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 true 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 Potions:heal(itemEx.uid) doRemoveItem(item.uid, 1) return true end Link para o comentário https://xtibia.com/forum/topic/222702-potion-system/#findComment-1572818 Compartilhar em outros sites More sharing options...
0 Lumus 254 Postado Outubro 16, 2013 Share Postado Outubro 16, 2013 Tó: local MIN = 950 local MAX = 1050 local EMPTY_POTION = 7635 local RANGE = -1 local exhaust = createConditionObject(CONDITION_EXHAUST) setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100)) function onUse(cid, item, fromPosition, itemEx, toPosition) if isPlayer(itemEx.uid) == FALSE then return FALSE end if hasCondition(cid, CONDITION_EXHAUST_HEAL) == TRUE then doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED) return TRUE end if(RANGE > 0 and cid ~= itemEx.uid and getDistanceBetween(getThingPosition(cid), getThingPosition(itemEx.uid)) > RANGE) then return FALSE end if doPlayerAddMana(itemEx.uid, math.random(MIN, MAX)) == LUA_ERROR then return FALSE end doAddCondition(cid, exhaust) doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_MAGIC_BLUE) doCreatureSay(itemEx.uid, "Aaaah!!!", TALKTYPE_ORANGE_1) doRemoveItem(item.uid, 1) pot_count = getPlayerItemCount(cid, EMPTY_POTION) doPlayerRemoveItem(cid, EMPTY_POTION, pot_count) return TRUE end Link para o comentário https://xtibia.com/forum/topic/222702-potion-system/#findComment-1572823 Compartilhar em outros sites More sharing options...
0 ScythePhantom 83 Postado Outubro 16, 2013 Autor Share Postado Outubro 16, 2013 (editado) Como o cara aí disse, deve funcionar assim: Spoiler 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 true 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 Potions:heal(itemEx.uid) doRemoveItem(item.uid, 1) return true end Funcionou, porém se uma vocação tenta usar um potion de outra vocação os potions também gastam, não healam, mas ainda assim são gastos, no caso deveria apararecer uma mensagem Only vocation... e tal, e não serem gastos. Editado Outubro 16, 2013 por ScythePhantom Link para o comentário https://xtibia.com/forum/topic/222702-potion-system/#findComment-1572902 Compartilhar em outros sites More sharing options...
0 lucasfgx 3 Postado Outubro 16, 2013 Share Postado Outubro 16, 2013 (editado) tenta aew local config = { removeOnUse = "yes", usableOnTarget = "yes", -- can be used on target? (fe. healing friend) splashable = "no", realAnimation = "no", -- make text effect visible only for players in range 1x1 healthMultiplier = 1.0, manaMultiplier = 1.0 } config.removeOnUse = getBooleanFromString(config.removeOnUse) config.usableOnTarget = getBooleanFromString(config.usableOnTarget) config.splashable = getBooleanFromString(config.splashable) config.realAnimation = getBooleanFromString(config.realAnimation) local POTIONS = { [8704] = {empty = 7636, splash = 2, health = {50, 100}}, -- small health potion [7618] = {empty = 7636, splash = 2, health = {100, 200}}, -- health potion [7588] = {empty = 7634, splash = 2, health = {200, 400}, level = 50, vocations = {3, 4, 7, 8}, vocStr = "knights and paladins"}, -- strong health potion [7591] = {empty = 7635, splash = 2, health = {500, 700}, level = 80, vocations = {4, 8}, vocStr = "knights"}, -- great health potion [8473] = {empty = 7635, splash = 2, health = {800, 1100}, level = 130, vocations = {4, 8}, vocStr = "knights"}, -- ultimate health potion [7620] = {empty = 7636, splash = 7, mana = {90, 170}}, -- mana potion [7589] = {empty = 7634, splash = 7, mana = {110, 190}, level = 50, vocations = {1, 2, 3, 5, 6, 7}, vocStr = "sorcerers, druids and paladins"}, -- strong mana potion [7590] = {empty = 7635, splash = 7, mana = {500, 800}, level = 80, vocations = {1, 2, 5, 6}, vocStr = "sorcerers and druids"}, -- great mana potion [8472] = {empty = 7635, splash = 3, health = {400, 600}, mana = {230, 380}, level = 80, vocations = {3, 7}, vocStr = "paladins"} -- great spirit potion } local exhaust = createConditionObject(CONDITION_EXHAUST) setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100)) function onUse(cid, item, fromPosition, itemEx, toPosition) local potion = POTIONS[item.itemid] if(not potion) then return false end if(not isPlayer(itemEx.uid) or (not config.usableOnTarget and cid ~= itemEx.uid)) then if(not config.splashable) then return false end if(toPosition.x == CONTAINER_POSITION) then toPosition = getThingPos(item.uid) end doDecayItem(doCreateItem(2016, potion.splash, toPosition)) doTransformItem(item.uid, potion.empty) return TRUE end if(hasCondition(cid, CONDITION_EXHAUST_HEAL)) then doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED) return TRUE end if(((potion.level and getPlayerLevel(cid) < potion.level) or (potion.vocations and not isInArray(potion.vocations, getPlayerVocation(cid)))) and not getPlayerCustomFlagValue(cid, PLAYERCUSTOMFLAG_GAMEMASTERPRIVILEGES)) then doCreatureSay(itemEx.uid, "Only " .. potion.vocStr .. (potion.level and (" of level " .. potion.level) or "") .. " or above may drink this fluid.", TALKTYPE_ORANGE_1) return TRUE end local health = potion.health if(health and not doCreatureAddHealth(itemEx.uid, math.ceil(math.random(health[1], health[2]) * config.healthMultiplier))) then return false end local mana = potion.mana if(mana and not doPlayerAddMana(itemEx.uid, math.ceil(math.random(mana[1], mana[2]) * config.manaMultiplier))) then return false end doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_MAGIC_BLUE) if(not realAnimation) then doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1) else for i, tid in ipairs(getSpectators(getCreaturePosition(cid), 1, 1)) do if(isPlayer(tid)) then doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1, false, tid) end end end doAddCondition(cid, exhaust) if(not potion.empty or config.removeOnUse) then doRemoveItem(item.uid, 1) return TRUE end doRemoveItem(item.uid, 0) doPlayerAddItem(cid, potion.empty, 0) doPlayerRemoveItem(cid, potion.empty, getPlayerItemCount(cid, potion.empty)) doPlayerAddItem(cid, potion.empty, getPlayerItemCount(cid, potion.empty)) return TRUE end Editado Outubro 16, 2013 por lucasfgx Link para o comentário https://xtibia.com/forum/topic/222702-potion-system/#findComment-1572910 Compartilhar em outros sites More sharing options...
0 ScythePhantom 83 Postado Outubro 16, 2013 Autor Share Postado Outubro 16, 2013 Mesma coisa, tipo aparece a mensagem This vocation cannot use this potion mas ainda assim o potion é gasto. Link para o comentário https://xtibia.com/forum/topic/222702-potion-system/#findComment-1572912 Compartilhar em outros sites More sharing options...
0 lucasfgx 3 Postado Outubro 16, 2013 Share Postado Outubro 16, 2013 Mesma coisa, tipo aparece a mensagem This vocation cannot use this potion mas ainda assim o potion é gasto. foi mal eu eskeci de arruma um negocio kkk tenta essa dae. eu arrumei ali em cima. Link para o comentário https://xtibia.com/forum/topic/222702-potion-system/#findComment-1572914 Compartilhar em outros sites More sharing options...
0 Omega 377 Postado Outubro 16, 2013 Share Postado Outubro 16, 2013 (editado) 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 true 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 doPlayerRemoveItem(cid, self.uid, 1) 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 Potions:heal(itemEx.uid) return true end Editado Outubro 16, 2013 por omega blueheaven Link para o comentário https://xtibia.com/forum/topic/222702-potion-system/#findComment-1572915 Compartilhar em outros sites More sharing options...
0 lucasfgx 3 Postado Outubro 16, 2013 Share Postado Outubro 16, 2013 Omega eu ja postei ali em cima. Link para o comentário https://xtibia.com/forum/topic/222702-potion-system/#findComment-1572916 Compartilhar em outros sites More sharing options...
0 ScythePhantom 83 Postado Outubro 16, 2013 Autor Share Postado Outubro 16, 2013 Agora está certo, porém está infinita... não gasta nenhuma. Link para o comentário https://xtibia.com/forum/topic/222702-potion-system/#findComment-1572919 Compartilhar em outros sites More sharing options...
0 lucasfgx 3 Postado Outubro 16, 2013 Share Postado Outubro 16, 2013 Agora está certo, porém está infinita... não gasta nenhuma. mano usa a minha la esta certo e esta gastando. local config = { removeOnUse = "yes", usableOnTarget = "yes", -- can be used on target? (fe. healing friend) splashable = "no", realAnimation = "no", -- make text effect visible only for players in range 1x1 healthMultiplier = 1.0, manaMultiplier = 1.0 } config.removeOnUse = getBooleanFromString(config.removeOnUse) config.usableOnTarget = getBooleanFromString(config.usableOnTarget) config.splashable = getBooleanFromString(config.splashable) config.realAnimation = getBooleanFromString(config.realAnimation) local POTIONS = { [8704] = {empty = 7636, splash = 2, health = {50, 100}}, -- small health potion [7618] = {empty = 7636, splash = 2, health = {100, 200}}, -- health potion [7588] = {empty = 7634, splash = 2, health = {200, 400}, level = 50, vocations = {3, 4, 7, 8}, vocStr = "knights and paladins"}, -- strong health potion [7591] = {empty = 7635, splash = 2, health = {500, 700}, level = 80, vocations = {4, 8}, vocStr = "knights"}, -- great health potion [8473] = {empty = 7635, splash = 2, health = {800, 1100}, level = 130, vocations = {4, 8}, vocStr = "knights"}, -- ultimate health potion [7620] = {empty = 7636, splash = 7, mana = {90, 170}}, -- mana potion [7589] = {empty = 7634, splash = 7, mana = {110, 190}, level = 50, vocations = {1, 2, 3, 5, 6, 7}, vocStr = "sorcerers, druids and paladins"}, -- strong mana potion [7590] = {empty = 7635, splash = 7, mana = {500, 800}, level = 80, vocations = {1, 2, 5, 6}, vocStr = "sorcerers and druids"}, -- great mana potion [8472] = {empty = 7635, splash = 3, health = {400, 600}, mana = {230, 380}, level = 80, vocations = {3, 7}, vocStr = "paladins"} -- great spirit potion } local exhaust = createConditionObject(CONDITION_EXHAUST) setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100)) function onUse(cid, item, fromPosition, itemEx, toPosition) local potion = POTIONS[item.itemid] if(not potion) then return false end if(not isPlayer(itemEx.uid) or (not config.usableOnTarget and cid ~= itemEx.uid)) then if(not config.splashable) then return false end if(toPosition.x == CONTAINER_POSITION) then toPosition = getThingPos(item.uid) end doDecayItem(doCreateItem(2016, potion.splash, toPosition)) doTransformItem(item.uid, potion.empty) return TRUE end if(hasCondition(cid, CONDITION_EXHAUST_HEAL)) then doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED) return TRUE end if(((potion.level and getPlayerLevel(cid) < potion.level) or (potion.vocations and not isInArray(potion.vocations, getPlayerVocation(cid)))) and not getPlayerCustomFlagValue(cid, PLAYERCUSTOMFLAG_GAMEMASTERPRIVILEGES)) then doCreatureSay(itemEx.uid, "Only " .. potion.vocStr .. (potion.level and (" of level " .. potion.level) or "") .. " or above may drink this fluid.", TALKTYPE_ORANGE_1) return TRUE end local health = potion.health if(health and not doCreatureAddHealth(itemEx.uid, math.ceil(math.random(health[1], health[2]) * config.healthMultiplier))) then return false end local mana = potion.mana if(mana and not doPlayerAddMana(itemEx.uid, math.ceil(math.random(mana[1], mana[2]) * config.manaMultiplier))) then return false end doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_MAGIC_BLUE) if(not realAnimation) then doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1) else for i, tid in ipairs(getSpectators(getCreaturePosition(cid), 1, 1)) do if(isPlayer(tid)) then doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1, false, tid) end end end doAddCondition(cid, exhaust) if(not potion.empty or config.removeOnUse) then doRemoveItem(item.uid, 1) return TRUE end doRemoveItem(item.uid, 0) doPlayerAddItem(cid, potion.empty, 0) doPlayerRemoveItem(cid, potion.empty, getPlayerItemCount(cid, potion.empty)) doPlayerAddItem(cid, potion.empty, getPlayerItemCount(cid, potion.empty)) return TRUE end Link para o comentário https://xtibia.com/forum/topic/222702-potion-system/#findComment-1572925 Compartilhar em outros sites More sharing options...
0 Omega 377 Postado Outubro 16, 2013 Share Postado Outubro 16, 2013 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. Link para o comentário https://xtibia.com/forum/topic/222702-potion-system/#findComment-1572928 Compartilhar em outros sites More sharing options...
0 lucasfgx 3 Postado Outubro 16, 2013 Share Postado Outubro 16, 2013 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. Link para o comentário https://xtibia.com/forum/topic/222702-potion-system/#findComment-1572930 Compartilhar em outros sites More sharing options...
Pergunta
ScythePhantom 83
#Edit, resolvido.
Editado por ScythePhantomLink para o comentário
https://xtibia.com/forum/topic/222702-potion-system/Compartilhar em outros sites
18 respostass a esta questão
Posts Recomendados