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

8.54 lua dont exchaust item and playersendcancel help

V0rTeX

New Member
Joined
Feb 7, 2018
Messages
31
Reaction score
2
I need something like PlayerSendCancel "You need 100 level":
Lua:
function onUse(cid, item, frompos, item2, topos)
local storage = 90022 -- Make sure to select non-used storage.
local cooldown = 5 -- in seconds.
local level = 100
if getPlayerStorageValue(cid, storage) <= os.time() then
setPlayerStorageValue(cid, storage, os.time() + cooldown)
if getPlayerSkill(cid,0) >= 50 then
if item.uid == 10122 and getPlayerLevel(cid) >= level then
local tekst = "You are teleported."
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE , tekst)
pos = {x=1025, y=1154, z=10}
doTeleportThing(cid, pos)
doSendMagicEffect(pos, 32)
else
return 0
end
else
doPlayerSendTextMessage(cid, 22, "Sorry, you need 50 Strength")
doSendMagicEffect(getPlayerPosition(cid),2)
end
else
doPlayerSendCancel(cid, "Can only be executed once every " .. cooldown .. " seconds. Remaining cooldown: " .. getPlayerStorageValue(cid, storage) - os.time())
doSendMagicEffect(getPlayerPosition(cid),2)
end
return 1
end

and the next one :
if dont have local level=200
or
if getPlayerSkill(cid,0) >= 70
dont exchaust this item


Lua:
local scroll = 11585
local temple = {x=1022, y=1023, z=7}
local level = 200

function onUse(cid, item, frompos, item2, topos)
   local storage = 90010 -- Make sure to select non-used storage.
    local cooldown = 3600 -- in seconds.
    if getPlayerStorageValue(cid, storage) <= os.time() then
       setPlayerStorageValue(cid, storage, os.time() + cooldown)
   if getPlayerSkill(cid,0) >= 70 then
   if item.itemid == scroll and getPlayerLevel(cid) >= level then
       doTeleportThing(cid, temple, TRUE)
       doSendMagicEffect(temple,3)
       doSendAnimatedText(temple, "Temple!", 12)
      return 0
end
   else
       doPlayerSendCancel(cid, "Sorry, you need 200lvl and 70 Strength")
       doSendMagicEffect(getPlayerPosition(cid),2)
end
        else
   doPlayerSendCancel(cid, "Can only be executed once every " .. cooldown .. " seconds. Remaining cooldown: " .. getPlayerStorageValue(cid, storage) - os.time())
       doSendMagicEffect(getPlayerPosition(cid),2)
      end
return 1
end
 
Lua:
local config = {
    storage = 90022 -- Make sure to select non-used storage.
    cooldown = 5 -- in seconds.
    level = 100
    skill = 50
    pos = {x = 1025, y = 1154, z = 10}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)   
    if getPlayerSkillLevel(cid, 0, false) < config.skill then
        doPlayerSendTextMessage(cid, MESSAGE_DAMAGE_RECEIVED, "Sorry, you need " .. config.skill .. " Strength")
        doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
        return true
    end
   
    if getPlayerLevel(cid) < config.level then
        doPlayerSendCancel(cid, "You need " .. config.level .. " level")
        return true
    end
   
    if getPlayerStorageValue(cid, config.storage) > os.time() then
        doPlayerSendCancel(cid, "Can only be executed once every " .. config.cooldown .. " seconds. Remaining cooldown: " .. getPlayerStorageValue(cid, config.storage) - os.time())
        doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
        return true
    end
    setPlayerStorageValue(cid, config.storage, os.time() + config.cooldown)
   
    doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You are teleported.")
    doTeleportThing(cid, config.pos)
    doSendMagicEffect(config.pos, CONST_ME_SLEEP)
    return true
end
Lua:
local config = {
    storage = 90010, -- Make sure to select non-used storage.
    cooldown = 3600, -- in seconds.
    level = 200,
    skill = 70,
    temple = {x = 1022, y = 1023, z = 7}
}

function onUse(cid, item, frompos, item2, topos)
    if getPlayerSkillLevel(cid, 0, false) < config.skill or getPlayerLevel(cid) >= config.level then
        if getPlayerStorageValue(cid, config.storage) > os.time() then
            doPlayerSendCancel(cid, "Can only be executed once every " .. config.cooldown .. " seconds. Remaining cooldown: " .. getPlayerStorageValue(cid, config.storage) - os.time())
            doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
            return true
        end
        setPlayerStorageValue(cid, config.storage, os.time() + config.cooldown)
    end

    doTeleportThing(cid, config.temple, true)
    doSendMagicEffect(config.temple, CONST_ME_BLOCKHIT)
    doSendAnimatedText(config.temple, "Temple!", 12)
    return true
end
 
@Xikini
first one:
[21/09/2018 20:32:35] [Error - LuaScriptInterface::loadFile] data/actions/scripts/hellb.lua:3: '}' expected (to close '{' at line 1) near 'cooldown'
[21/09/2018 20:32:35] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/hellb.lua)
[21/09/2018 20:32:35] data/actions/scripts/hellb.lua:3: '}' expected (to close '{' at line 1) near 'cooldown'

second one:
[21/09/2018 20:36:38] [Error - Action Interface]
[21/09/2018 20:36:38] data/actions/scripts/kinto.lua:eek:nUse
[21/09/2018 20:36:38] Description:
[21/09/2018 20:36:38] (luaGetPlayerSkillLevel) Player not found

[21/09/2018 20:36:38] [Error - Action Interface]
[21/09/2018 20:36:38] data/actions/scripts/kinto.lua:eek:nUse
[21/09/2018 20:36:38] Description:
[21/09/2018 20:36:38] data/actions/scripts/kinto.lua:10: attempt to compare boolean with number
[21/09/2018 20:36:38] stack traceback:
[21/09/2018 20:36:38] data/actions/scripts/kinto.lua:10: in function <data/actions/scripts/kinto.lua:9>
 
@Xikini
first one:
[21/09/2018 20:32:35] [Error - LuaScriptInterface::loadFile] data/actions/scripts/hellb.lua:3: '}' expected (to close '{' at line 1) near 'cooldown'
[21/09/2018 20:32:35] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/hellb.lua)
[21/09/2018 20:32:35] data/actions/scripts/hellb.lua:3: '}' expected (to close '{' at line 1) near 'cooldown'

second one:
[21/09/2018 20:36:38] [Error - Action Interface]
[21/09/2018 20:36:38] data/actions/scripts/kinto.lua:eek:nUse
[21/09/2018 20:36:38] Description:
[21/09/2018 20:36:38] (luaGetPlayerSkillLevel) Player not found

[21/09/2018 20:36:38] [Error - Action Interface]
[21/09/2018 20:36:38] data/actions/scripts/kinto.lua:eek:nUse
[21/09/2018 20:36:38] Description:
[21/09/2018 20:36:38] data/actions/scripts/kinto.lua:10: attempt to compare boolean with number
[21/09/2018 20:36:38] stack traceback:
[21/09/2018 20:36:38] data/actions/scripts/kinto.lua:10: in function <data/actions/scripts/kinto.lua:9>
Lua:
local config = {
    storage = 90022, -- Make sure to select non-used storage.
    cooldown = 5, -- in seconds.
    level = 100,
    skill = 50,
    pos = {x = 1025, y = 1154, z = 10}
}

function onUse(cid, item, fromPosition, itemEx, toPosition) 
    if getPlayerSkill(cid, 0) < config.skill then
        doPlayerSendTextMessage(cid, MESSAGE_DAMAGE_RECEIVED, "Sorry, you need " .. config.skill .. " Strength")
        doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
        return true
    end
   
    if getPlayerLevel(cid) < config.level then
        doPlayerSendCancel(cid, "You need " .. config.level .. " level")
        return true
    end
   
    if getPlayerStorageValue(cid, config.storage) > os.time() then
        doPlayerSendCancel(cid, "Can only be executed once every " .. config.cooldown .. " seconds. Remaining cooldown: " .. getPlayerStorageValue(cid, config.storage) - os.time())
        doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
        return true
    end
    setPlayerStorageValue(cid, config.storage, os.time() + config.cooldown)
   
    doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You are teleported.")
    doTeleportThing(cid, config.pos)
    doSendMagicEffect(config.pos, CONST_ME_SLEEP)
    return true
end
Lua:
local config = {
    storage = 90010, -- Make sure to select non-used storage.
    cooldown = 3600, -- in seconds.
    level = 200,
    skill = 70,
    temple = {x = 1022, y = 1023, z = 7}
}

function onUse(cid, item, frompos, item2, topos)
    if getPlayerSkillLevel(cid, 0, false) < config.skill or getPlayerLevel(cid) >= config.level then
        if getPlayerStorageValue(cid, config.storage) > os.time() then
            doPlayerSendCancel(cid, "Can only be executed once every " .. config.cooldown .. " seconds. Remaining cooldown: " .. getPlayerStorageValue(cid, config.storage) - os.time())
            doSendMagicEffect(getThingPosition(cid), CONST_ME_POFF)
            return true
        end
        setPlayerStorageValue(cid, config.storage, os.time() + config.cooldown)
    end
   
    doTeleportThing(cid, config.temple, true)
    doSendMagicEffect(config.temple, CONST_ME_BLOCKHIT)
    doSendAnimatedText(config.temple, "Temple!", 12)
    return true
end
 
@Xikini
first one
work but debugging when use
second one
the same like before
#2 change
Lua:
getPlayerSkillLevel(cid, 0, false)
to
Lua:
getPlayerSkill(cid, 0)

Idk why you would be 'debugging' with the first one.
I'm using the same stuff your original script was.
 

Similar threads

Back
Top