T
tejdi
Guest
I need scripts that:
1. When the player dies, resets all skills and magic levels to values predefined in the database.
(each player has its own values).
2. When the player dies, equipment resets to predefined in the database[?] - I am not sure if I should add tables to the
3. Removes body after the player dies.
(there shouldn't be a body on the ground or just a body without loot, whatever is simpler)
--
Ad. 1.
I was able to solve it. For anyone who would like to have it:
login.lua (above return true):
Remember to add skill_shielding_base, skill_dist_base, skill_club_base, maglevel_base to your database before.
--
Ad. 3.
I was also able to solve this one. If you also need it:
Add to playerdeath.lua above
This:
1. When the player dies, resets all skills and magic levels to values predefined in the database.
(each player has its own values).
SQL:
player -> maglevel_base / skill_club_base / skill_dist_base / skill_shielding_base
2. When the player dies, equipment resets to predefined in the database[?] - I am not sure if I should add tables to the
player
with basic equipment IDs or there is a better way to do that.3. Removes body after the player dies.
(there shouldn't be a body on the ground or just a body without loot, whatever is simpler)
Post automatically merged:
--
Ad. 1.
I was able to solve it. For anyone who would like to have it:
login.lua (above return true):
Lua:
-- Skills
local shieldingBase = db.storeQuery("SELECT `skill_shielding_base` FROM `players` WHERE `name` = '" .. player:getName() .. "';")
local distanceBase = db.storeQuery("SELECT `skill_dist_base` FROM `players` WHERE `name` = '" .. player:getName() .. "';")
local meleeBase = db.storeQuery("SELECT `skill_club_base` FROM `players` WHERE `name` = '" .. player:getName() .. "';")
local magicBase = db.storeQuery("SELECT `maglevel_base` FROM `players` WHERE `name` = '" .. player:getName() .. "';")
-- Shielding
if player:getSkillLevel(5) < shieldingBase then
player:addSkillTries(5, player:getVocation():getRequiredSkillTries(5, player:getSkillLevel(5) + 1) - player:getSkillTries(5))
end
-- Distance
if player:getSkillLevel(4) < distanceBase then
player:addSkillTries(4, player:getVocation():getRequiredSkillTries(4, player:getSkillLevel(4) + 1) - player:getSkillTries(4))
end
-- Melee
if player:getSkillLevel(1) < meleeBase then
player:addSkillTries(1, player:getVocation():getRequiredSkillTries(1, player:getSkillLevel(1) + 1) - player:getSkillTries(1))
end
-- Magic
if player:getSkillLevel(1) < magicBase then
player:addManaSpent(player:getVocation():getRequiredManaSpent(player:getBaseMagicLevel() + 1) - player:getManaSpent())
end
Remember to add skill_shielding_base, skill_dist_base, skill_club_base, maglevel_base to your database before.
--
Ad. 3.
I was also able to solve this one. If you also need it:
Add to playerdeath.lua above
Lua:
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You are dead.")
This:
Lua:
-- all slots to look for
local slots = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
-- cycle through the slots table and store the slot id in slot
for _, slot in pairs(slots) do
-- get the player's slot item and store it in item
local item = player:getSlotItem(slot)
-- if the item exists meaning its not nil then continue
if item then
-- if it exists then remove the item
item:remove()
end
end
Last edited by a moderator: