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

Time expires

TomCrusher

Jeg er ingenting
Joined
Dec 31, 2008
Messages
663
Reaction score
19
Location
Norway
Hello how to set time of expires for set player storage on real time? I think about scroll some get you promotion but only for 2 weeks, how to set it???
I'm newbie and wrote first my script like this but dont work <_<
Who can help me?
PHP:
local config = {
	promotion = 2,	-- promotion level, default = 2 . Ignore if you don't have new vocations.
        oldpromotion = 1, -- back promotion level, default = 2
        MaxTime = 20, --max time of promotion
        TimeStor = 18009 --here will be saved the time.
}

local disabledVocations = {0}

config.premium = getBooleanFromString(config.premium)

function onUse(cid, item, frompos, param, topos)
        if item.itemid == 9004 then

		setPlayerPromotionLevel(cid, config.promotion)
		doPlayerRemoveItem(cid, 9004, 1)
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have been succesful promoted to " .. getVocationInfo(getPlayerVocation(cid)).name .. ".")
                setPlayerStorageValue(cid, config.TimeStor, config.MaxTime)
	end
local PlayerTime = getPlayerStorageValue(cid, config.TimeStor)
        if PlayerTime - 10 <= os.time() then
	doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "you have "..PlayerTime - os.time().." seconds left.!")
        elseif PlayerTime == 0 <=os.time() then
        setPlayerPromotionLevel(cid, config.oldpromotion)
	end
	return TRUE
end
Thanks a lot.:blink:
 
Try this:

PHP:
local config = {
    promotion = 2,    -- promotion level, default = 2 . Ignore if you dont have new vocations.
        oldpromotion = 1, -- back promotion level, default = 2
        MaxTime = 20, --max time of promotion
        TimeStor = 18009 --here will be saved the time.
        compare = 14 * 24 * 60 * 1000 --here will be saved the time.
}

local disabledVocations = {0}

config.premium = getBooleanFromString(config.premium)

function onUse(cid, item, frompos, param, topos)
        if item.itemid == 9004 then

        setPlayerPromotionLevel(cid, config.promotion)
        doPlayerRemoveItem(cid, 9004, 1)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have been succesful promoted to " .. getVocationInfo(getPlayerVocation(cid)).name .. ".")
                setPlayerStorageValue(cid, config.TimeStor, config.MaxTime)
    end
local PlayerTime = getPlayerStorageValue(cid, config.TimeStor)
        if (os.time() - PlayerTime) > config.compare then
		setPlayerPromotionLevel(cid, config.oldpromotion)
setPlayerStorageValue(cid, config.TimeStor, os.time())
        else
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "you have "..os.time() - PlayerTime.." seconds left.!")
    end
    return TRUE
end
 
@up!

your script have a bug!

Code:
local config = {
    promotion = 2,    -- promotion level, default = 2 . Ignore if you dont have new vocations.
        oldpromotion = 1, -- back promotion level, default = 2
        MaxTime = 20, --max time of promotion
        TimeStor = 18009 --here will be saved the time.
        compare = 14 * 24 * 60 * 1000 --here will be saved the time.
}

local disabledVocations = {0}

[B]config.premium = getBooleanFromString(config.premium)[/B]

where is premium in config? maybe promotion xD
 
It thing about check premium on account but not used @up I going to check yurs script :)

So comming error on console:
PHP:
Lua Script Error: [Action Interface] 
data/actions/scripts/vocscroll.lua

data/lib/function.lua:398: attempt to index local 'str' (a nil value)
Warning: [Event::loadScript] Can not load script. data/actions/scripts/vocscroll.lua

Huh?
 
Last edited:
Hello i fixed error and modifited script to:
PHP:
local config = {
    promotion = 2,    -- promotion level, default = 2 . Ignore if you dont have new vocations.
        oldpromotion = 1, -- back promotion level, default = 2
        MaxTime = 20, --max time of promotion
        TimeStor = 18009, --here will be saved the time.
        compare = 14 * 24 * 60 * 1000 --here will be saved the time.
}

local disabledVocations = {0}

function onUse(cid, item, frompos, param, topos)
        if item.itemid == 9004 then

        setPlayerPromotionLevel(cid, config.promotion)
        doPlayerRemoveItem(cid, 9004, 1)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have been succesful promoted to " .. getVocationInfo(getPlayerVocation(cid)).name .. ".")
                setPlayerStorageValue(cid, config.TimeStor, config.compare)
    end
local PlayerTime = getPlayerStorageValue(cid, config.TimeStor)
        if (os.time() - PlayerTime) > config.compare then
        setPlayerPromotionLevel(cid, config.oldpromotion)
setPlayerStorageValue(cid, config.TimeStor, os.time())
        elseif PlayerTime - 10 <= os.time() then
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "you have "..os.time() - PlayerTime.." seconds left.!")
    end
    return TRUE
end

But dont removed promotion 2 after the time what is wrong?:confused:
 
Back
Top