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

Help with addevent error

Grillo1995

New Member
Joined
Feb 8, 2018
Messages
21
Solutions
1
Reaction score
1
Location
Brazil
Hi Otlanders

I have this code: DOUBLE EXP POTION

Code:
local tempo = 600
local storage = 770546

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local player = Player(cid)

    if player:getStorageValue(storage) >= os.time() then
        player:sendTextMessage(MESSAGE_INFO_DESCR, 'You already have double EXP! Ended: ' .. os.date("%X", player:getStorageValue(storage)) .. ' .')
        cid:sendMagicEffect(3)
        return true
    end

    player:setStorageValue(storage, os.time() + tempo)
    Item(item.uid):remove(1)
    player:sendTextMessage(MESSAGE_INFO_DESCR, 'Your 10 minutes of double EXP has started! Ended: ' .. os.date("%X", player:getStorageValue(storage)) .. ' .')
    cid:sendMagicEffect(14)

    addEvent(function(playerid)
        local player = Player(playerid)
        player:sendMagicEffect(5)
        player:sendTextMessage(MESSAGE_INFO_DESCR, 'Your DOUBLE EXP is finished.')
    end, 600000, cid)

    return true
end

And have warningin tfs:

Erro.PNG

Everything works fine the script, but just give this warning on tfs, I would like to take it off!
Hug and thanks.
 
I’ve answered a similar question in another post in the past - if you’d like an explanation as to why this warning message occurs.


While I don’t recommend this, as the error is showing you that the loop has the potential to crash the server if userdata is lost, to disable the messages, you want to find this in config.lua

Code:
warnUnsafeScripts = true

and change it to

Code:
warnUnsafeScripts = false

If you can’t find it at all in config.lua for some reason, simply add the second line in config.lua and the error won’t display anymore.


If you’d like to actually fix the unsafe code, you can pass player:getId() into your addEvent instead of “cid” (which in TFS 1.x is actually userdata and not cid).

Red
 
Back
Top