QuaS
Cykotitan Pwned =/
I didn't relase anything last time so here we go. It's example of using my lua function : http://otland.net/f35/gettimesincelastmove-103625/
@Down. Function isTrapped return true if you're trapped.
Function isTileBlocking return true if player cannot enter this tile.
Function getThingsFromPos is not optimized. It return table with items from this pos.
Lua:
PLAYER_NO_MOVE_MAX_TIME_TRAPPED = 5; -- example time, seconds.
function isTrapped(cid)
local timee = getTimeSinceLastMove(cid);
local bool = true;
if (timee < PLAYER_NO_MOVE_MAX_TIME_TRAPPED*1000) then
return false;
end
if(not getCreatureCondition(cid,CONDITION_INFIGHT)) then
return false;
end
local player_pos = getCreaturePosition(cid);
local count = 0;
for ax = player_pos.x-1,player_pos.x+1 do
for ay = player_pos.y-1, player_pos.y+1 do
if((player_pos.x ~= ax or player_pos.y ~= ay) and not isTileBlocking({x=ax,y=ay,z=player_pos.z})) then
return false;
end
end
end
return true;
end
function getThingsFromPos(pos, except)
local table_, excl = {}, except or 0;
local yea = true;
if(excl==0) then
yea = false;
end
yea = true;
for i=1,254 do
pos.stackpos=i;
local itemt = getThingFromPos(pos);
if(itemt.itemid>0) then
if(yea) then
if(type(excl) == "table") then
if(not isInArray(excl, itemt.itemid)) then
table.insert(table_,itemt.uid);
end
else
if(not (excl == itemt.itemid)) then
table.insert(table_,itemt.uid);
end
end
end
end
end
return #table_>0 and table_ or 0;
end
function isTileBlocking(pos, cid)
cid = cid or false;
local items = getThingsFromPos(pos);
if(type(items) ~= "table") then
return false;
end
for i=1,#items do
if(isCreature(items[i])) then
return true;
elseif(hasProperty(items[i], 0) or hasProperty(items[i], 3)) then
return true;
end
end
if(getHouseFromPos(getThingPos(items[i])) and cid)then
local hinfo = getHouseInfo(getHouseFromPos(getThingPos(items[i])));
if(getPlayerGUID(cid) ~= hinfo.owner) then --not sure. hinfo.owner or hinfo['owner'];
return true;
end
end
return false;
end
@Down. Function isTrapped return true if you're trapped.
Function isTileBlocking return true if player cannot enter this tile.
Function getThingsFromPos is not optimized. It return table with items from this pos.
Last edited: