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

Solved Help with Exhaust on my script :D

L

LordVissie

Guest
So, I tried to make a script and this is the outcome :p

Code:
local exhaustTime, exhaustStorage = 4999, 5000

function onUse(cid, item, frompos, item2, topos)
    if exhaustion.check(cid, exhaustStorage) then
    local time = exhaustion.get(cid, exhaustStorage)
    local hours, minutes, seconds = math.floor (time / 3600), math.floor ((time - ((math.floor (time / 3600)) * 3600))/ 60), time - ((math.floor (time/60)) * 60)
    if time >= 3600 then
        text = hours.." "..(hours == 1 and "hour" or "hours")..", "..minutes.." "..(minutes == 1 and "minute" or "minutes").." and "..seconds.." "..(seconds == 1 and "second" or "seconds")
    elseif time >= 120 then
       text = minutes.." "..(minutes == 1 and "minute" or "minutes").." and "..seconds.." "..(seconds == 1 and "second" or "seconds")
    else
       text = seconds.." "..(seconds == 1 and "second" or "seconds")
    end
doSummonCreature("terror bird", {x=588, y=1423, z=3})
doSummonCreature("terror bird", {x=589, y=1425, z=3}) -- fix coordinaten
doSummonCreature("terror bird", {x=590, y=1424, z=3})
exhaustion.set(cid, exhaustStorage, exhaustTime)
end
return true
end

If you pull the lever there will spawn 3 terror birds in near you but I had a little trubble between the exhaust you can just pull the lever again after 2 seconds that makes it giving infinite exp. So I tried to add some exhaustion. The exhaustion part is from Limos. but I don't know if I putted it in correctly, probally not because It does nothing when I try to pull the lever the lever doesn't change (from left to right) the script doesn't gives any errors when I use it and when I start the server up. (Also no: Sorry, not possible. on use)

Anyone have an idea what I did wrong? ;)

~~~~ Edit ~~~~

Actions.xml : <action uniqueid="13201" event="script" value="terror bird.lua"/>

Using: 0.3.6
 
Last edited by a moderator:
Try splitting up first line like that
PHP:
local exhaustTime = 4999
local exhaustStorage = 5000
This is just a short hand method of assignment and has no negative effect if done the short or long way.
Code:
local exhaustTime, exhaustStorage = 4999, 5000
The long way provides clarity, the short way provides convenience.

It looks like you just took a bunch of scripts and tossed them in a text file :/
See if this works out.
Code:
    -- Learn to use tables, they don't need to be complex, you can keep it simple
    local creatures = {
        { name = "terror bird", pos = { x = 588, y = 1423, z = 3} },
        { name = "terror bird", pos = { x = 589, y = 1425, z = 3} },
        { name = "terror bird", pos = { x = 590, y = 1424, z = 3} }
    }

    -- time in seconds til you can pull the switch again
    local time_ = 5

    -- do not edit this
    local switch = {1946, 1945}
    local exhaust = true
    ---------------------

    function onUse(cid, item, frompos, item2, topos)
        local function resetSwitch()
             exhaust = true
        end
        if isInArray(switch, item.itemid) and exhaust then
            for i in ipairs(creatures) do
                doSummonCreature(creatures[i].name, creatures[i].pos)
            end
            exhaust = false
            addEvent(resetSwitch, time_ * 1000)
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you need to wait to use this switch again.")
        end
        doTransformItem(item.uid, (item.itemid == 1945) and item.itemid + 1 or item.itemid - 1)
        return true
    end
 
Last edited:
This is just a short hand method of assignment and has no negative effect if done the short or long way.
Code:
local exhaustTime, exhaustStorage = 4999, 5000
The long way provides clarity, the short way provides convenience.

It looks like you just took a bunch of scripts and tossed them in a text file :/
See if this works out.
Code:
    -- Learn to use tables, they don't need to be complex, you can keep it simple
    local creatures = {
        { name = "terror bird", pos = { x = 588, y = 1423, z = 3} },
        { name = "terror bird", pos = { x = 589, y = 1425, z = 3} },
        { name = "terror bird", pos = { x = 590, y = 1424, z = 3} }
    }

    -- time in seconds til you can pull the switch again
    local time_ = 5

    -- do not edit this
    local switch = {1946, 1945}
    local exhaust = true
    ---------------------

    function onUse(cid, item, frompos, item2, topos)
        local function resetSwitch()
             exhaust = true
        end
        if isInArray(switch, item.itemid) and exhaust then
            for i in ipairs(creatures) do
                doSummonCreature(creatures[i].name, creatures[i].pos)
            end
            exhaust = false
            addEvent(resetSwitch, time_ * 1000)
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you need to wait to use this switch again.")
        end
        doTransformItem(item.uid, (item.itemid == 1945) and item.itemid + 1 or item.itemid - 1)
        return true
    end
Well actually, I got the exhaustion part from limos wich I saw somewhere and the rest I did myself and tossed that into Notepad++ :p

Your script works really nice. Thanks for helping as always ;)
 
This is just a short hand method of assignment and has no negative effect if done the short or long way.
Code:
local exhaustTime, exhaustStorage = 4999, 5000
The long way provides clarity, the short way provides convenience.

It looks like you just took a bunch of scripts and tossed them in a text file :/
See if this works out.
Code:
    -- Learn to use tables, they don't need to be complex, you can keep it simple
    local creatures = {
        { name = "terror bird", pos = { x = 588, y = 1423, z = 3} },
        { name = "terror bird", pos = { x = 589, y = 1425, z = 3} },
        { name = "terror bird", pos = { x = 590, y = 1424, z = 3} }
    }

    -- time in seconds til you can pull the switch again
    local time_ = 5

    -- do not edit this
    local switch = {1946, 1945}
    local exhaust = true
    ---------------------

    function onUse(cid, item, frompos, item2, topos)
        local function resetSwitch()
             exhaust = true
        end
        if isInArray(switch, item.itemid) and exhaust then
            for i in ipairs(creatures) do
                doSummonCreature(creatures[i].name, creatures[i].pos)
            end
            exhaust = false
            addEvent(resetSwitch, time_ * 1000)
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you need to wait to use this switch again.")
        end
        doTransformItem(item.uid, (item.itemid == 1945) and item.itemid + 1 or item.itemid - 1)
        return true
    end

Im trying to learn tables...
how:
doSummonCreature(creatures.name, creatures.pos)
make:
local creatures = {
{ name = "terror bird", pos = { x = 588, y = 1423, z = 3} },
{ name = "terror bird", pos = { x = 589, y = 1425, z = 3} },
{ name = "terror bird", pos = { x = 590, y = 1424, z = 3} }
}

summon creature?
 
Back
Top