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

PremiumScroll 30/60/90/ .... days

kaszanalubizryc

New Member
Joined
Sep 10, 2015
Messages
148
Reaction score
1
hello
how i can add 60days premium scroll and 90days premium scrol to this?>

Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
player:setStorageValue(998899, 1)
player:addPremiumDays(30)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have received 30 premium days.")
item:remove(1)
return true
end
 
player:addPremiumDays(30) <---- change 30 for the days that you like
you are troll?
i want have on one .lua file

30,60,90 days
i don't want change lol....:D:D:D:D
like
Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
player:setStorageValue(998899, 1)
player:addPremiumDays(30)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have received 30 premium days.")
item:remove(1)
return true
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
player:setStorageValue(998899, 1)
player:addPremiumDays(60)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have received 60 premium days.")
item:remove(1)
return true
end
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
player:setStorageValue(998899, 1)
player:addPremiumDays(90)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have received 90 premium days.")
item:remove(1)
return true
end
but i know this don't work i think must have item.id to do this
 
If you want more premium scrolls you have to edit the items.otb and copy the premium scroll and add it in items.xml too, else you have to tell us when do you get 30 days, when 60, when 90....
 
You have the different items ready and all you are asking for is a single script that will handle few different cases? If that's the case then try this:


Code:
local config = {
[1] = {id = 123, days = 30, storage = 998899},
[2] = {id = 123, days = 60, storage = 998899},
[3] = {id = 123, days = 90, storage = 998899},
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local itemId = item:getId()

for i = 1,#config do
if config[i].id == itemId then
player:setStorageValue(config[i].storage, 1)
player:addPremiumDays(config[i].days)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have received " ..config[i].days.." premium days.")
item:remove(1)
break
end
end

return true
end

in config change ids and storage
 
Last edited:
You have the different items ready and all you are asking for is a single script that will handle few different cases? If that's the case then try this:


Code:
local config = {
[1] = {id = 123, days = 30, storage = 998899},
[2] = {id = 123, days = 60, storage = 998899},
[3] = {id = 123, days = 90, storage = 998899},
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
local itemId = item:getId()

for i = 1,#config do
if config[i].id == itemId then
player:setStorageValue(config[i].storage, 1)
player:addPremiumDays(config[i].days)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have received " ..config[i].days.." premium days.")
item:remove(1)
break
end
end

return true
end

in config change ids and storage
storage must be the same is to teleport to town when premium end thanks :)
 
Why do you use loop? You can easily do something like this:
Code:
local config = {
    [itemId] = {days = 30, storage = 123},
    [itemId] = {days = 60, storage = 124},
    [itemId] = {days = 90, storage = 125}
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local scroll = config[item.itemid]
    if not scroll then
        return false
    end

    player:addPremiumDays(scroll.days)
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have received ".. scroll.days .." premium days.")
    item:remove(1)
    return true
end
 
Why do you use loop? You can easily do something like this:
Code:
local config = {
    [itemId] = {days = 30, storage = 123},
    [itemId] = {days = 60, storage = 124},
    [itemId] = {days = 90, storage = 125}
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local scroll = config[item.itemid]
    if not scroll then
        return false
    end

    player:addPremiumDays(scroll.days)
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have received ".. scroll.days .." premium days.")
    item:remove(1)
    return true
end
thanks but i got some error
premiumscroll.lua:2 table index is nill
stack traceback:
[C]: in fuction __newindex

i use tfs 1.2
 
Back
Top Bottom