• 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 onThink function help

Lurk

Active Member
Joined
Dec 4, 2017
Messages
336
Reaction score
48
Hello, I'm working in this script, tfs 0.4 8.6
Lua:
function onThink(cid, interval)

local rate = 1.15 -- só access
local ratering42 = 3.15 -- ring 200 com acces
local origratering42 = 3.0 -- ring 200 sem access
local ratering41 = 2.45 -- ring 130 com access
local origratering41 = 2.3 -- ring 130 sem access
local origratering40 = 1.9 -- ring 90 sem access
local ratering40 = 2.05 -- rate ring 90 com access

local rates = getPlayerRates(cid)
local config = {
s = 13704, -- storage vip
scrollexp = 1000,
}
-- 10502 ring 130, 10064 ring 90, ring 200 2122

if getPlayerSlotItem(cid, CONST_SLOT_RING).itemid == 10064 then -- ring 90
    doCreatureSay(cid, "ATUALIZADO RING 90" , TALKTYPE_ORANGE_1)
    if getPlayerStorageValue(cid, config.scrollexp) - os.time() >= 1 and getPlayerStorageValue(cid, config.s) - os.time() >= 1 then -- com access e scroll
        doPlayerSetExperienceRate(cid, 1+(ratering40+0.5))
        return true
    elseif getPlayerStorageValue(cid, config.scrollexp) - os.time() < 1 and getPlayerStorageValue(cid, config.s) - os.time() >= 1 then -- sem exp doc mas com access
        doPlayerSetExperienceRate(cid, 1+(ratering40))
        return true
    elseif getPlayerStorageValue(cid, config.scrollexp) - os.time() >= 1 and getPlayerStorageValue(cid, config.s) - os.time() < 1 then -- sem access mas com doc
        doPlayerSetExperienceRate(cid, 1+(origratering40+0.5))
        return true
    elseif getPlayerStorageValue(cid, config.scrollexp) - os.time() >= 1 and getPlayerStorageValue(cid, config.s) - os.time() < 1 then -- sem exp doc e sem access
        doPlayerSetExperienceRate(cid, 1+(origratering40))
        return true
    end
    doPlayerSetExperienceRate(cid, 1)
    return true
end

if getPlayerSlotItem(cid, CONST_SLOT_RING).itemid == 10502 then -- ring 130
    doCreatureSay(cid, "ATUALIZADO RING 130" , TALKTYPE_ORANGE_1)
    if getPlayerStorageValue(cid, config.scrollexp) - os.time() >= 1 and getPlayerStorageValue(cid, config.s) - os.time() >= 1 then -- com access e scroll
        doPlayerSetExperienceRate(cid, 1+(ratering41+0.5))
        return true
    elseif getPlayerStorageValue(cid, config.scrollexp) - os.time() < 1 and getPlayerStorageValue(cid, config.s) - os.time() >= 1 then -- sem exp doc mas com access
        doPlayerSetExperienceRate(cid, 1+(ratering41))
        return true
    elseif getPlayerStorageValue(cid, config.scrollexp) - os.time() >= 1 and getPlayerStorageValue(cid, config.s) - os.time() < 1 then -- sem access mas com doc
        doPlayerSetExperienceRate(cid, 1+(origratering41+0.5))
        return true
    elseif getPlayerStorageValue(cid, config.scrollexp) - os.time() >= 1 and getPlayerStorageValue(cid, config.s) - os.time() < 1 then -- sem exp doc e sem access
        doPlayerSetExperienceRate(cid, 1+(origratering41))
        return true
    end
    doPlayerSetExperienceRate(cid, 1)
    return true
end

if getPlayerSlotItem(cid, CONST_SLOT_RING).itemid == 2122 then -- ring 200
    doCreatureSay(cid, "ATUALIZADO RING 200" , TALKTYPE_ORANGE_1)
    if getPlayerStorageValue(cid, config.scrollexp) - os.time() >= 1 and getPlayerStorageValue(cid, config.s) - os.time() >= 1 then -- com access e scroll
        doPlayerSetExperienceRate(cid, 1+(ratering42+0.5))
        return true
    elseif getPlayerStorageValue(cid, config.scrollexp) - os.time() < 1 and getPlayerStorageValue(cid, config.s) - os.time() >= 1 then -- sem exp doc mas com access
        doPlayerSetExperienceRate(cid, 1+(ratering42))
        return true
    elseif getPlayerStorageValue(cid, config.scrollexp) - os.time() >= 1 and getPlayerStorageValue(cid, config.s) - os.time() < 1 then -- sem access mas com doc
        doPlayerSetExperienceRate(cid, 1+(origratering42+0.5))
        return true
    elseif getPlayerStorageValue(cid, config.scrollexp) - os.time() >= 1 and getPlayerStorageValue(cid, config.s) - os.time() < 1 then -- sem exp doc e sem access
        doPlayerSetExperienceRate(cid, 1+(origratering42))
        return true
    end
    doPlayerSetExperienceRate(cid, 1)
    return true
end

    doCreatureSay(cid, "ATUALIZADO SEM RING" , TALKTYPE_ORANGE_1)
    doPlayerSetExperienceRate(cid, 1)
    return true
end

I want this onThink to check if the player has an specific item in the ring slot and if he has, he'll earn more exp from each monster killed, there are some bonuses based on storage as well
thing is, I made this an onThink creaturescript, I registered in login.lua and etc, but the player is receiving the maximum amount of exp even when he doesn't have any ring equiped
I'm wondering if it I simply can't use this getPlayerSlotItem(cid, CONST_SLOT_RING) in an onThink event because it doesn't make any sense to me
there are no console errors
 
Last edited:
because the stages are always changing when the players level up, it was a movement before but having to reequip every time sucks
 

Similar threads

Back
Top