- Joined
- Feb 14, 2015
- Messages
- 5,643
- Solutions
- 559
- Reaction score
- 3,949
This is a Talkaction that auto calculates the HP/MP for the vocation id you choose, and sets it to the player.
Probably not useful to many people, but maybe someone will need it so I'll just throw it here.
Note: If you have a prestige system, put this script in your login.lua
Usage: /adjust Playername, VocationID
Probably not useful to many people, but maybe someone will need it so I'll just throw it here.
Note: If you have a prestige system, put this script in your login.lua
Code:
if getPlayerStorageValue(cid, 85987) == -1 then
doPlayerSetStorageValue(cid, 85987, 0)
end
Usage: /adjust Playername, VocationID
Code:
<talkaction log="yes" words="/adjust" access="6" event="script" value="Adjust.lua"/>
Code:
function onSay(cid, words, param)
local t = string.explode(param, ",")
local NewID = tonumber(t[2])
-- Get Player Name --
local Player = getPlayerByNameWildcard(t[1])
-- Config --
local Config = {
Prestige_Level = 3250, -- What is the required level to prestige?
Storage = 85987, -- What storage do you use for prestige?
Base_Health = 185, -- What health do you have when you login to a new character?
Base_Mana = 35, -- What mana do you have when you login to a new character?
Textcolor = TEXTCOLOR_LIGHTGREEN,
Effect = 14,
}
-- Get Player Attributes --
local Get = {
Health = getCreatureMaxHealth(Player),
Mana = getCreatureMaxMana(Player),
Level = getPlayerLevel(Player),
Prestige = getPlayerStorageValue(Player, Config.Storage),
Position = getCreaturePosition(Player),
Vocation_Info = getVocationInfo(NewID),
Position = getCreaturePosition(Player),
}
-- Health/Mana Calculations (DONT TOUCH) --
local Formulas = {
Health_Formula = ((Config.Base_Health + (Get.Vocation_Info.healthGain * Get.Level))),
Mana_Formula = ((Config.Base_Mana + (Get.Vocation_Info.manaGain * Get.Level))),
Prestige_Health_Formula = ((Config.Base_Health + (Get.Vocation_Info.healthGain * Get.Level)) + (Get.Vocation_Info.healthGain * Config.Prestige_Level) * Get.Prestige),
Prestige_Mana_Formula = ((Config.Base_Mana + (Get.Vocation_Info.manaGain * Get.Level)) + (Get.Vocation_Info.manaGain * Config.Prestige_Level) * Get.Prestige)
}
if(param == "") then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Name and vocation required.")
return true
end
if(not t[2]) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need to add a comma, then the vocation id to adjust.")
end
if Get.Vocation_Info.id ~= NewID then
doPlayerSendTextMessage(Player, MESSAGE_STATUS_CONSOLE_RED, "Incorrect Vocation ID.")
return true
end
if Get.Vocation_Info.id == NewID then
if Get.Prestige > 0 then
doPlayerSetVocation(Player, NewID)
setCreatureMaxHealth(Player, Formulas.Prestige_Health_Formula)
doCreatureAddHealth(Player, Get.Health)
setCreatureMaxMana(Player, Formulas.Prestige_Mana_Formula)
doCreatureAddMana(Player, Get.Mana)
doSendMagicEffect(Get.Position, Config.Effect)
doSendAnimatedText(Get.Position, "Adjust", Config.Textcolor)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "".. getCreatureName(Player) .." has prestiged, using prestige calculations.")
doPlayerSendTextMessage(Player, MESSAGE_INFO_DESCR,"[HP] Adjusted to ".. Formulas.Prestige_Health_Formula .."\n[MP] Adjusted to ".. Formulas.Prestige_Mana_Formula .."\n[Vocation] Adjusted to ".. Get.Vocation_Info.name ..".")
elseif Get.Prestige <= 0 then
doPlayerSetVocation(Player, NewID)
setCreatureMaxHealth(Player, Formulas.Health_Formula)
doCreatureAddHealth(Player, Get.Health)
setCreatureMaxMana(Player, Formulas.Mana_Formula)
doCreatureAddMana(Player, Get.Mana)
doSendMagicEffect(Get.Position, Config.Effect)
doSendAnimatedText(Get.Position, "Adjust", Config.Textcolor)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "".. getCreatureName(Player) .." has not prestiged, using normal calculations.")
doPlayerSendTextMessage(Player, MESSAGE_INFO_DESCR,"[HP] Adjusted to ".. Formulas.Health_Formula .."\n[MP] Adjusted to ".. Formulas.Mana_Formula .."\n[Vocation] Adjusted to ".. Get.Vocation_Info.name ..".")
end
end
return true
end
Last edited: