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

experience cast open

Pedrook

Advanced OT User
Joined
May 24, 2009
Messages
442
Solutions
3
Reaction score
183
Location
Brazil
I would like to add in the cast a bonus experience for when the player is open, and when closing the experience back to normal.

Lua:
function onSay(player, words, param)
   
    if param == 'on' then
        if player:startLiveCast() then
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You have started casting your gameplay.")
        else
            player:sendCancelMessage("You're already casting your gameplay.")
        end
    elseif param == 'off' then
        if player:stopLiveCast() then
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You have stopped casting your gameplay.")
        else
            player:sendCancelMessage("You're not casting your gameplay.")
        end
    end
   
    return false
end
 
Solution
before function onSay define:

local storage = 17754 -- exp storage

now before player:sendTextMessage(MESSAGE_INFO_DESCR, "You have started casting your gameplay."):

player:setStorageValue(storage, 1)

and before player:sendTextMessage(MESSAGE_INFO_DESCR, "You have stopped casting your gameplay."):

player:setStorageValue(storage, 0).



Now in events/scripts/player.lua search for "onGainExperience" callback and add the following before the return:

local multiplier = 1.2 -- 20%+ exp
if player:getStorageValue(17754) == 1 then
exp = exp * multiplier
end
before function onSay define:

local storage = 17754 -- exp storage

now before player:sendTextMessage(MESSAGE_INFO_DESCR, "You have started casting your gameplay."):

player:setStorageValue(storage, 1)

and before player:sendTextMessage(MESSAGE_INFO_DESCR, "You have stopped casting your gameplay."):

player:setStorageValue(storage, 0).



Now in events/scripts/player.lua search for "onGainExperience" callback and add the following before the return:

local multiplier = 1.2 -- 20%+ exp
if player:getStorageValue(17754) == 1 then
exp = exp * multiplier
end
 
Solution
Which version of TFS you using?

Easy to tell when it's 1.x or 0.x, check
Lua:
function onSay(player, words, param)
player instead of cid.
Lua:
 player:sendTextMessage(MESSAGE_INFO_DESCR, "You have started casting your gameplay.")
player:sendTextMessage(..) instead of doPlayerSendTextMessage(cid, ..)
etc etc
 
I would like to add in the cast a bonus experience for when the player is open, and when closing the experience back to normal.

Lua:
function onSay(player, words, param)
  
    if param == 'on' then
        if player:startLiveCast() then
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You have started casting your gameplay.")
        else
            player:sendCancelMessage("You're already casting your gameplay.")
        end
    elseif param == 'off' then
        if player:stopLiveCast() then
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You have stopped casting your gameplay.")
        else
            player:sendCancelMessage("You're not casting your gameplay.")
        end
    end
  
    return false
end
Where did you find this cast system?
 
Back
Top