• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Exp 'scroll' / item.

Bam

Active Member
Joined
Aug 11, 2007
Messages
1,446
Reaction score
39
Location
Sweden
I use a script but it doesnt seem to work with my TFS 0.3.4.

It says the "yey exp" thingy but it wont remove the item nor give me exp.

LUA:
local config = {
funnyEffect = "YES", -- effects fireworks & Animated Text  (YES/NO) 
minimumLevel = 1,
maximumLevel = 200, -- for infinite type math.huge
}
local addExp = {
[{config.minimumLevel, 1}] = 15000000,
[{100, 150}] = 5000000,
[{150, config.maximumLevel}] = 3000000
}
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 scroll.")
        return FALSE 
    end
    
    if level >= config.maximumLevel then
        doPlayerSendCancel(cid, "Your level is too high for using a scroll.")
        return FALSE 
    end

    for k, v in pairs(addExp) do 
        if level >= k[1] and level < k[2] then 
            doPlayerAddExp(cid, v)
            doRemoveItem(item.uid, 1)
            break 
        end 
    end  

        if config.funnyEffect == "YES" then
        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(getThingPos(cid), "Yeah! Exp!", TEXTCOLOR_RED) 
            doSendMagicEffect(positions[i],effect)
        end
    end
    return TRUE 
end
experience.lua


XML:
    <action itemid="5785" script="experience.lua"/>
actions.xml



Any ideas?
 
Last edited by a moderator:
Not Work i can't Click on it :S:S
I've tested your script with 0.3.6pl and it worked fine except the experience. I didn't get any experience but if you do it like this it works fine,...

XML:
<action itemid="5957" event="script" value="special/funny.lua" />

LUA:
local config = {
funnyEffect = "YES", -- effects fireworks & Animated Text  (YES/NO) 
minimumLevel = 1,
maximumLevel = 200, -- for infinite type math.huge
}

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 scroll.")
        return FALSE 
    end
 
    if level >= config.maximumLevel then
        doPlayerSendCancel(cid, "Your level is too high for using a scroll.")
        return FALSE 
    end
 

            doPlayerAddExp(cid, 24000)
            doRemoveItem(item.uid, 1)

 
        if config.funnyEffect == "YES" then
        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(getThingPos(cid), "Yeah! Exp!", TEXTCOLOR_RED) 
            doSendMagicEffect(positions[i],effect)
        end
    end
    return TRUE 
end
 
Back
Top