• 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! People are entering inside others dp (pz)

1268995

Member
Joined
Sep 9, 2010
Messages
422
Reaction score
13
Hello guys, o have a bug on my otserver.

People can enter inside other people and steal their item on depot.

How can i solve that? I still want that people can pass throw others inside a PZ ZONE, but NOT ON DEPOT!

IDK if it can help, but the item of dp tile =
glowing switch.
ItemID: [11059]
 
You can add a stepin movements script, add it itemid in movements.xml.
Code:
if getTileInfo(position).creatures > 1 then
Then teleport back.
Code:
doTeleportThing(cid, fromPosition, false)
 
@1268995 https://otland.net/threads/walk-through-people-at-depot.233487/#post-2251706
Heba helped me out


In player.cpp
Change

Code:
bool Player::canWalkthrough(const Creature* creature) const
{
if(creature == this || hasCustomFlag(PlayerCustomFlag_CanWalkthrough) || creature->isWalkable() ||
(creature->getMaster() && creature->getMaster() != this && canWalkthrough(creature->getMaster())))
return true;

const Player* player = creature->getPlayer();
if(!player)
return false;

if((((g_game.getWorldType() == WORLDTYPE_OPTIONAL &&
#ifdef __WAR_SYSTEM__
!player->isEnemy(this, true) &&
#endif
player->getVocation()->isAttackable()) || (player->getVocation()->isAttackable() &&
player->getLevel() < (uint32_t)g_config.getNumber(ConfigManager::PROTECTION_LEVEL))) && player->getTile()->ground &&
Item::items[player->getTile()->ground->getID()].walkStack) && (!player->hasCustomFlag(PlayerCustomFlag_GamemasterPrivileges)
|| player->getAccess() <= getAccess()))
return true;

return (player->isGhost() && getGhostAccess() < player->getGhostAccess())
|| (isGhost() && getGhostAccess() > player->getGhostAccess());
}

To
Code:
bool Player::canWalkthrough(const Creature* creature) const
{
if(creature == this || creature->isWalkable() ||
(creature->getMaster() && creature->getMaster() != this && canWalkthrough(creature->getMaster())))
return true;

const Player* player = creature->getPlayer();
if(!player)
return false;

if(
(
(
(
(
player->getVocation()->isAttackable() &&
player->getLevel() < (uint32_t)g_config.getNumber(ConfigManager::pROTECTION_LEVEL)
)
|| (
player->getTile()->hasFlag(TILESTATE_PROTECTIONZONE) &&
!player->getTile()->hasFlag(TILESTATE_HOUSE)
)
)
) && player->getTile()->ground &&
player->getTile()->ground->getID() != 11063
) && (
!player->hasCustomFlag(PlayerCustomFlag_GamemasterPrivileges)
|| player->getAccess() <= getAccess()
)
) return true;

return (player->isGhost() && getGhostAccess() < player->getGhostAccess())
|| (isGhost() && getGhostAccess() > player->getGhostAccess());
}
 
Last edited:
It is, but you can also add a movement script to prevent this.
Limos, the code should be: ?

Code:
function onStepIn(cid, item, fromPosition, toPosition)
    if getTileInfo(position).creatures > 1 then
        doTeleportThing(cid, fromPosition, false)
    end
end

?
 
If the itemid isn't added yet to movements.xml you can add a new script, else add it to the already added movement stepin script.
Code:
function onStepIn(cid, item, position, fromPosition)
The parameters are like this. Third parameter is the position you step on and the fourth parameter the last position.
 
If the itemid isn't added yet to movements.xml you can add a new script, else add it to the already added movement stepin script.

I maded this script:
Code:
function onStepIn(cid, item, fromPosition, toPosition)
    if getTileInfo(position).creatures > 1 then
        doTeleportThing(cid, fromPosition, false)
    end
end

and putted this on movements.xml:

Code:
<movevent type="StepIn" itemid="11059" event="script" value="dptile.lua"/>

And appear on console:

Code:
[Error - MoveEvents Interface]
data/movements/scripts/dptile.lua:onStepIn
Description:
attempt to index a nil value
stack traceback:
[C]: in function 'getTileInfo'
data/movements/scripts/dptile.lua:3 in function <data/movements/scripts/dptile.lua:2>
 
so you're stuck with the same itemid for all tiles infront of depot :p (except if you make a script for the other tile(s) that you put), anyway it was a smart move from Limos to fix it using movements, made it much easier
 
