Hello guys i am new to scripting and am still learning. I wrote this script with onAdvance level 50 the player receives a reward based on his vocation. For people that are looking for that instead of giving 1 reward. Also can be increase the level etc in config. It should work although i haven't tested it <_<
Lua:
function onAdvance(cid, skill, oldLevel, newLevel)
local setup = {
level = 50, -- level to receive items.
message = "Congratulations on advancing to level 50 here is your reward.", -- The message they will receive.
effectID = 61 -- ID of the effect that will appear on the character.
storage = 1337 -- storage value to store information.
}
if skill == SKILL__LEVEL and newLevel < setup.level then
doPlayerSendTextMessage("Congratulations on leveling your brand new character! You are now level ".. getPlayerLevel(cid) .."!"
return true
end
if getPlayerStorageValue(cid, storage) ~= 1 then
return true
end
local p = getPlayerPosition(cid)
local positions = {
{ position= {x=p.x+1,y=p.y,z=p.z}, delay = 100},
{ position= {x=p.x+1,y=p.y+1,z=p.z}, delay = 200},
{ position= {x=p.x,y=p.y+1,z=p.z}, delay = 300},
{ position= {x=p.x-1,y=p.y+1,z=p.z}, delay = 400},
{ position= {x=p.x-1,y=p.y,z=p.z}, delay = 500},
{ position= {x=p.x-1,y=p.y-1,z=p.z}, delay = 600},
{ position= {x=p.x,y=p.y-1,z=p.z}, delay = 700},
{ position= {x=p.x+1,y=p.y-1,z=p.z}, delay = 800}
for i = 1, 8 do
addEvent(doSendDistanceShoot, positions[i].delay, positions[i].position, p, setup.effectID)
end
local vocations = {
sorcerer = 1,
druid = 2,
paladin = 3,
knight = 4,
msorcerer = 5,
edruid = 6,
rpaladin = 7,
eknight = 8
}
local backpack = doPlayerAddItem(cid, 1988, 1)
if getPlayerVocation(cid) == vocations.sorcerer or getPlayerVocation(cid) == vocations.druid or getPlayerVocation(cid) == vocations.msorcerer or getPlayerVocation(cid) == vocations.edruid then
doAddContainerItem(backpack, 2160, 5)
doAddContainerItem(backpack, 7589, 50)
doPlayerSendTextMessage(cid, setup.message)
doSetPlayerStorageValue(cid, storage, 1)
end
elseif getPlayerVocation(cid) == vocations.paladin or getPlayerVocation(cid) == vocations.rpaladin then
doAddContainerItem(backpack, 2160, 5)
doAddContainerItem(backpack, 7588, 50)
doPlayerSendTextMessage(cid, setup.message)
doSetPlayerStorageValue(cid, storage, 1)
end
elseif getPlayerVocation(cid) == vocations.knight or getPlayerVocation(cid) == vocations.eknight then
doAddContainerItem(backpack, 2160, 5)
doAddContainerItem(backpack, 7588, 50)
doPlayerSendTextMessage(cid, setup.message)
doSetPlayerStorageValue(cid, storage, 1)
end
return true
end