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

Request fix for tiles script, players are still able to walk through another player at the dp

Tatuy1

Member
Joined
Mar 24, 2014
Messages
159
Solutions
1
Reaction score
13
Location
México
Request fix for tiles script, players are still able to walk through another player at the dp and steal items.

Here is my script for tiles:
Code:
function onStepIn(cid, item, pos)
    if isPlayer(cid) ~= TRUE then
        return true
    end
    if item.actionid == 100 then
        doTransformSwitchTile(item)
    elseif item.actionid > 100 then
        if getPlayerDepotItems(cid, item.actionid - 100) > 1 then
            doPlayerSendTextMessage(cid, 23, "Your depot contains " .. getPlayerDepotItems(cid, item.actionid - 100) .. " items.")
        else
            doPlayerSendTextMessage(cid, 23, "Your depot contains 1 item.")
        end
        doTransformSwitchTile(item)
    end
    return true
end

function onStepOut(cid, item, pos)
    doTransformSwitchTile(item)
    return true
end

function doTransformSwitchTile(item)
    if isInArray(SWITCH_TILE_ON, item.itemid) == TRUE then
        if item.itemid == 425 then
            doTransformItem(item.uid, item.itemid + 1)
        else
            doTransformItem(item.uid, item.itemid - 1)
        end
    else
        if item.itemid == 426 then
            doTransformItem(item.uid, item.itemid - 1)
        else
            doTransformItem(item.uid, item.itemid + 1)
        end
    end
end
function StepIn(cid, item, pos)
    doTransformSwitchTile(item)
    return true
end
function doTransformSwitchTile(item)
    if isInArray(SWITCH_TILE_ON, item.itemid) == TRUE then
        if item.itemid == 416 then
            doTransformItem(item.uid, item.itemid + 1)
        else
            doTransformItem(item.uid, item.itemid - 1)
        end
    else
        if item.itemid == 417 then
            doTransformItem(item.uid, item.itemid - 1)
        else
            doTransformItem(item.uid, item.itemid + 1)
        end
    end
end
function StepIn(cid, item, pos)
    doTransformSwitchTile(item)
    return true
end
function doTransformSwitchTile(item)
    if isInArray(SWITCH_TILE_ON, item.itemid) == TRUE then
        if item.itemid == 446 then
            doTransformItem(item.uid, item.itemid + 1)
        else
            doTransformItem(item.uid, item.itemid - 1)
        end
    else
        if item.itemid == 447 then
            doTransformItem(item.uid, item.itemid - 1)
        else
            doTransformItem(item.uid, item.itemid + 1)
        end
    end
end
function StepIn(cid, item, pos)
    doTransformSwitchTile(item)
    return true
end
function doTransformSwitchTile(item)
    if isInArray(SWITCH_TILE_ON, item.itemid) == TRUE then
        if item.itemid == 3216 then
            doTransformItem(item.uid, item.itemid + 1)
        else
            doTransformItem(item.uid, item.itemid - 1)
        end
    else
        if item.itemid == 3217 then
            doTransformItem(item.uid, item.itemid - 1)
        else
            doTransformItem(item.uid, item.itemid + 1)
        end
    end
end

I have OTServ 0.6.4.
Can you help me?
 
The solution for this problem is a source edit, but you could check the tile id against the zone with getTilePzInfo(pos) with a walkback, ya know like when you step on a chest it kicks you backwards or just check the stack of the tile to see if there is a player already on it

Code:
//getThingFromPos(pos)
    //Note:
    //    stackpos = 255. Get the top thing(item moveable or creature)
    //    stackpos = 254. Get MagicFieldtItem
    //    stackpos = 253. Get Creature

Code:
int LuaScriptInterface::luaGetTilePzInfo(lua_State *L)
{
    //getTilePzInfo(pos)
    PositionEx pos;
    popPosition(L, pos);

    Tile *tile = g_game.getMap()->getTile(pos);

    if(tile){
        if(tile->hasFlag(TILESTATE_PROTECTIONZONE)){
            lua_pushboolean(L, true);
        }
        else{
            lua_pushboolean(L, false);
        }
    }
    else{
        std::stringstream ss;
        ss << pos << " " << getErrorDesc(LUA_ERROR_TILE_NOT_FOUND);
        reportErrorFunc(ss.str().c_str());
        lua_pushboolean(L, false);
    }
    return 1;
}

Hope this was helpful :)
 
Last edited:
Thank you very much for your answer.
I made this LUAScript:
Code:
function onStepIn(cid, item, pos, frompos)
    if item.actionid > 100 and item.actionid <= 130 and isPlayer(cid) then --ActionsId depot tiles
            if frompos.x == 0 and frompos.y == 0 and frompos.z == 0 then
                frompos = getPlayerMasterPos(cid)
            end
            doTeleportThing(cid, frompos)
    end
    return true
end
but it work only one time because the tile get up and change the id of the item. This has been a headache, hehe.

I think it's easier in c ++, but I'm a little rusty, can you help me?
by the by: I have the same code in luascript.cpp :)
 
I found the function hehe:
Code:
bool Player::canWalkthrough(const Creature* creature) const
{
    if(hasFlag(PlayerFlag_CanPassThroughAllCreatures)
        || (creature->getPlayer() && creature->getPlayer()->hasSomeInvisibilityFlag())){
        return true;
    }
    if (creature->getTile() && creature->getTile()->ground
        && creature->getTile()->ground->getID() == ITEM_GLOWING_SWITCH){
        return false;
    }

    return (Combat::checkPVPExtraRestrictions(this, creature, true) != RET_NOERROR);
}

It solved.
 
Back
Top