• 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!

Advanced Exp Ticket

Saint

New Member
Joined
Jun 16, 2007
Messages
231
Reaction score
1
Location
Łódź, Poland
Hello,

I'd like you to make advanced exp ticket. What should the script do?

- It should check whether player has level higher than 200. If no it should give 1,000,000 exp else 500,000 exp.
- It should send magic effect (doesn't matter which you will choose)
- It should send the message to player like "CONGRATULATIONS! <ammount of exp> exp has been given to you!"

Thanks in advance.

/Saint.
 
Easy lol

expticket.lua:
Code:
function onUse(cid, item, toPos, item2, fromPos)
    local levelReq = 200
    local expHigh = 1000000
    local expLow = 500000
    local tmp = getCreaturePosition(cid)
    if getPlayerLevel(cid) >= levelReq then
        doPlayerAddExp(cid, expLow)
        doPlayerSendTextMessage(cid, 25, "CONGRATULATIONS! "..expLow.." exp has been given to you!")
    else
        doPlayerAddExp(cid, expHigh)
        doPlayerSendTextMessage(cid, 25, "CONGRATULATIONS! "..expHigh.." exp has been given to you!")
    end
    doPlayerSendMagicEffect(tmp, CONST_ME_MAGIC_RED)
    return TRUE
end

Put in actions.xml either (where XXXX = itemid of ticket)
Code:
<action itemid="XXXX" script="expticket.lua"/>

Or
Code:
<action itemid="XXXX" event="script" value="expticket.lua"/>

Depending on which distro you use.
 
Last edited:
@up
a end is missing wont work :)
this will work :)
LUA:
  function onUse(cid, item, toPos, item2, fromPos)
-- script by zonet
local config = {
    highExp = 1000000,
    lowExp = 500000,
    levelHigh = 200,
    effect = 37,
    item = xxxx  -- put your item id please.
    
}

    if getPlayerLevel(cid) >= config.levelHigh then
        doPlayerAddExperience(cid, config.lowExp)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You gained "..config.lowExp.." experience points!")
        doSendMagicEffect(getPlayerPosition(cid), config.effect)
        doPlayerRemoveItem(cid, config.item, 1)
        

    else
        doPlayerAddExperience(cid, config.highExp)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You gained "..config.highExp.." experience points!")
        doSendMagicEffect(getPlayerPosition(cid), config.effect)
        doPlayerRemoveItem(cid, config.item, 1)

        end
    return TRUE
end
 
Last edited:
@up

Actually mine wasn't working because I put ""CON... instead of "CON... And I had enough ends...

Edit: Just realised that the item doesnt get remove. Here is the correct script...
Code:
function onUse(cid, item, toPos, item2, fromPos)
    local levelReq = 200
    local expHigh = 1000000
    local expLow = 500000
    local tmp = getCreaturePosition(cid)
    if getPlayerLevel(cid) >= levelReq then
        doPlayerAddExp(cid, expLow)
        doPlayerSendTextMessage(cid, 25, "CONGRATULATIONS! "..expLow.." exp has been given to you!")
        doPlayerRemoveItem(cid, XXXX, 1)
    else
        doPlayerAddExp(cid, expHigh)
        doPlayerSendTextMessage(cid, 25, "CONGRATULATIONS! "..expHigh.." exp has been given to you!")
        doPlayerRemoveItem(cid, XXXX, 1)
    end
    doSendMagicEffect(tmp, CONST_ME_MAGIC_RED)
    return TRUE
end
 
Last edited:
Or this one.

PHP:
<action itemid="XXXX" script="other/scroll.lua"/>

PHP:
-- OTcentrum.pl - Polskie Centrum OpenTibii 
local config = {
funnyEffect = "YES", -- effects fireworks & Animated Text  (YES/NO) 
minimumLevel = 20,
maximumLevel = 250, -- for infinite type math.huge
}
local addExp = {
[{config.minimumLevel, 40}] = 40000000,
[{40, 80}] = 35000000,
[{80, 90}] = 35000000,
[{90, 100}] = 35000000,
[{100, 120}] = 35000000,
[{120, 160}] = 35000000,
[{160, config.maximumLevel}] = 40000000,
}
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
 
Back
Top