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

Exhaust Request

Exmortis

Member
Joined
Jun 27, 2008
Messages
189
Reaction score
5
As the title says, I need exhaust for the following scripts to avoid alot of memory usage if players would abuse the scripts for crashing the server or such.
If you can make it easy configurable so I can choose the exhaust myself that would be swell.
Or if you could tell me how to add it effectively to any script in the future.
Rep+

First script, teleportscroll:
Code:
function onUse(cid, item, frompos, item2, topos)
ppos = getPlayerPosition(cid)
temple = getPlayerMasterPos(cid)
if (getCreatureCondition(cid, CONDITION_INFIGHT) == FALSE) then
doTeleportThing(cid, temple, TRUE)
doSendMagicEffect(ppos,66)
doSendAnimatedText(frompos,'Warped!',16)
else
doPlayerSendCancel(cid,"You can't teleport immediately after fight.")
doSendMagicEffect(ppos,2)
end
return 1
end

Second script, outfit doll:
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local v, tmp = math.random(351), getCreatureOutfit(cid)
	while isInArray({tmp.lookType, 75, 135, 266, 302}, v) == TRUE or v <= 1 or (v > 160 and v < 192) or v > 351 do
		v = math.random(351)
	end
 
	tmp.lookType = v
	doCreatureChangeOutfit(cid, tmp)
	doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_RED)
	doCreatureSay(cid, 'Your outfit has been changed.', TALKTYPE_ORANGE_1, false, cid, getThingPos(cid))
	return TRUE
end

Third script, toilettes:
Code:
local message = "You took a dump and you feel alot lighter"
local speed = 450 --- Put the speed you'd like
local time = 200 --- Put the time you'd like (it will be multiplied by 1000)
function onUse(cid, item, frompos, item2, topos)
ppos = getPlayerPosition(cid)
doSendMagicEffect(ppos,65)
doPlayerAddMana(cid, 500)
doChangeSpeed(cid, speed)
addEvent(doChangeSpeed, time*1000, cid, -speed)
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,message) ---- If you don't want messages displayed then erase this line
return true
end

Fourth script, showers:
Code:
local gratePos = {x=1004, y=1137, z=9}
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local v = getTileItemById(gratePos, 9586).uid
	if v == 0 then
		local p = getTopCreature(gratePos).uid
		if p ~= cid then
			doPlayerSendCancel(cid, 'You need to stand on the grate.')
		else
			doCreateItem(9586, 1, gratePos)
			doSendMagicEffect(gratePos, CONST_ME_WATERSPLASH)
			doCreatureSay(cid, 'Ohh, that felt so good!', TALKTYPE_ORANGE_1)
			doCreatureAddHealth(cid, 10)
		end
	else
		doRemoveItem(v)
	end
	return true	
end
 
data/global.lua, add:
Lua:
exhaustion =
{
    check = function (cid, storage)
        if(getPlayerFlagValue(cid, PlayerFlag_HasNoExhaustion)) then
            return FALSE
        end

        return getPlayerStorageValue(cid, storage) >= os.time()
    end,

    get = function (cid, storage)
        if(getPlayerFlagValue(cid, PlayerFlag_HasNoExhaustion)) then
            return FALSE
        end

        local exhaust = getPlayerStorageValue(cid, storage)
        if(exhaust > 0) then
            local left = exhaust - os.time()
            if(left >= 0) then
                return left
            end
        end

        return FALSE
    end,

    set = function (cid, storage, time)
        setPlayerStorageValue(cid, storage, os.time() + time)
    end,

    make = function (cid, storage, time)
        local exhaust = exhaustion.get(cid, storage)
        if(not exhaust) then
            exhaustion.set(cid, storage, time)
            return TRUE
        end

        return FALSE
    end
}

Lua:
local storage = 23456

function onUse(cid, item, fromPosition, itemEx, toPosition)
    
    if exhaustion.check(cid, storage) == TRUE then
        doPlayerSendCancel(cid, "You can not use this yet["..exhaustion.get(cid, storage).."].")
        return TRUE
    else
        exhaustion.set(cid, storage, 60)
    end

    if getCreatureCondition(cid, CONDITION_INFIGHT) == FALSE then
        doTeleportThing(cid, getPlayerMasterPos(cid))
        doSendMagicEffect(getThingPos(cid),66)
        doSendAnimatedText(fromPosition,"Warped!",16)
    else
        doPlayerSendCancel(cid,"You can't teleport immediately after fight.")
        doSendMagicEffect(getThingPos(cid), 2)
    end
    return TRUE
