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

Solved item for double exp TFS 1.0

nurlan

Member
Joined
Feb 5, 2012
Messages
156
Reaction score
22
how can i edit this item and lua ?.. please help me guys :(
i use this script, but dont know how edit items for use :(
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local player = Player(cid)
    if player:getStorageValue(1234) >= os.time() then
        return true
    end
  
    player:setStorageValue(1234, os.time() + 86400)
    Item(item.uid):remove(1)
    return true
end

function Player:onGainExperience(source, exp, rawExp)
    if self:getStorageValue(1234) >= os.time() then
        exp = exp * 2
    end
    return exp
end
 
You can do something like this:
What this does is activate double experience for the player for 2 hours. You can adjust the time and script however you like this was just a basic example.

data/actions/double.lua
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local player = Player(cid)
player:setStorageValue(80000, os.time() + 2 * 60 * 60)
Item(item.uid):remove()
player:say("You have just activated 2 hours of Double Experience!", TALKTYPE_MONSTER_SAY)
return true
end

data/actions.xml
Code:
<action itemid="8981" script="double.lua"/>


data/events/player.lua:
Code:
function Player:onGainExperience(source, exp, rawExp)
    local thing = self:getStorageValue(80000)
    if thing > os.time() then
        return exp * 2.0
    end
    return exp
end

data/events.xml
change
Code:
<event class="Player" method="onGainExperience" enabled="0" />
to
Code:
<event class="Player" method="onGainExperience" enabled="1" />
 
I like to put a lot of options in my scripts, but your ideas are good too :)

Oh I'm sorry I guess I misunderstood your post.
I thought you were uncertain of how to activate double experience for X player for X amount of time using X item. So there was my simple example of one way it could be done.

What was your main goal? Maybe I can help better this time.
 
This is someone else's thread I was just explaining to them how they could use their script on an item but then realized the script didn't do anything to give xp, so I wrote a script on the fly :)

I don't even know if it works, its just mainly an example, I'll test it later tho

lol my apologies man, this is why sleep is important. :oops:

Now everything makes sense, I was pretty confused for a moment there! :p
 
You can do something like this:
What this does is activate double experience for the player for 2 hours. You can adjust the time and script however you like this was just a basic example.

data/actions/double.lua
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local player = Player(cid)
player:setStorageValue(80000, os.time() + 2 * 60 * 60)
Item(item.uid):remove()
player:say("You have just activated 2 hours of Double Experience!", TALKTYPE_MONSTER_SAY)
return true
end

data/actions.xml
Code:
<action itemid="8981" script="double.lua"/>


data/events/player.lua:
Code:
function Player:onGainExperience(source, exp, rawExp)
    local thing = self:getStorageValue(80000)
    if thing > os.time() then
        return exp * 2.0
    end
    return exp
end

data/events.xml
change
Code:
<event class="Player" method="onGainExperience" enabled="0" />
to
Code:
<event class="Player" method="onGainExperience" enabled="1" />
Solved Thanks :)
 
Back
Top