I maded this script:
Code:
function onStepIn(cid, item, fromPosition, toPosition)
    if getTileInfo(position).creatures > 1 then
        doTeleportThing(cid, fromPosition, false)
    end
end

and putted this on movements.xml:

Code:
<movevent type="StepIn" itemid="11059" event="script" value="dptile.lua"/>

And appear on console:

Code:
[Error - MoveEvents Interface]
data/movements/scripts/dptile.lua:onStepIn
Description:
attempt to index a nil value
stack traceback:
[C]: in function 'getTileInfo'
data/movements/scripts/dptile.lua:3 in function <data/movements/scripts/dptile.lua:2>
I already edited my post when I noticed you used different parameter names.
Atm position is nil since there is no parameter called like that.
 
so you're stuck with the same itemid for all tiles infront of depot :p (except if you make a script for the other tile(s) that you put), anyway it was a smart move from Limos to fix it using movements, made it much easier
You right, thanks!


Thanks for the idea, but i will use limos code, i dont want to compile again XD

I already edited my post when I noticed you used different parameter names.
Atm position is nil since there is no parameter called like that.

Thank you Limos, i already forgot how many thanks i gaved to you... A LOT!!! :eek::eek::eek::D:D:p

SO FOR YOU GUYS IN THE FUTURE WITH THE SAME PROBLEM, THE SOLUTION IS:

1) Compile again with this code: https://otland.net/threads/walk-through-people-at-depot.233487/#post-2251706
OR
2) make a moveevent.
Create a script on data\movements\scripts called
dptile.lua
and add this:
Code:
function onStepIn(cid, item, position, fromPosition)
    if getTileInfo(position).creatures > 1 then
        doTeleportThing(cid, fromPosition, false)
    end
end
Then, on data\movements\movements.xml,
put this:

Code:
<movevent type="StepIn" itemid="11059" event="script" value="dptile.lua"/>

AND DONE! Dont forget that it will work only with item id 11059, that is a glowing switch.
You can change the idemid for the id of any item u want.

EDIT: I FOUND A BUG. READ DOWN POST!
 
Last edited:
@Limos , @ghettobird , @heba , @Tarek1337 , i got a problem.

I used Limos script (see above) but i found a bug.

When people logout in the depot tile, and other player enter in this tile, when the first people log IN again, she will be on the tile she log out, i mean, INSIDE OTHER GUY DEPOT XDDD

How can i solve that?
 
@Limos , @ghettobird , @heba , @Tarek1337 , i got a problem.

I used Limos script (see above) but i found a bug.

When people logout in the depot tile, and other player enter in this tile, when the first people log IN again, she will be on the tile she log out, i mean, INSIDE OTHER GUY DEPOT XDDD

How can i solve that?
sources then :p OR make it when u go onto a tile u get a storage, only the person with this storage gets access, if he leaves/logs out there's a 10 second wait before anyone else can get access

I'm not sure if it will work tho
 
If you login on the tile it's also a stepin action, if it doesn't have the last position you can add this.
Code:
if fromPosition.x == 0 then
       fromPosition = getTownTemplePosition(getPlayerTown(cid))
end
 
If you login on the tile it's also a stepin action, if it doesn't save the last position you can add this.
Code:
if fromPosition.x == 0 then
       fromPosition = getTownTemplePosition(getPlayerTown(cid))
end
Where should i add this?

sources then :p OR make it when u go onto a tile u get a storage, only the person with this storage gets access, if he leaves/logs out there's a 10 second wait before anyone else can get access

I'm not sure if it will work tho

Im getitng this erros while trying to compile:

player.cpp: In member function 'virtual bool Player::canWalkthrough(const Creature*) const':
player.cpp:897:51: error: 'pROTECTION_LEVEL' is not a member of 'ConfigManager'
CXX protocolgame.o
make[1]: *** [player.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory `/home/otserver/trunk'
make: *** [all] Error 2
 
Where should i add this?



Im getitng this erros while trying to compile:

player.cpp: In member function 'virtual bool Player::canWalkthrough(const Creature*) const':
player.cpp:897:51: error: 'pROTECTION_LEVEL' is not a member of 'ConfigManager'
CXX protocolgame.o
make[1]: *** [player.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory `/home/otserver/trunk'
make: *** [all] Error 2
do what limos said, in the movement script just add else then the code limos put :p
 
Code:
if fromPosition.x == 0 or (fromPosition.x == position.x and fromPosition.y == position.y) then
     fromPosition = getTownTemplePosition(getPlayerTown(cid))
end
Under: if getTileInfo(position).creatures > 1 then
 
Back
Top