end

Lua:
local storage = 23457

function onUse(cid, item, fromPosition, itemEx, toPosition)
    
    if exhaustion.check(cid, storage) == TRUE then
        doPlayerSendCancel(cid, "You can not use this yet["..exhaustion.get(cid, storage).."].")
        return TRUE
    else
        exhaustion.set(cid, storage, 60)
    end

    local v, tmp = math.random(351), getCreatureOutfit(cid)
    while isInArray({tmp.lookType, 75, 135, 266, 302}, v) == TRUE or v <= 1 or (v > 160 and v < 192) or v > 351 do
        v = math.random(351)
    end
 
    tmp.lookType = v
    doCreatureChangeOutfit(cid, tmp)
    doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_RED)
    doCreatureSay(cid, 'Your outfit has been changed.', TALKTYPE_ORANGE_1, false, cid, getThingPos(cid))
    return TRUE
end

Lua:
local storage = 23459
local message = "You took a dump and you feel alot lighter"
local speed = 450 --- Put the speed you'd like
local time = 200 --- Put the time you'd like (it will be multiplied by 1000)

function onUse(cid, item, fromPosition, itemEx, toPosition)

    if exhaustion.check(cid, storage) == TRUE then
        doPlayerSendCancel(cid, "You can not use this yet["..exhaustion.get(cid, storage).."].")
        return TRUE
    else
        exhaustion.set(cid, storage, 60)
    end

    doSendMagicEffect(getThingPos(cid), CONST_ME_YALAHARIGHOST)
    doPlayerAddMana(cid, 500)
    doChangeSpeed(cid, speed)
    addEvent(doChangeSpeed, time*1000, cid, -speed)
    doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,message) ---- If you don't want messages displayed then erase this line
    return TRUE
end

Lua:
local gratePos = {x=1004, y=1137, z=9}
local storage = 23432
 
function onUse(cid, item, fromPosition, itemEx, toPosition)

    if exhaustion.check(cid, storage) == TRUE then
        doPlayerSendCancel(cid, "You can not use this yet["..exhaustion.get(cid, storage).."].")
        return TRUE
    else
        exhaustion.set(cid, storage, 60)
    end

    local v = getTileItemById(gratePos, 9586).uid
    if v == 0 then
        local p = getTopCreature(gratePos).uid
        if p ~= cid then
            doPlayerSendCancel(cid, 'You need to stand on the grate.')
        else
            doCreateItem(9586, 1, gratePos)
            doSendMagicEffect(gratePos, CONST_ME_WATERSPLASH)
            doCreatureSay(cid, 'Ohh, that felt so good!', TALKTYPE_ORANGE_1)
            doCreatureAddHealth(cid, 10)
        end
    else
        doRemoveItem(v)
    end
    return TRUE
end

for each script:
Code:
exhaustion.set(cid, storage, [COLOR=red][B]60[/B][/COLOR])
60 seconds
 
global.lua
Lua:
exhaustion =
{
    check = function (cid, storage)
        if getPlayerFlagValue(cid, PlayerFlag_HasNoExhaustion) == TRUE then
            return FALSE
        end
 
        return getPlayerStorageValue(cid, storage) >= os.time() and TRUE or FALSE
    end,
 
    get = function (cid, storage)
        if getPlayerFlagValue(cid, PlayerFlag_HasNoExhaustion) == TRUE then
            return FALSE
        end
 
        local exhaust = getPlayerStorageValue(cid, storage)
        if(exhaust > 0) then
            local left = exhaust - os.time()
            if(left >= 0) then
                return left
            end
        end
 
        return FALSE
    end,
 
    set = function (cid, storage, time)
        setPlayerStorageValue(cid, storage, os.time() + time)
    end,
 
    make = function (cid, storage, time)
        local exhaust = exhaustion.get(cid, storage)
        if(not exhaust) then
            exhaustion.set(cid, storage, time)
            return TRUE
        end
 
        return FALSE
    end
}
Don't test this on a GM character.
 
Back
Top