Postado Setembro 20, 2015 9 anos Iae Bom, estou querendo um script onde as potions curem uma porcentagem configurável do hp e da mana do jogador. As potions de mana curariam uma porcentagem de mana, e as de hp curariam uma porcentagem do hp. Grato
Postado Setembro 21, 2015 9 anos Solução local config = { removeOnUse = "yes", usableOnTarget = "yes", -- can be used on target? (fe. healing friend) exhaustedTime = 100 -- time to use again (1000 = 1 second) } config.removeOnUse = getBooleanFromString(config.removeOnUse) config.usableOnTarget = getBooleanFromString(config.usableOnTarget) local POTIONS = { --[item id] = {manaPercent, healthPercent, effect} [2686] = {healthPercent = 20, effect = 13}, -- HP Potion [2692] = {manaPercent = 25, effect = 13}, -- Mana Potion } local exhaust = createConditionObject(CONDITION_EXHAUST) setConditionParam(exhaust, CONDITION_PARAM_TICKS, config.exhaustedTime) function onUse(cid, item, fromPosition, itemEx, toPosition) local potion = POTIONS[item.itemid] if(not potion) then return false elseif(not isPlayer(itemEx.uid) or (not config.usableOnTarget and cid ~= itemEx.uid)) then return false elseif(hasCondition(cid, CONDITION_EXHAUST)) then doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED) return true elseif(cid ~= itemEx.uid and getDistanceBetween(getThingPos(cid), getThingPos(itemEx.uid)) > 1) then return false end local health, mana = potion.healthPercent, potion.manaPercent if(health ~= nil) then doCreatureAddHealth(itemEx.uid, math.ceil(getCreatureMaxHealth(cid) * (health / 100))) end if(mana ~= nil) then doCreatureAddMana(itemEx.uid, math.ceil(getCreatureMaxMana(cid) * (mana / 100))) end doSendMagicEffect(getThingPos(itemEx.uid), potion.effect) doAddCondition(cid, exhaust) if(config.removeOnUse) then doRemoveItem(item.uid, 1) end return true end Você sabe onde colocar, certo?
Postado Setembro 21, 2015 9 anos Autor local config = { removeOnUse = "yes", usableOnTarget = "yes", -- can be used on target? (fe. healing friend) exhaustedTime = 100 -- time to use again (1000 = 1 second) } config.removeOnUse = getBooleanFromString(config.removeOnUse) config.usableOnTarget = getBooleanFromString(config.usableOnTarget) local POTIONS = { --[item id] = {manaPercent, healthPercent, effect} [2686] = {healthPercent = 20, effect = 13}, -- HP Potion [2692] = {manaPercent = 25, effect = 13}, -- Mana Potion } local exhaust = createConditionObject(CONDITION_EXHAUST) setConditionParam(exhaust, CONDITION_PARAM_TICKS, config.exhaustedTime) function onUse(cid, item, fromPosition, itemEx, toPosition) local potion = POTIONS[item.itemid] if(not potion) then return false elseif(not isPlayer(itemEx.uid) or (not config.usableOnTarget and cid ~= itemEx.uid)) then return false elseif(hasCondition(cid, CONDITION_EXHAUST)) then doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED) return true elseif(cid ~= itemEx.uid and getDistanceBetween(getThingPos(cid), getThingPos(itemEx.uid)) > 1) then return false end local health, mana = potion.healthPercent, potion.manaPercent if(health ~= nil) then doCreatureAddHealth(itemEx.uid, math.ceil(getCreatureMaxHealth(cid) * (health / 100))) end if(mana ~= nil) then doCreatureAddMana(itemEx.uid, math.ceil(getCreatureMaxMana(cid) * (mana / 100))) end doSendMagicEffect(getThingPos(itemEx.uid), potion.effect) doAddCondition(cid, exhaust) if(config.removeOnUse) then doRemoveItem(item.uid, 1) end return true end Você sabe onde colocar, certo? Substituir potions.lua nos actions certo? Vou deixar aqui o script todo editado com todas a potions pra quem quiser, só mudar o valor da porcentagem.: local config = { removeOnUse = "yes", usableOnTarget = "yes", -- can be used on target? (fe. healing friend) exhaustedTime = 100 -- time to use again (1000 = 1 second) } config.removeOnUse = getBooleanFromString(config.removeOnUse) config.usableOnTarget = getBooleanFromString(config.usableOnTarget) local POTIONS = { --[item id] = {manaPercent, healthPercent, effect} [8704] = {healthPercent = 5, effect = 13}, -- small health potion [7618] = {healthPercent = 7, effect = 13}, -- health potion [7588] = {healthPercent = 10, effect = 13}, {level = 50}, vocations = 3, 4, 7, 8, {vocStr = "knights and paladins"}, -- strong health potion [7591] = {healthPercent = 15, effect = 13}, level = 80, vocations = {4, 8}, {vocStr = "knights"}, -- great health potion [8473] = {healthPercent = 20, effect = 13}, level = 130, vocations = {4, 8}, {vocStr = "knights"}, -- ultimate health potion [7620] = {manaPercent = 10, effect = 13}, -- mana Potion [7589] = {manaPercent = 15, effect = 13}, level = 50, vocations = {1, 2, 3, 5, 6, 7}, {vocStr = "sorcerers, druids and paladins"},-- strong mana Potion [7590] = {manaPercent = 20, effect = 13}, level = 80, vocations = {1, 2, 5, 6}, {vocStr = "sorcerers and druids"},-- great mana Potion [8472] = {manaPercent = 20, healthPercent = 20, effect = 13}, level = 80, vocations = {3, 7}, {vocStr = "paladins"}-- great spirit potion } local exhaust = createConditionObject(CONDITION_EXHAUST) setConditionParam(exhaust, CONDITION_PARAM_TICKS, config.exhaustedTime) function onUse(cid, item, fromPosition, itemEx, toPosition) local potion = POTIONS[item.itemid] if(not potion) then return false elseif(not isPlayer(itemEx.uid) or (not config.usableOnTarget and cid ~= itemEx.uid)) then return false elseif(hasCondition(cid, CONDITION_EXHAUST)) then doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED) return true elseif(cid ~= itemEx.uid and getDistanceBetween(getThingPos(cid), getThingPos(itemEx.uid)) > 1) then return false end local health, mana = potion.healthPercent, potion.manaPercent if(health ~= nil) then doCreatureAddHealth(itemEx.uid, math.ceil(getCreatureMaxHealth(cid) * (health / 100))) end if(mana ~= nil) then doCreatureAddMana(itemEx.uid, math.ceil(getCreatureMaxMana(cid) * (mana / 100))) end doSendMagicEffect(getThingPos(itemEx.uid), potion.effect) doAddCondition(cid, exhaust) if(config.removeOnUse) then doRemoveItem(item.uid, 1) end if(((potion.level and getPlayerLevel(itemEx.uid) < potion.level) or (potion.vocations and not isInArray(potion.vocations, getPlayerVocation(itemEx.uid)))) 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 return true end só substituir o arquivo potions.lua na pasta actions Editado Setembro 21, 2015 9 anos por NathanAmaro (veja o histórico de edições)
Postado Setembro 21, 2015 9 anos Substituir potions.lua nos actions certo? Sim, mas tem um porem, o script que fiz é mais simplificado que os tradicionais que vem com o servidor. Ele por exemplo não cria Splash e nem frascos vazios. Se quiser que eu adicione isso só falar.
Postado Setembro 21, 2015 9 anos Autor Sim, mas tem um porem, o script que fiz é mais simplificado que os tradicionais que vem com o servidor. Ele por exemplo não cria Splash e nem frascos vazios. Se quiser que eu adicione isso só falar. Não precisa de vials ou splash, eu tinha desativado no meu antigo script kkk
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.