• 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 with this vip lever

darknelson

Member
Joined
Jun 19, 2011
Messages
190
Solutions
1
Reaction score
15
im trying to make a lever when u use it, it add to you 2 vip days, only if you never geting, just once, i make this script, but is not working no error on console

Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)

local config={
removeOnUse = "no" -- remover quando usar ("yes" or "no")
}

local days = 2 -- coloque os dias que ser�o a VIP!
local daysvalue = days * 24 * 60 * 60
local storageplayer = getPlayerStorageValue(cid, 13702)
local timenow = os.time()
time = timenow + daysvalue
time = storageplayer + daysvalue
end
if getPlayerStorageValue(cid, 82082) == -1 then
setPlayerStorageValue(cid, 13702, time)
setPlayerStorageValue(cid, 82082, 1)
local quantity = math.floor((getPlayerStorageValue(cid, 13702) - timenow)/(24 * 60 * 60))
doSendMagicEffect(getPlayerPosition(cid), math.random(28,30))
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Felicidades Amigo ".. days .." dias de VIP fueron agregados a tu cuenta.")
if (config.removeOnUse == "yes") then
doRemoveItem(item.uid, 1)
else
doPlayerSendTextMessage(cid,22,"NO MEN YA TOMASTE VIP.")
end

return TRUE
end


tfs 0.4
 
Lua:
local config = {
    storage = 82082,
    days = 2
    }
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.itemid == 1945 then
        if getPlayerStorageValue(cid, config.storage) == -1 then
            setPlayerStorageValue(cid, config.storage, 1)
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Felicidades Amigo ".. config.days .." dias de VIP fueron agregados a tu cuenta.")
            doPlayerAddPremiumDays(cid, config.days)
            doSendMagicEffect(getPlayerPosition(cid), math.random(28,30))
        else
            doPlayerSendTextMessage(cid,22,"NO MEN YA TOMASTE VIP.")
        end
        doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
    end
    return true
end
try this
 
Last edited:
im trying to make a lever when u use it, it add to you 2 vip days, only if you never geting, just once, i make this script, but is not working no error on console

Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)

local config={
removeOnUse = "no" -- remover quando usar ("yes" or "no")
}

local days = 2 -- coloque os dias que ser�o a VIP!
local daysvalue = days * 24 * 60 * 60
local storageplayer = getPlayerStorageValue(cid, 13702)
local timenow = os.time()
time = timenow + daysvalue
time = storageplayer + daysvalue
end
if getPlayerStorageValue(cid, 82082) == -1 then
setPlayerStorageValue(cid, 13702, time)
setPlayerStorageValue(cid, 82082, 1)
local quantity = math.floor((getPlayerStorageValue(cid, 13702) - timenow)/(24 * 60 * 60))
doSendMagicEffect(getPlayerPosition(cid), math.random(28,30))
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Felicidades Amigo ".. days .." dias de VIP fueron agregados a tu cuenta.")
if (config.removeOnUse == "yes") then
doRemoveItem(item.uid, 1)
else
doPlayerSendTextMessage(cid,22,"NO MEN YA TOMASTE VIP.")
end

return TRUE
end


tfs 0.4
Properly tabbing your script will go a long way towards creating less issues for yourself.
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local config={
        removeOnUse = "no" -- remover quando usar ("yes" or "no")
    }
   
    local days = 2 -- coloque os dias que ser�o a VIP!
    local daysvalue = days * 24 * 60 * 60
    local storageplayer = getPlayerStorageValue(cid, 13702)
    local timenow = os.time()
    time = timenow + daysvalue
    time = storageplayer + daysvalue
    end -- end here for some reason?
    if getPlayerStorageValue(cid, 82082) == -1 then
        setPlayerStorageValue(cid, 13702, time)
        setPlayerStorageValue(cid, 82082, 1)
        local quantity = math.floor((getPlayerStorageValue(cid, 13702) - timenow)/(24 * 60 * 60))
        doSendMagicEffect(getPlayerPosition(cid), math.random(28,30))
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Felicidades Amigo ".. days .." dias de VIP fueron agregados a tu cuenta.")
        if (config.removeOnUse == "yes") then
            doRemoveItem(item.uid, 1)
        else
            doPlayerSendTextMessage(cid,22,"NO MEN YA TOMASTE VIP.")
        end
    -- missing end here
    return TRUE
end

Regardless, I believe I'll re-write the script from scratch.
Lua:
local config = {
    storage_one_time_use = 82082,
    storage_vip = 13702,
    days_to_give = 2, -- must be a positive number.
    remove_item = false -- true/false
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    -- one time use check
    if getCreatureStorage(cid, config.storage_one_time_use) == 1 then
        doPlayerSendTextMessage(cid, 22, "This item can only be used once per character.")
        return true
    end
    doCreatureSetStorage(cid, config.storage_one_time_use, 1)
    
    -- calculate an additional 2 days of VIP
    local cur_time = os.time()
    local vip_storage = getCreatureStorage(cid, config.storage_vip)
    vip_storage = vip_storage >= cur_time and vip_storage or cur_time -- if VIP is expired or has never been given, use cur_time, else use the current storage
    vip_storage = vip_storage + (60 * 60 * 24 * config.days_to_give) -- add 2 days of time
    doCreatureSetStorage(cid, config.storage_vip, vip_storage)
    doPlayerSendTextMessage(cid, 22, "You have received " .. config.days_to_give .. " day" .. (config.days_to_give == 1 and "" or "s") .. " of VIP.")
    
    if config.remove_item then
        doRemoveItem(item.uid, 1)
    end
    
    return true    
end
 

Similar threads

Back
Top