TomCrusher
Jeg er ingenting
Hello i trying to write my first script and I'm newbie so I cannot excute it who can help me wit it???
This is a scroll on use, u can get a new vocation but only with time expiries. What is wrong? 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
minLevel = 20, -- Level needed to buy promotion
cost = 20000, -- Promotion cost in gp
premium = "yes", -- is premium needed to buy promotion?
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
elseif(config.premium == TRUE and isPremium(cid) == FALSE) then
doPlayerSendCancel(cid, "You need a premium account.")
elseif(getPlayerPromotionLevel(cid) >= config.promotion) then
doPlayerSendCancel(cid, "You are already promoted.")
elseif(getPlayerLevel(cid) < config.minLevel) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You need " .. config.minLevel .. " to get promotion.")
else
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, os.time()+config.MaxTime)
end
local PlayerTime = getPlayerStorageValue(Player, 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
Last edited: