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

Adding Experience

Gazzy

Server Owner
Joined
Sep 25, 2013
Messages
55
Reaction score
3
Hey guys,
I'm making an item that when used it adds experience. I need to know how to do this. Any help?
Thanks!
 
Use an action script, add it with itemid in actions.xml and in the lua scriot use function onUse(cid, item, fromPosition, itemEx, toPosition), with
Code:
doPlayerAddExp(cid,exp)
 
Doesn't work with what I've came up with:
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    doPlayerAddExp(cid, 50000000000)
    doCreatureSay(cid, "EXP Egg used!", TALKTYPE_ORANGE_1)
end
 
No errors, but when I use the item in game it performs the script but it doesn't give anywhere near the amount of exp in the script.
 
Code:
local t = {
    storage = 20000,
    exp = 850000
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerStorageValue(cid, t.storage) < 5 then
        doPlayerAddExp(cid, 850000)
        doSendAnimatedText(getThingPos(cid), t.exp, TEXTCOLOR_WHITE)
        doCreatureSay(cid, "You gained " .. t.exp .. " experience!", TALKTYPE_ORANGE_1, false, cid, getThingPos(cid))
        setPlayerStorageValue(cid, t.storage, 1)
        doRemoveItem(item.uid, 1)
end
    return true
end


Action.xml
Code:
    <action itemid="6544" event="script" value="expeggs.lua"/>

-----------------------------------------------------
itemid="6544"

Item id for what you want to use for getting exp
-------------------------------------------------------
 
Code:
doPlayerAddExp(cid, 50000000, true, true)
Limit is 2755359744, but by setting the third parameter to true 50000000 will become 50000000000. Last true is to get a textmessage, so you see how much exp you got.
 
Okay thanks bro. Another thing, where can I find stuff like all the functions such as "doPlayerAddExp" and stuff (all the "do" functions)
 
Go to the folder doc, then the file LUA_FUNCTIONS.

For more information about Lua functions go to luascript.cpp (source file).
 
Back
Top