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

Lua Help me whit premium scroll

Ranel

New Member
Joined
Oct 13, 2016
Messages
9
Reaction score
0
how to make items na "premium scroll" witch give 14 days premium ? TFS 0.4 is me engine
If sommone know, please help .
THX
 
Last edited:
Haven't used 0.4 in a long time but try this: (un-tested)

data/actions/actions.xml [replace 1234 with your itemID]
Code:
<action itemid="1234" event="script" value="premy.lua"/>

data/actions/scripts/premy.lua
Code:
local config = {
    daysToAdd = 14, -- How many days do you want to add?
    maxDays = 500, -- If the player has greater than or equal to (>=) this many days send him a cancel to prevent wasting the item
    failEffect = CONST_ME_POFF, -- What type of magic effect do you want to send upon FAILURE?
    successEffect = CONST_ME_MAGIC_RED, -- What type of magic effect do you want to send upon SUCCESS?
    msgType = MESSAGE_INFO_DESCR -- message type
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    -- establish the variables that we used more than once
    local premDays = getPlayerPremiumDays(cid)
    local playerPos = getCreaturePosition(cid)

    -- Check to see if the player doesn't already have plenty of days left
    if premDays >= config.maxDays then
        doPlayerSendTextMessage(cid, config.msgType, config.msgType, 'You currently have ' .. premDays .. ' premium day' .. (premDays > 1 and 's' or '') .. ' left. You many only add more premium time once you are below ' .. config.maxDays .. ' premium day' .. (config.maxDays > 1 and 's' or '') .. '.')
        doSendMagicEffect(playerPos, config.failEffect)
        return false
    end

    -- If all checks have passed then go ahead and remove the item and add the days
    doRemoveItem(item.uid, 1)
    doPlayerAddPremiumDays(cid, config.daysToAdd)
    doSendMagicEffect(playerPos, config.successEffect)
    doPlayerSendTextMessage(cid, config.msgType, 'Congratulations, you have successfully added ' .. config.daysToAdd .. ' premium day' .. (config.daysToAdd > 1 and 's' or '') .. ' to your account!')
    return true
end

Here are some 0.4 functions:
https://otland.net/threads/lua-0-4-tfs-functions.149040/
 
Last edited:
Here you are (tested):
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
   if getPlayerPremiumDays(cid) > 500 then
       doPlayerSendTextMessage (cid, MESSAGE_INFO_DESCR, "You have more than 500 PREMIUM days, wait to use this scroll again!")
       doSendMagicEffect (getCreaturePosition (cid), 2)     
   else
       doRemoveItem(item.uid, 1)
       doPlayerAddPremiumDays(cid, 30)
       doSendMagicEffect(getCreaturePosition(cid), 14)
       doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You added more 30 PREMIUM days in your account!")
   end
   return true
end
 
Back
Top