Oh, didn't think about it.
I will do that, thanks
local config = {
savePlayer = true, --Save Player When The Gain Level!
healPlayerOnLevel = true, --heal health/mana full
getServerVersionUnder860 = true, --If the server is 860 and lower than that, leave it true! If its over 860, use false!
levelText = "LEVEL UP!" --Gain Level Text!
}
local vocations = {
["Sorcerer"] = {item = 1111, count = 1, level = 50, storage = 3000},
["Master Sorcerer"] = {item = 1111, count = 1, level = 50, storage = 3001},
["Druid"] = {item = 1111, count = 1, level = 50, storage = 3002},
["Elder Druid"] = {item = 1111, count = 1, level = 50, storage = 3003},
["Paladin"] = {item = 1111, count = 1, level = 50, storage = 3004},
["RoyalPaladin"] = {item = 1111, count = 1, level = 50, storage = 3005},
["Knight"] = {item = 1111, count = 1, level = 50, storage = 3006},
["Elite Knight"] = {item = 1111, count = 1, level = 50, storage = 3007}
}
function onAdvance(cid, skill, oldLevel, newLevel)
if(skill == SKILL__EXPERIENCE) then
return true
end
if(newLevel < oldLevel)then return true end
if config.getServerVersionUnder860 then
VOC = vocations(getPlayerVocation(cid))
else
VOC = vocations(player:getVocation():getName())
end
if not VOC then return false end
if(skill == SKILL__LEVEL) then
if config.getServerVersionUnder860 and config.healPlayerOnLevel == true then
if player:getlevel(cid) == VOC.level then
doCreatureAddHealth(cid, getCreatureMaxHealth(cid) - getCreatureHealth(cid))
doCreatureAddMana(cid, getCreatureMaxMana(cid) - getCreatureMana(cid))
doSendAnimatedText(getCreaturePosition(cid), config.levelText, math.random(1,255))
doSendMagicEffect(getPlayerPosition(cid), math.random(25, 28))
doPlayerAddItem(cid, VOC.item, VOC.count)
setPlayerStorageValue(cid, VOC.storage, 1)
if config.savePlayer then
doPlayerSave(cid)
end
end
elseif config.getServerVersionUnder860 == false and config.healPlayerOnLevel == true then
player = Player(cid)
if player:getLevel() == VOC.level and player:getStorageValue(VOC.storage) < 1 then
player:addHealth(player:getHealthMax())
player:addMana(player:getManaMax())
doCreatureSay(cid,config.levelText,TALKTYPE_ORANGE_1)
doSendMagicEffect(player:getPosition(), math.random(25, 28))
player:addItem(VOC.item, VOC.count)
player:setStorageValue(VOC.storage, 1)
if config.savePlayer then
player:save()
end
end
end
end
return true
end
local config = {
savePlayer = true, --Save Player When The Gain Level!
healPlayerOnLevel = true, --Heal Players Hp And Mana On Level!
effectOnLevel = true, --Fireworks Effect On Level!
getServerVersionUnder860 = true, --If the server is 860 and lower than that, leave it true! If its over 860, use false!
levelText = "LEVEL UP!", --Gain Level Text!
Sorcerer = {
Vocsid = {1,5}, --Vocs id for Wizards
[13] = {item = 2191, count = 1, storage = 3000}, --Wand of Dragonbreath--
[19] = {item = 2188, count = 1, storage = 3001}, --Wand of Decay--
[20] = {item = 2160, count = 1, storage = 3002}, --1cc--
[22] = {item = 8921, count = 1, storage = 3003}, --Wand of Draconia--
[26] = {item = 2189, count = 1, storage = 3004}, --Wand of Cosmic Energy--
[33] = {item = 2187, count = 1, storage = 3005}, --Wand of Inferno--
[37] = {item = 8920, count = 1, storage = 3006}, --Wand of Starstorm--
[40] = {item = 2160, count = 3, storage = 3007} --3cc--
},
Druid = {
Vocsid = {2,6}, --Vocs id for Mages
[13] = {item = 2186, count = 1, storage = 3000}, --Moonlight Rod--
[19] = {item = 2185, count = 1, storage = 3001}, --Necrotic Rod--
[20] = {item = 2160, count = 1, storage = 3002}, --1cc--
[22] = {item = 8911, count = 1, storage = 3003}, --Northwind Rod--
[26] = {item = 2181, count = 1, storage = 3004}, --Terra Rod--
[33] = {item = 2183, count = 1, storage = 3005}, --Hailstorm Rod--
[37] = {item = 8912, count = 1, storage = 3006}, --Springsprout Rod--
[40] = {item = 2160, count = 3, storage = 3007} --3cc--
},
Paladin = {
Vocsid = {3,7}, --Vocs id for Rangers
[19] = {item = 3965, count = 1, storage = 3000}, --Hunting Spear--
[20] = {item = 2160, count = 1, storage = 3001}, --1cc--
[40] = {item = 2160, count = 3, storage = 3002} --3cc--
},
Knight = {
Vocsid = {4,8}, --Vocs id for Warriors
[20] = {item = 2160, count = 1, storage = 3000}, --1cc--
[40] = {item = 2160, count = 3, storage = 3001} --3cc--
},
}
function onAdvance(cid, skill, oldLevel, newLevel)
if(skill == SKILL__EXPERIENCE) then
return true
end
if(newLevel < oldLevel)then return true end
if(skill == SKILL__LEVEL and config.healPlayerOnLevel) then
doCreatureAddHealth(cid, getCreatureMaxHealth(cid) - getCreatureHealth(cid))
doCreatureAddMana(cid, getCreatureMaxMana(cid) - getCreatureMana(cid))
doSendMagicEffect(getCreaturePosition(cid), math.random(28, 30))
if config.getServerVersionUnder860 then
doSendAnimatedText(getCreaturePosition(cid), config.levelText, math.random(1,255))
else
doCreatureSay(cid,config.levelText,TALKTYPE_ORANGE_1)
end
end
if(config.savePlayer) then
doPlayerSave(cid, true)
end
local sorc,druid,pally,knight = config.Sorcerer[getPlayerLevel(cid)],config.Druid[getPlayerLevel(cid)],config.Paladin[getPlayerLevel(cid)],config.Knight[getPlayerLevel(cid)]
if (isInArray(config.Sorcerer.Vocsid, getPlayerVocation(cid)) or isInArray(config.Druid.Vocsid, getPlayerVocation(cid)) or isInArray(config.Paladin.Vocsid, getPlayerVocation(cid)) or isInArray(config.Knight.Vocsid, getPlayerVocation(cid))) then
if (sorc and isInArray(config.Sorcerer.Vocsid, getPlayerVocation(cid)) and (getPlayerStorageValue(cid,sorc.storage) == -1)) then
doPlayerAddItem(cid,sorc.item,sorc.count)
setPlayerStorageValue(cid,sorc.storage,1)
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have recived "..sorc.count.."x "..getItemNameById(sorc.item).."." )
elseif (druid and isInArray(config.Druid.Vocsid, getPlayerVocation(cid)) and (getPlayerStorageValue(cid,druid.storage) == -1)) then
doPlayerAddItem(cid,druid.item,druid.count)
setPlayerStorageValue(cid,druid.storage,1)
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have recived "..druid.count.."x "..getItemNameById(druid.item).."." )
elseif (pally and isInArray(config.Paladin.Vocsid, getPlayerVocation(cid)) and (getPlayerStorageValue(cid,pally.storage) == -1)) then
doPlayerAddItem(cid,pally.item,pally.count)
setPlayerStorageValue(cid,pally.storage,1)
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have recived "..pally.count.."x "..getItemNameById(pally.item).."." )
elseif (knight and isInArray(config.Knight.Vocsid, getPlayerVocation(cid)) and (getPlayerStorageValue(cid,knight.storage) == -1)) then
doPlayerAddItem(cid,knight.item,knight.count)
setPlayerStorageValue(cid,knight.storage,1)
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have recived "..knight.count.."x "..getItemNameById(knight.item).."." )
end
else
print("Your vocation id doesn't exsist: "..getPlayerVocation(cid)..".")
end
return true
end
@Itutorial's one is not working for TFS 0.4. Found solution to previous scripts, the mistake are in:
Wrong:
"(getPlayerStorageValue(cid,config.Sorcerer.storage)", "setPlayerStorageValue(cid, config.sorc.storage,1)".
Correct:
(getPlayerStorageValue(cid,sorc.storage), setPlayerStorageValue(cid,sorc.storage,1).
Need changes for all vocations, full "levelup.lua" should be like this:
Lua:local config = { savePlayer = true, --Save Player When The Gain Level! healPlayerOnLevel = true, --Heal Players Hp And Mana On Level! effectOnLevel = true, --Fireworks Effect On Level! getServerVersionUnder860 = true, --If the server is 860 and lower than that, leave it true! If its over 860, use false! levelText = "LEVEL UP!", --Gain Level Text! Sorcerer = { Vocsid = {1,5}, --Vocs id for Wizards [13] = {item = 2191, count = 1, storage = 3000}, --Wand of Dragonbreath-- [19] = {item = 2188, count = 1, storage = 3001}, --Wand of Decay-- [20] = {item = 2160, count = 1, storage = 3002}, --1cc-- [22] = {item = 8921, count = 1, storage = 3003}, --Wand of Draconia-- [26] = {item = 2189, count = 1, storage = 3004}, --Wand of Cosmic Energy-- [33] = {item = 2187, count = 1, storage = 3005}, --Wand of Inferno-- [37] = {item = 8920, count = 1, storage = 3006}, --Wand of Starstorm-- [40] = {item = 2160, count = 3, storage = 3007} --3cc-- }, Druid = { Vocsid = {2,6}, --Vocs id for Mages [13] = {item = 2186, count = 1, storage = 3000}, --Moonlight Rod-- [19] = {item = 2185, count = 1, storage = 3001}, --Necrotic Rod-- [20] = {item = 2160, count = 1, storage = 3002}, --1cc-- [22] = {item = 8911, count = 1, storage = 3003}, --Northwind Rod-- [26] = {item = 2181, count = 1, storage = 3004}, --Terra Rod-- [33] = {item = 2183, count = 1, storage = 3005}, --Hailstorm Rod-- [37] = {item = 8912, count = 1, storage = 3006}, --Springsprout Rod-- [40] = {item = 2160, count = 3, storage = 3007} --3cc-- }, Paladin = { Vocsid = {3,7}, --Vocs id for Rangers [19] = {item = 3965, count = 1, storage = 3000}, --Hunting Spear-- [20] = {item = 2160, count = 1, storage = 3001}, --1cc-- [40] = {item = 2160, count = 3, storage = 3002} --3cc-- }, Knight = { Vocsid = {4,8}, --Vocs id for Warriors [20] = {item = 2160, count = 1, storage = 3000}, --1cc-- [40] = {item = 2160, count = 3, storage = 3001} --3cc-- }, } function onAdvance(cid, skill, oldLevel, newLevel) if(skill == SKILL__EXPERIENCE) then return true end if(newLevel < oldLevel)then return true end if(skill == SKILL__LEVEL and config.healPlayerOnLevel) then doCreatureAddHealth(cid, getCreatureMaxHealth(cid) - getCreatureHealth(cid)) doCreatureAddMana(cid, getCreatureMaxMana(cid) - getCreatureMana(cid)) doSendMagicEffect(getCreaturePosition(cid), math.random(28, 30)) if config.getServerVersionUnder860 then doSendAnimatedText(getCreaturePosition(cid), config.levelText, math.random(1,255)) else doCreatureSay(cid,config.levelText,TALKTYPE_ORANGE_1) end end if(config.savePlayer) then doPlayerSave(cid, true) end local sorc,druid,pally,knight = config.Sorcerer[getPlayerLevel(cid)],config.Druid[getPlayerLevel(cid)],config.Paladin[getPlayerLevel(cid)],config.Knight[getPlayerLevel(cid)] if (isInArray(config.Sorcerer.Vocsid, getPlayerVocation(cid)) or isInArray(config.Druid.Vocsid, getPlayerVocation(cid)) or isInArray(config.Paladin.Vocsid, getPlayerVocation(cid)) or isInArray(config.Knight.Vocsid, getPlayerVocation(cid))) then if (sorc and isInArray(config.Sorcerer.Vocsid, getPlayerVocation(cid)) and (getPlayerStorageValue(cid,sorc.storage) == -1)) then doPlayerAddItem(cid,sorc.item,sorc.count) setPlayerStorageValue(cid,sorc.storage,1) doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have recived "..sorc.count.."x "..getItemNameById(sorc.item).."." ) elseif (druid and isInArray(config.Druid.Vocsid, getPlayerVocation(cid)) and (getPlayerStorageValue(cid,druid.storage) == -1)) then doPlayerAddItem(cid,druid.item,druid.count) setPlayerStorageValue(cid,druid.storage,1) doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have recived "..druid.count.."x "..getItemNameById(druid.item).."." ) elseif (pally and isInArray(config.Paladin.Vocsid, getPlayerVocation(cid)) and (getPlayerStorageValue(cid,pally.storage) == -1)) then doPlayerAddItem(cid,pally.item,pally.count) setPlayerStorageValue(cid,pally.storage,1) doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have recived "..pally.count.."x "..getItemNameById(pally.item).."." ) elseif (knight and isInArray(config.Knight.Vocsid, getPlayerVocation(cid)) and (getPlayerStorageValue(cid,knight.storage) == -1)) then doPlayerAddItem(cid,knight.item,knight.count) setPlayerStorageValue(cid,knight.storage,1) doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have recived "..knight.count.."x "..getItemNameById(knight.item).."." ) end else print("Your vocation id doesn't exsist: "..getPlayerVocation(cid)..".") end return true end
Could anybody more experienced shorten the code, please?
local config = {
savePlayer = true, --Save Player When The Gain Level!
healPlayerOnLevel = true, --Heal Players Hp And Mana On Level!
getServerVersionUnder860 = true, --If the server is 860 and lower than that, leave it true! If its over 860, use false!
levelText = "LEVEL UP!", --Gain Level Text!
vocations = {
-- sorcerer
[{1, 5}] = {
[13] = {item = 2191, count = 1, storage = 3000}, --Wand of Dragonbreath--
[19] = {item = 2188, count = 1, storage = 3001}, --Wand of Decay--
[20] = {item = 2160, count = 1, storage = 3002}, --1cc--
[22] = {item = 8921, count = 1, storage = 3003}, --Wand of Draconia--
[26] = {item = 2189, count = 1, storage = 3004}, --Wand of Cosmic Energy--
[33] = {item = 2187, count = 1, storage = 3005}, --Wand of Inferno--
[37] = {item = 8920, count = 1, storage = 3006}, --Wand of Starstorm--
[40] = {item = 2160, count = 3, storage = 3007} --3cc--
},
-- druid
[{2, 6}] = {
[13] = {item = 2186, count = 1, storage = 3000}, --Moonlight Rod--
[19] = {item = 2185, count = 1, storage = 3001}, --Necrotic Rod--
[20] = {item = 2160, count = 1, storage = 3002}, --1cc--
[22] = {item = 8911, count = 1, storage = 3003}, --Northwind Rod--
[26] = {item = 2181, count = 1, storage = 3004}, --Terra Rod--
[33] = {item = 2183, count = 1, storage = 3005}, --Hailstorm Rod--
[37] = {item = 8912, count = 1, storage = 3006}, --Springsprout Rod--
[40] = {item = 2160, count = 3, storage = 3007} --3cc--
},
-- paladin
[{3, 7}] = {
[19] = {item = 3965, count = 1, storage = 3000}, --Hunting Spear--
[20] = {item = 2160, count = 1, storage = 3001}, --1cc--
[40] = {item = 2160, count = 3, storage = 3002} --3cc--
},
-- knight
[{4, 8}] = {
[20] = {item = 2160, count = 1, storage = 3000}, --1cc--
[40] = {item = 2160, count = 3, storage = 3001} --3cc--
}
}
}
local function rewardPlayer(cid, reward)
doPlayerAddItem(cid, reward.item, reward.count)
setPlayerStorageValue(cid, reward.storage, 1)
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have recived ".. reward.count .."x "..getItemNameById(reward.item)..".")
end
function onAdvance(cid, skill, oldLevel, newLevel)
if skill ~= SKILL__LEVEL then
return true
end
local pos = getCreaturePosition(cid)
local voc = getPlayerVocation(cid)
local level = getPlayerLevel(cid)
-- send level text
if config.getServerVersionUnder860 then
doCreatureSay(cid, config.levelText, TALKTYPE_ORANGE_1)
else
doSendAnimatedText(pos, config.levelText)
end
-- heal player if enabled in config
if config.healPlayerOnLevel then
doCreatureAddHealth(cid, getCreatureMaxHealth(cid) - getCreatureHealth(cid))
doCreatureAddMana(cid, getCreatureMaxMana(cid) - getCreatureMana(cid))
doSendMagicEffect(pos, math.random(28, 30))
end
-- save player if enabled in config
if config.savePlayer then
doPlayerSave(cid, true)
end
-- reward the player if possible
for k, v in pairs(config.vocations) do
if isInArray(k, voc) then
local reward = v[level]
if not reward or getPlayerStorageValue(cid, reward.storage) == 1 then
return true
end
rewardPlayer(cid, reward)
end
end
return true
end
Lua:local config = { savePlayer = true, --Save Player When The Gain Level! healPlayerOnLevel = true, --Heal Players Hp And Mana On Level! effectOnLevel = true, --Fireworks Effect On Level! getServerVersionUnder860 = true, --If the server is 860 and lower than that, leave it true! If its over 860, use false! levelText = "LEVEL UP!", --Gain Level Text! vocations = { -- sorcerer [{1, 5}] = { [13] = {item = 2191, count = 1, storage = 3000}, --Wand of Dragonbreath-- [19] = {item = 2188, count = 1, storage = 3001}, --Wand of Decay-- [20] = {item = 2160, count = 1, storage = 3002}, --1cc-- [22] = {item = 8921, count = 1, storage = 3003}, --Wand of Draconia-- [26] = {item = 2189, count = 1, storage = 3004}, --Wand of Cosmic Energy-- [33] = {item = 2187, count = 1, storage = 3005}, --Wand of Inferno-- [37] = {item = 8920, count = 1, storage = 3006}, --Wand of Starstorm-- [40] = {item = 2160, count = 3, storage = 3007} --3cc-- }, -- druid [{2, 6}] = { [13] = {item = 2186, count = 1, storage = 3000}, --Moonlight Rod-- [19] = {item = 2185, count = 1, storage = 3001}, --Necrotic Rod-- [20] = {item = 2160, count = 1, storage = 3002}, --1cc-- [22] = {item = 8911, count = 1, storage = 3003}, --Northwind Rod-- [26] = {item = 2181, count = 1, storage = 3004}, --Terra Rod-- [33] = {item = 2183, count = 1, storage = 3005}, --Hailstorm Rod-- [37] = {item = 8912, count = 1, storage = 3006}, --Springsprout Rod-- [40] = {item = 2160, count = 3, storage = 3007} --3cc-- }, -- paladin [{3, 7}] = { [19] = {item = 3965, count = 1, storage = 3000}, --Hunting Spear-- [20] = {item = 2160, count = 1, storage = 3001}, --1cc-- [40] = {item = 2160, count = 3, storage = 3002} --3cc-- }, -- knight [{4, 8}] = { [20] = {item = 2160, count = 1, storage = 3000}, --1cc-- [40] = {item = 2160, count = 3, storage = 3001} --3cc-- } } } local function rewardPlayer(cid, reward) doPlayerAddItem(cid, reward.item, reward.count) setPlayerStorageValue(cid, reward.storage, 1) doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have recived ".. reward.count .."x "..getItemNameById(reward.item)..".") end function onAdvance(cid, skill, oldLevel, newLevel) if skill ~= SKILL__LEVEL then return true end -- send level text if config.getServerVersionUnder860 then doCreatureSay(cid, config.levelText, TALKTYPE_ORANGE_1) else doSendAnimatedText(getCreaturePosition(cid), config.levelText) end -- reward the player if possible local voc = getPlayerVocation(cid) local level = getPlayerLevel(cid) for k, v in pairs(config.vocations) do if isInArray(k, voc) then local reward = v[level] if not reward or getPlayerStorageValue(cid, reward.storage) == 1 then return true end rewardPlayer(cid, reward) end end return true end
i know, i reported my post for a mod to replace the code with a pastebin link because i didn't want to double post.Doesn't support:
save player
heal player on level
effect on level