• 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 Exp scroll Problem with save

jareczekjsp

Member
Joined
Jan 30, 2023
Messages
185
Reaction score
9
GitHub
Jarek123
Hello Guys I have Problem with double scroll ,when you click You have 2x more exprinke but when you died or relog You dont have 2x exprince dont save storage (2x more Exprince )and you can not use next double scroll ,How I can do it ?

Lua:
local config = {
    rate = 2,
    storage = 1000,
    expstorage = 1100,
    register = 1200,
    time = 10800
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerStorageValue(cid, config.storage) <= 0 then
        local rates = getPlayerRates(cid)
        setPlayerStorageValue(cid, config.expstorage, rates[SKILL__LEVEL])
        setPlayerStorageValue(cid, config.register, 1)
        itemEx = itemid == 9004
        doCreatureSay(cid, "Your extra experience rate has been activated! It now is: " .. config.rate .. "x added to your former experience rate.", TALKTYPE_ORANGE_1, true, cid)
        setPlayerStorageValue(cid, config.storage, os.time()+config.time)
        doPlayerSetExperienceRate(cid, rates[SKILL__LEVEL]*config.rate)
        doRemoveItem(item.uid,1)
        registerCreatureEvent(cid, "ExpStage")
    else
        doCreatureSay(cid, "You must finish first exp condition to start other exp condition !", TALKTYPE_ORANGE_1, true, cid)
    end
    return true
end

function onThink(cid, interval)
    if getPlayerStorageValue(cid, config.register) == 1 then
        if getPlayerStorageValue(cid, config.storage) <= os.time() then
            doCreatureSay(cid, "Your extra experience rate has finished! It is now normaly experience rate.", TALKTYPE_ORANGE_1, true, cid)
            setPlayerStorageValue(cid, config.storage, 0)
            setPlayerStorageValue(cid, config.register, 0)
            local oldexp = getPlayerStorageValue(cid, config.expstorage)
            doPlayerSetExperienceRate(cid, oldexp)
            unregisterCreatureEvent(cid, "ExpStage")
        end
    end
    return true
end

function onLogin(cid)
    if getPlayerStorageValue(cid, config.register) == 1 then
        registerCreatureEvent(cid, "ExpStage")
        local rates = getPlayerRates(cid)
        doCreatureSay(cid, "Your extra experience rate is still here! It is: " .. config.rate .. "x added to your former experience rate.", TALKTYPE_ORANGE_1, true, cid)
        if getPlayerStorageValue(cid, config.storage) > os.time() then
            local oldexp = getPlayerStorageValue(cid, config.expstorage)
            doPlayerSetExperienceRate(cid, oldexp+config.rate)
        end
    end
    return true
end
 
Last edited by a moderator:
Solution
It is probably due to the login function, you can try this:
Lua:
local config = {
    rate = 2,
    storage = 1000,
    expstorage = 1100,
    register = 1200,
    time = 10800
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerStorageValue(cid, config.storage) <= 0 then
        local rates = getPlayerRates(cid)
        setPlayerStorageValue(cid, config.expstorage, rates[SKILL__LEVEL])
        setPlayerStorageValue(cid, config.register, 1)
        itemEx = itemid == 9004
        doCreatureSay(cid, "Your extra experience rate has been activated! It now is: " .. config.rate .. "x added to your former experience rate.", TALKTYPE_ORANGE_1, true, cid)
        setPlayerStorageValue(cid, config.storage, os.time()+config.time)...
It is probably due to the login function, you can try this:
Lua:
local config = {
    rate = 2,
    storage = 1000,
    expstorage = 1100,
    register = 1200,
    time = 10800
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerStorageValue(cid, config.storage) <= 0 then
        local rates = getPlayerRates(cid)
        setPlayerStorageValue(cid, config.expstorage, rates[SKILL__LEVEL])
        setPlayerStorageValue(cid, config.register, 1)
        itemEx = itemid == 9004
        doCreatureSay(cid, "Your extra experience rate has been activated! It now is: " .. config.rate .. "x added to your former experience rate.", TALKTYPE_ORANGE_1, true, cid)
        setPlayerStorageValue(cid, config.storage, os.time()+config.time)
        doPlayerSetExperienceRate(cid, rates[SKILL__LEVEL]*config.rate)
        doRemoveItem(item.uid,1)
        registerCreatureEvent(cid, "ExpStage")
    else
        doCreatureSay(cid, "You must finish first exp condition to start other exp condition !", TALKTYPE_ORANGE_1, true, cid)
    end
    return true
end

function onThink(cid, interval)
    if getPlayerStorageValue(cid, config.register) == 1 then
        if getPlayerStorageValue(cid, config.storage) <= os.time() then
            doCreatureSay(cid, "Your extra experience rate has finished! It is now normaly experience rate.", TALKTYPE_ORANGE_1, true, cid)
            setPlayerStorageValue(cid, config.storage, 0)
            setPlayerStorageValue(cid, config.register, 0)
            local oldexp = getPlayerStorageValue(cid, config.expstorage)
            doPlayerSetExperienceRate(cid, oldexp)
            unregisterCreatureEvent(cid, "ExpStage")
        end
    end
    return true
end

function onLogin(cid)
    if getPlayerStorageValue(cid, config.register) == 1 then
        registerCreatureEvent(cid, "ExpStage")
        local rates = getPlayerRates(cid)
        doCreatureSay(cid, "Your extra experience rate is still here! It is: " .. config.rate .. "x added to your former experience rate.", TALKTYPE_ORANGE_1, true, cid)
        if getPlayerStorageValue(cid, config.storage) > os.time() then
            doPlayerSetExperienceRate(cid, rates[SKILL__LEVEL]*config.rate)
        end
    end
    return true
end
 
Solution
It is probably due to the login function, you can try this:
Lua:
function onLogin(cid)
    if getPlayerStorageValue(cid, config.register) == 1 then
        registerCreatureEvent(cid, "ExpStage")
        local rates = getPlayerRates(cid)
        doCreatureSay(cid, "Your extra experience rate is still here! It is: " .. config.rate .. "x added to your former experience rate.", TALKTYPE_ORANGE_1, true, cid)
        if getPlayerStorageValue(cid, config.storage) > os.time() then
            doPlayerSetExperienceRate(cid, rates[SKILL__LEVEL]*config.rate)
        end
    end
    return true
end
Thanks for help I have Add this script to Creaturescripts/login.lua ? ,or change script from old to this script?
Post automatically merged:

My script login.lua

Lua:
local config = {
    loginMessage = getConfigValue('loginMessage')
}

function onLogin(cid)
    local loss = getConfigValue('deathLostPercent')
    if(loss ~= nil) then
        doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10)
    end

    local accountManager = getPlayerAccountManager(cid)
    if(accountManager == MANAGER_NONE) then
        local lastLogin, str = getPlayerLastLoginSaved(cid), config.loginMessage
        if(lastLogin > 0) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
            str = "Your last visit was on " .. os.date("%a %b %d %X %Y", lastLogin) .. "."
        else
            str = str .. " Please choose your outfit."
            doPlayerSendOutfitWindow(cid)
        end

        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
    elseif(accountManager == MANAGER_NAMELOCK) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, it appears that your character has been namelocked, what would you like as your new name?")
    elseif(accountManager == MANAGER_ACCOUNT) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to manage your account and if you want to start over then type 'cancel'.")
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to create an account or type 'recover' to recover an account.")
    end

    if(not isPlayerGhost(cid)) then
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
    end

    registerCreatureEvent(cid, "Mail")
    registerCreatureEvent(cid, "GuildMotd")
   
registerCreatureEvent(cid, "killer")
registerCreatureEvent(cid, "DeathC")
registerCreatureEvent(cid, "DeathSystem")
registerCreatureEvent(cid, "TiraBattle")
registerCreatureEvent(cid, "tkexp")
registerCreatureEvent(cid, "tkexp2")
registerCreatureEvent(cid, "castleexp")
registerCreatureEvent(cid, "dodge")
registerCreatureEvent(cid, "Idle")
registerCreatureEvent(cid, "autoloot")
registerCreatureEvent(cid, "attackguild")   
registerCreatureEvent(cid, "advance")
registerCreatureEvent(cid, "FimVip")
registerCreatureEvent(cid, "VipReceive")
registerCreatureEvent(cid, "forever amulet")
registerCreatureEvent(cid, "SkullCheck")
registerCreatureEvent(cid, "ReportBug")


registerCreatureEvent(cid, "PlayerKill")
    if (InitArenaScript ~= 0) then
    InitArenaScript = 1
    -- make arena rooms free
        for i = 42300, 42309 do
            setGlobalStorageValue(i, 0)
            setGlobalStorageValue(i+100, 0)
        end
    end

registerCreatureEvent(cid, "critical")
if getPlayerStorageValue(cid, 48913) == -1 then
        setPlayerStorageValue(cid, 48913, 0)
    end
   
registerCreatureEvent(cid, "dodge")
if getPlayerStorageValue(cid, 48902) == -1 then
        setPlayerStorageValue(cid, 48902, 0)
    end

    -- if he did not make full arena 1 he must start from zero
    if getPlayerStorageValue(cid, 42309) < 1 then
        for i = 42300, 42309 do
            setPlayerStorageValue(cid, i, 0)
        end
    end
    -- if he did not make full arena 2 he must start from zero
    if getPlayerStorageValue(cid, 42319) < 1 then
        for i = 42310, 42319 do
            setPlayerStorageValue(cid, i, 0)
        end
    end
    -- if he did not make full arena 3 he must start from zero
    if getPlayerStorageValue(cid, 42329) < 1 then
        for i = 42320, 42329 do
            setPlayerStorageValue(cid, i, 0)
        end
    end
    if getPlayerStorageValue(cid, 42355) == -1 then
        setPlayerStorageValue(cid, 42355, 0) -- did not arena level
    end
    setPlayerStorageValue(cid, 42350, 0) -- time to kick 0
    setPlayerStorageValue(cid, 42352, 0) -- is not in arena 
    if getPlayerStorageValue(cid, 12036) == -1 then
setPlayerStorageValue(cid, 12036, 1)
end
return true
end
 
Thanks for help I have Add this script to Creaturescripts/login.lua ? ,or change script from old to this script?
Post automatically merged:

My script login.lua

Lua:
local config = {
    loginMessage = getConfigValue('loginMessage')
}

function onLogin(cid)
    local loss = getConfigValue('deathLostPercent')
    if(loss ~= nil) then
        doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10)
    end

    local accountManager = getPlayerAccountManager(cid)
    if(accountManager == MANAGER_NONE) then
        local lastLogin, str = getPlayerLastLoginSaved(cid), config.loginMessage
        if(lastLogin > 0) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
            str = "Your last visit was on " .. os.date("%a %b %d %X %Y", lastLogin) .. "."
        else
            str = str .. " Please choose your outfit."
            doPlayerSendOutfitWindow(cid)
        end

        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
    elseif(accountManager == MANAGER_NAMELOCK) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, it appears that your character has been namelocked, what would you like as your new name?")
    elseif(accountManager == MANAGER_ACCOUNT) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to manage your account and if you want to start over then type 'cancel'.")
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to create an account or type 'recover' to recover an account.")
    end

    if(not isPlayerGhost(cid)) then
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
    end

    registerCreatureEvent(cid, "Mail")
    registerCreatureEvent(cid, "GuildMotd")
 
registerCreatureEvent(cid, "killer")
registerCreatureEvent(cid, "DeathC")
registerCreatureEvent(cid, "DeathSystem")
registerCreatureEvent(cid, "TiraBattle")
registerCreatureEvent(cid, "tkexp")
registerCreatureEvent(cid, "tkexp2")
registerCreatureEvent(cid, "castleexp")
registerCreatureEvent(cid, "dodge")
registerCreatureEvent(cid, "Idle")
registerCreatureEvent(cid, "autoloot")
registerCreatureEvent(cid, "attackguild") 
registerCreatureEvent(cid, "advance")
registerCreatureEvent(cid, "FimVip")
registerCreatureEvent(cid, "VipReceive")
registerCreatureEvent(cid, "forever amulet")
registerCreatureEvent(cid, "SkullCheck")
registerCreatureEvent(cid, "ReportBug")


registerCreatureEvent(cid, "PlayerKill")
    if (InitArenaScript ~= 0) then
    InitArenaScript = 1
    -- make arena rooms free
        for i = 42300, 42309 do
            setGlobalStorageValue(i, 0)
            setGlobalStorageValue(i+100, 0)
        end
    end

registerCreatureEvent(cid, "critical")
if getPlayerStorageValue(cid, 48913) == -1 then
        setPlayerStorageValue(cid, 48913, 0)
    end
 
registerCreatureEvent(cid, "dodge")
if getPlayerStorageValue(cid, 48902) == -1 then
        setPlayerStorageValue(cid, 48902, 0)
    end

    -- if he did not make full arena 1 he must start from zero
    if getPlayerStorageValue(cid, 42309) < 1 then
        for i = 42300, 42309 do
            setPlayerStorageValue(cid, i, 0)
        end
    end
    -- if he did not make full arena 2 he must start from zero
    if getPlayerStorageValue(cid, 42319) < 1 then
        for i = 42310, 42319 do
            setPlayerStorageValue(cid, i, 0)
        end
    end
    -- if he did not make full arena 3 he must start from zero
    if getPlayerStorageValue(cid, 42329) < 1 then
        for i = 42320, 42329 do
            setPlayerStorageValue(cid, i, 0)
        end
    end
    if getPlayerStorageValue(cid, 42355) == -1 then
        setPlayerStorageValue(cid, 42355, 0) -- did not arena level
    end
    setPlayerStorageValue(cid, 42350, 0) -- time to kick 0
    setPlayerStorageValue(cid, 42352, 0) -- is not in arena
    if getPlayerStorageValue(cid, 12036) == -1 then
setPlayerStorageValue(cid, 12036, 1)
end
return true
end
No, it's the same script, check the post again, I already combined them so you don't get confused.
 
Back
Top