OTlanders Hello, First I need a script that will give the possiblity to gain maximum 40 level when a player has storagevalue = 9645, and if player don't have this storagevalue he can gain max 30 level then he won't gain experience from monsters. The second request: Please edit this script:
to work as the script above - player with storage can use this item from level 1 to 40, while player without storage can use it from 1 to 30 level.
Code:
local config = {
funnyEffect = "YES",
minimumLevel = 13,
maximumLevel = 30, -- for infinite type math.huge
}
local addExp = {
[{config.minimumLevel, 15}] = 1500,
[{15, 17}] = 900,
[{17, 20}] = 600,
[{20, 25}] = 500,
[{25, config.maximumLevel}] = 400
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local level = getPlayerLevel(cid)
local effect = math.random(CONST_ME_FIREWORK_YELLOW,CONST_ME_FIREWORK_BLUE)
if level < config.minimumLevel then
doPlayerSendCancel(cid, "You need to be at least "..config.minimumLevel.." to use a experience egg.")
return FALSE
end
if level >= config.maximumLevel then
doPlayerSendCancel(cid, "Your level is too high for using a experience egg.")
return FALSE
end
for k, v in pairs(addExp) do
if level >= k[1] and level < k[2] then
doPlayerAddExp(cid, v)
doPlayerSendTextMessage(cid, 22, "Experience egg Gave You " .. v .." experience!")
doRemoveItem(item.uid, 1)
break
end
end
if config.funnyEffect == "YES" then
local playerexp = addExp
local pos = getPlayerPosition(cid)
local positions = {
{x=pos.x+1,y=pos.y-1,z=pos.z},
{x=pos.x-1,y=pos.y-1,z=pos.z},
{x=pos.x+1,y=pos.y+1,z=pos.z},
{x=pos.x-1,y=pos.y+1,z=pos.z},
{x=pos.x+1,y=pos.y,z=pos.z},
{x=pos.x-1,y=pos.y,z=pos.z},
{x=pos.x,y=pos.y+1,z=pos.z},
{x=pos.x,y=pos.y-1,z=pos.z}
}
for i = 1, table.getn(positions) do
doSendAnimatedText(getPlayerPosition(cid), playerexp, TEXTCOLOR_RED)
doSendMagicEffect(positions[i],effect)
end
end
return TRUE
end