• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Feature Fix/Patch exploit of bot to crash/lag servers and clone items

The os.time() works only with seconds so the lowest exhaust you can get is 1sec
 
Use os.mtime() in TFS 0.3.7 or 0.4, note in 0.2 you should add this function at sources
 
Lua:
local config =
{
	storage_id = 61894,
	exhaustion = 500 -- time in milliseconds
}


function onMoveItem(cid, item, formPosition, toPosition, fromItem, toItem, fromGround, toGround, status)
	if exhaustion.check(cid, config.storage_id) then
		doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
		return false
	end
	
	exhaustion.set(cid, config.storage_id, config.exhaustion / 1000)
	addEvent(valid(doCreatureSetStorage), config.exhaustion, cid, config.storage_id, 0)
	
	if getTileInfo(fromPosition).house then
		doPlayerSave(cid)
		doSaveHouse(getHouseFromPos(fromPosition))
	elseif getTileInfo(toPosition).house then
		doPlayerSave(cid)
		doSaveHouse(getHouseFromPos(toPosition))
	end
	return true
end
 
not compiling
Code:
creatureevent.cpp: In member function 'uint32_t CreatureEvent::executeOnMove(Player*, Item*, const Position&, const Position&, Item*, Item*, Item*, Item*, std::map<std::basic_string<char>, int>)':
creatureevent.cpp:1971:40: error: variable 'it' set but not used [-Werror=unused-but-set-variable]
cc1plus: all warnings being treated as errors
make[1]: *** [creatureevent.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory `/root/sources'
make: *** [all] Error 2
 
Hello,
as some of you know there is an exploit using elfbot/magebot(...) to crash/lag server and possibiliting cloning.

Elf Hotkey to lag server:
Code:
auto 50 dropitemsxyzamount $posx [$posy+2] $posz 3590 1 |dropitemsxyzamount $posx [$posy+2] $posz 6569 1 |dropitemsxyzamount $posx [$posy+2] $posz 3591 1 |dropitemsxyzamount $posx [$posy+2] $posz 130 1 |dropitemsxyzamount $posx [$posy+2] $posz 3588 1
No matter if this key is used in a house or not, it will lag anyway.

How to fix
http://otland.net/f35/creatureevent-onmove-very-advanced-134016/

and

XML:
<event type="move" name="onMove" event="script" value="Custom/onMove.lua"/>
Lua:
local storage = 61894
local exhause_time = 500 -- in milli seconds

local function resetStorage(cid)
    if isPlayer(cid) then
        setPlayerStorageValue(cid, storage, 0)
    end
end

local function doExhaust(cid)
    -- exhaust divided by 1000 can be 0 (500 / 1000 = 0), but in onMoveItem(..) we check if time is >= os.time()
    setPlayerStorageValue(cid,storage,os.time()+(exhause_time / 1000))
    -- so if 'event' does not execute, it won't be a problem (just block for 1 second [not 0.5 sec] IF you relog)
    addEvent(resetStorage, exhause_time, cid)
end

function onMoveItem(cid, item, fromPosition, toPosition, fromItem, toItem, fromGround, toGround, status)
    -- and here we check time, not 1/0 value
    if getPlayerStorageValue(cid,storage) >= os.time() then
        doPlayerSendCancel(cid, "You cannot move objects that fast.")
        return false
    end
    doExhaust(cid)

    if (getTileInfo(fromPosition).house) then
        doPlayerSave(cid)
        doSaveHouse(getHouseFromPos(fromPosition))
    elseif (getTileInfo(toPosition).house) then
        doPlayerSave(cid)
        doSaveHouse(getHouseFromPos(toPosition))
    end
    return true
end

Thanks to Kito2.
Thanks to Gesior.pl for optimizing this script.
Thanks to Summ for adding check if player exist.

Im gonna post a new exhaust script later... I compiled yesterday and worked well.
 
not compiling
Code:
creatureevent.cpp: In member function 'uint32_t CreatureEvent::executeOnMove(Player*, Item*, const Position&, const Position&, Item*, Item*, Item*, Item*, std::map<std::basic_string<char>, int>)':
creatureevent.cpp:1971:40: error: variable 'it' set but not used [-Werror=unused-but-set-variable]
cc1plus: all warnings being treated as errors
make[1]: *** [creatureevent.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory `/root/sources'
make: *** [all] Error 2

Find this at game.gpp:

if(!player->hasCustomFlag(PlayerCustomFlag_CanPushAllItems) && (!item->isPushable() || (item->isLoadedFromMap() &&
(item->getUniqueId() != 0 || (item->getActionId() != 0 && item->getContainer())))))
{
player->sendCancelMessage(RET_NOTMOVABLE);
return false;
}

Change MOVABLE for MOVEABLE.
 
Back
Top