Thorn
Spriting since 2013
OTX Server Version: (2.52 - 1557)
Hello guys, i have a rebirth npc lua file that i want to change something
the thing i want to change is that when i set manapercent and hp percent (percent of mana/hp you get in lvl 8 from the total of mana/hp you had before doing the rebirth) to 0, a new mana and hp settings are unlocked, where i decide how much they will get in lvl 8 after rebirth.
but what i want is that when players do the rebirth, they start with the lvl 8 normal hp and mana according to their vocation, not the same value for everyone, i dont know if i made myself clear, well i hope you guys can help me, i dont believe it's hard, thanks in advance guys!!!!
Hello guys, i have a rebirth npc lua file that i want to change something
the thing i want to change is that when i set manapercent and hp percent (percent of mana/hp you get in lvl 8 from the total of mana/hp you had before doing the rebirth) to 0, a new mana and hp settings are unlocked, where i decide how much they will get in lvl 8 after rebirth.
but what i want is that when players do the rebirth, they start with the lvl 8 normal hp and mana according to their vocation, not the same value for everyone, i dont know if i made myself clear, well i hope you guys can help me, i dont believe it's hard, thanks in advance guys!!!!
Code:
local config = {
price = 30000, -- Precio del primer rebirth
priceIncrease = 0, -- el precio + rebirths actuales * precio aumentado.
rebirthLevel = 400, -- nivel para el primer rebirth.
rebirthIncrease = 0, -- El numero de rebirth + el actual * Rebirth aumentado.
maxRebirths = 20, -- maximo numero de rebirth que se pueden llegar.
level = 8, -- despues del revirth a que nivel te reseteara.
healthPercent = 0, -- el % de vida despues reset 1.00 = 100%.
health = 100, -- Only used if 'healthPercent' = 0.
manaPercent = 0, -- el % de mana despues reset 1.00 = 100%.
mana = 100, -- Only used if 'manaPercent' = 0.
keepSkills = true, -- true si quieren que el nivel de skill se mantenga.
skillLevel = 10, -- Only used if 'keepSkills' = false.
magicLevel = 0, -- Only used if 'keepSkills' = false.
capacity = 1000, -- la capacidad despues del rebirth a la que te dejara.
capacity = 1000, -- la capacidad despues del rebirth a la que te dejara.
templePos = {x = 1000, y = 1000, z = 7}, -- el lugar al que te enviara despues del reset.
storage = 85987 -- Player storage rebirth count is kept on.
}
local focuses = {}
local function isFocused(cid)
for i, v in pairs(focuses) do
if(v == cid) then
return true
end
end
return false
end
local function addFocus(cid)
if(not isFocused(cid)) then
table.insert(focuses, cid)
end
end
local function removeFocus(cid)
for i, v in pairs(focuses) do
if(v == cid) then
table.remove(focuses, i)
break
end
end
end
local function lookAtFocus()
for i, v in pairs(focuses) do
if(isPlayer(v)) then
doNpcSetCreatureFocus(v)
return
end
end
doNpcSetCreatureFocus(0)
end
function onCreatureDisappear(cid)
if(isFocused(cid)) then
selfSay("Goodbye.")
removeFocus(cid)
end
end
function onCreatureSay(cid, type, msg)
if((msg == "hi") and not (isFocused(cid))) then
selfSay("Bienvenido, ".. getCreatureName(cid) ..".", cid, true)
selfSay("I can {rebirth} you!", cid)
addFocus(cid)
status = 1
elseif((isFocused(cid)) and (msg == "rebirth") and (status == 1)) then
--selfSay("GET=" .. tostring(getCreatureStorage(cid, config.storage)));
--selfSay("MAX=" .. tostring(config.maxRebirths));
if (tostring(getCreatureStorage(cid, config.storage)) == nil) or (tostring(getCreatureStorage(cid, config.storage)) == "") then
storage = 0
rebirthLevel = config.rebirthLevel + (config.rebirthIncrease * storage)
if (getPlayerLevel(cid) >= rebirthLevel) then
money = config.price + (config.priceIncrease * storage)
if (getPlayerMoney(cid) >= money) then
selfSay("Do you want me to rebirth you?", cid)
status = 2
else
selfSay("You need at least " .. money .. " gold before you can rebirth.", cid)
status = 1
end
else
selfSay("You need to be at least level " .. rebirthLevel .. " before you can rebirth.", cid)
status = 1
end
else
if (tonumber(getCreatureStorage(cid, config.storage)) < config.maxRebirths) then
storage = getCreatureStorage(cid, config.storage)
rebirthLevel = config.rebirthLevel + (config.rebirthIncrease * storage)
if (getPlayerLevel(cid) >= rebirthLevel) then
money = config.price + (config.priceIncrease * storage)
if (getPlayerMoney(cid) >= money) then
selfSay("Do you want me to rebirth you?", cid)
status = 2
else
selfSay("You need at least " .. money .. " gold before you can rebirth.", cid)
status = 1
end
else
selfSay("You need to be at least level " .. rebirthLevel .. " before you can rebirth.", cid)
status = 1
end
else
selfSay("It seems you can not rebirth anymore.", cid)
status = 1
end
end
elseif((isFocused(cid)) and (msg == "yes") and (status == 2)) then
selfSay("Ok then i will rebirth you.", cid)
selfSay("You will now be logged out.", cid)
doPlayerRemoveMoney(cid, money)
addEvent(doRebirthPlayer, 2000, {cid=cid})
removeFocus(cid)
elseif((isFocused(cid)) and (msg == "no") and (status == 2)) then
selfSay("Maybe one day you will wise up and change your mind!", cid)
status = 1
elseif((isFocused(cid)) and (msg == "bye" or msg == "goodbye" or msg == "cya")) then
selfSay("Goodbye!", cid, true)
removeFocus(cid)
end
end
function onPlayerCloseChannel(cid)
if(isFocused(cid)) then
selfSay("Goodbye.")
removeFocus(cid)
end
end
function onThink()
for i, focus in pairs(focuses) do
if(not isCreature(focus)) then
removeFocus(focus)
else
local distance = getDistanceTo(focus) or -1
if((distance > 4) or (distance == -1)) then
selfSay("Goodbye.")
removeFocus(focus)
end
end
end
lookAtFocus()
end
function doRebirthPlayer(cid)
cid = cid.cid
if (cid == nil) then
return true
end
local guid = getPlayerGUID(cid)
if (config.healthPercent > 0) then
health = getCreatureMaxHealth(cid) * config.healthPercent
else
health = config.health
end
if (config.manaPercent > 0) then
mana = getCreatureMaxMana(cid) * config.manaPercent
else
mana = config.mana
end
if (getPlayerTown(cid) > 0) then
pos = getTownTemplePosition(getPlayerTown(cid))
else
pos = config.templePos
end
if (tostring(getCreatureStorage(cid, config.storage)) == nil) or (tostring(getCreatureStorage(cid, config.storage)) == "") then
doCreatureSetStorage(cid, config.storage, 1)
else
if (getCreatureStorage(cid, config.storage) == 0) then
doCreatureSetStorage(cid, config.storage, 1)
else
doCreatureSetStorage(cid, config.storage, getCreatureStorage(cid, config.storage) + 1)
end
end
--selfSay("storage1=" .. getCreatureStorage(cid, config.storage))
--if (getCreatureStorage(cid, config.storage) == 0) then
-- doCreatureSetStorage(cid, config.storage, getCreatureStorage(cid, config.storage) + 1)
--end
--selfSay("storage2=" .. getCreatureStorage(cid, config.storage))
doRemoveCreature(cid, true)
db.query("UPDATE `players` SET level = " .. config.level .. " WHERE id = " .. guid .. ";")
db.query("UPDATE `players` SET cap = " .. config.capacity .. " WHERE id = " .. guid .. ";")
db.query("UPDATE `players` SET health = " .. health .. " WHERE id = " .. guid .. ";")
db.query("UPDATE `players` SET healthmax = " .. health .. " WHERE id = " .. guid .. ";")
db.query("UPDATE `players` SET mana = " .. mana .. " WHERE id = " .. guid .. ";")
db.query("UPDATE `players` SET manamax = " .. mana .. " WHERE id = " .. guid .. ";")
db.query("UPDATE `players` SET posx = " .. pos.x .. " WHERE id = " .. guid .. ";")
db.query("UPDATE `players` SET posy = " .. pos.y .. " WHERE id = " .. guid .. ";")
db.query("UPDATE `players` SET posz = " .. pos.z .. " WHERE id = " .. guid .. ";")
if (not config.keepSkills) then
db.query("UPDATE `players` SET maglevel = " .. config.magicLevel .. " WHERE id = " .. guid .. ";")
db.query("UPDATE `player_skills` SET value = " .. config.skillLevel .. " WHERE id = " .. guid .. ";")
end
return true
end
--npcHandler:addModule(FocusModule:new())
Last edited: