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

tfs 1.1 exp stone problem

strutZ

Australian OT Member {AKA Beastn}
Joined
Nov 16, 2014
Messages
1,393
Solutions
7
Reaction score
552
Hey guys,

I have an item which will grant the player x2 exp rate when they use it. Here is the code.

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local player = Player(cid)
    if player:getStorageValue(1234) >= os.time() then
        player:say('You already have double exp!', TALKTYPE_MONSTER_SAY)
        return true
    end
  
    player:setStorageValue(1234, os.time() + 86400)
    Item(item.uid):remove(1)
    player:say('Your 24 hours of double XP has started!', TALKTYPE_MONSTER_SAY)
    return true
end

function Player:onGainExperience(source, exp, rawExp)
    if self:getStorageValue(1234) >= os.time() then
        exp = exp * 2
    end
    return exp
end

It worked fine on tfs 1.1 ORTS 10.41 but all i have done is used the latest tfs 1.1 recompiled and using ORTS 10.76 and the exp rate doesn't apply? has something changed that i cant seem to find? (Guessing a function or something in player.cpp?) Any help would be awesome tah
 
bump

bump still cant find it grr!!!

Re checked my sources as far as i can see this should work fml
 
Last edited:
Fixed well sort of.. lol

actions/scripts/expstone.lua

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local player = Player(cid)
    if player:getStorageValue(1234) >= os.time() then
        player:say('You already have double exp!', TALKTYPE_MONSTER_SAY)
        return true
    end
 
    player:setStorageValue(1234, os.time() + 86400)
    Item(item.uid):remove(1)
    player:say('Your 24 hours of double XP has started!', TALKTYPE_MONSTER_SAY)
    return true
end

events/scripts/player.lua

Code:
    if self:getStorageValue(1234) >= 1 then
        exp = exp * 2
    end

if anyone knows a better way please share ;)
 
if self:getStorageValue(1234) >= 1 then
it will be bigger than 1 forever

you did it correctly here.

Ahh yeah i posted the wrong one.. i was just testing so i didnt have to keep removing the storage haha
 
Ahh yeah i posted the wrong one.. i was just testing so i didnt have to keep removing the storage haha
Thats why i have this script for my god.

Code:
function onSay(cid, words, param)
local player = Player(cid)
local playerPos = player:getPosition()
local split = param:split(",")
local effect = CONST_ME_MAGIC_GREEN
if not player:getGroup():getAccess() then return true end
if player:getAccountType() < ACCOUNT_TYPE_GOD then return true   end

  player:setStorageValue(split[1], split[2])
  playerPos:sendMagicEffect(effect)
  player:sendTextMessage(ORANGE, "Storage "..split[1].." is set to "..split[2])
end
 
Thats why i have this script for my god.

Code:
function onSay(cid, words, param)
local player = Player(cid)
local playerPos = player:getPosition()
local split = param:split(",")
local effect = CONST_ME_MAGIC_GREEN
if not player:getGroup():getAccess() then return true end
if player:getAccountType() < ACCOUNT_TYPE_GOD then return true   end

  player:setStorageValue(split[1], split[2])
  playerPos:sendMagicEffect(effect)
  player:sendTextMessage(ORANGE, "Storage "..split[1].." is set to "..split[2])
end

Wai make the script so messy?
Code:
function onSay(player, words, param)
    if not player:getGroup():getAccess() or player:getAccountType() < ACCOUNT_TYPE_GOD then
        return true
    end
  
    if param == "" then
        return false
    end
  
    local split = param:split(",")
    player:setStorageValue(split[1], split[2])
    player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
    player:sendTextMessage(TALKTYPE_MONSTER_SAY, "Storage " .. split[1] .. " is set to " .. split[2])
    return true
end
 
Wai make the script so messy?
Code:
function onSay(player, words, param)
    if not player:getGroup():getAccess() or player:getAccountType() < ACCOUNT_TYPE_GOD then
        return true
    end
 
    if param == "" then
        return false
    end
 
    local split = param:split(",")
    player:setStorageValue(split[1], split[2])
    player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
    player:sendTextMessage(TALKTYPE_MONSTER_SAY, "Storage " .. split[1] .. " is set to " .. split[2])
    return true
end
depends on perspective.
I'm slowly making all my script using loads of Local values. Much easier to change things and track errors.
Write the way you want, but my code is not messy.
 
depends on perspective.
I'm slowly making all my script using loads of Local values. Much easier to change things and track errors.
Write the way you want, but my code is not messy.

It really is, if statments on one line, things like ORANGE? You already have a constant for it.
And why load everything in variables? There is no reason at all unless you are going to use them more then once(functions etc).
But atleast imo that script is just as messy as most of the scripts uploaded to otland aka worthless xD
 
It really is, if statments on one line, things like ORANGE? You already have a constant for it.
And why load everything in variables? There is no reason at all unless you are going to use them more then once(functions etc).
But atleast imo that script is just as messy as most of the scripts uploaded to otland aka worthless xD
Good practice. I have huge scripts too and the more local variables i have the easier for me.
Oh yea, forgot about the "ORANGE", its just I keep forgetting what was the long name for it..

It only looks messy because the execution for scripts is only 3 lines.
But when my scripts get few hundred lines long then, these local variables are going to be handy. VERY HANDY.

You think my Script is worthless. Well your script doesn't even work.
 
Good practice. I have huge scripts too and the more local variables i have the easier for me.
Oh yea, forgot about the "ORANGE", its just I keep forgetting what was the long name for it..

It only looks messy because the execution for scripts is only 3 lines.
But when my scripts get few hundred lines long then, these local variables are going to be handy. VERY HANDY.

You think my Script is worthless. Well your script doesn't even work.

Well for a script that is short it really is worthless to keep things like you do in variables, I can agree as I said before about ex. getPosition that will be executed more then once.
I agree with the long names, but that makes it harder for others if you forget to swap it back :p

How does my script not work?
Oh you are using 1.0, he uses 1.1.
If you ever decide to move from that legacy software imo you will notice you don't need to compile the player userdata as it is's a userdata argument not a creature id argument.
 
Well for a script that is short it really is worthless to keep things like you do in variables, I can agree as I said before about ex. getPosition that will be executed more then once.
I agree with the long names, but that makes it harder for others if you forget to swap it back :p

How does my script not work?
Oh you are using 1.0, he uses 1.1.
If you ever decide to move from that legacy software imo you will notice you don't need to compile the player userdata as it is's a userdata argument not a creature id argument.
Well i like that update.
But as long as i don't know how to change source code, i won't be taking on the newest updates from TFS. i need LUA and Hardcoded EXP givers seperately.
 
Well i like that update.
But as long as i don't know how to change source code, i won't be taking on the newest updates from TFS. i need LUA and Hardcoded EXP givers seperately.

Wut? Why would you even need that? You can just add more exp in the event function. The good thing about the newer versions IS that you can modify alot more WITHOUT source changes.
 
Back
Top