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

Can't throw items under ppl [game.cpp]

Gomgom

Member
Joined
Oct 1, 2009
Messages
135
Reaction score
18
Location
Egypt
I'm trying to edit game.cpp making ppl unable to throw stackable items under themselves/others
but there is something wrong

with this one
Code:
  if(!canThrowObjectTo(mapFromPos, mapToPos) && !player->hasCustomFlag(PlayerCustomFlag_CanThrowAnywhere))
   {
     player->sendCancelMessage(RET_CANNOTTHROW);
     return false;
   }

   //here
   if(toCylinder->getTile()->getCreatureCount() && item->isStackable())
   {
     player->sendCancelMessage(RET_CANNOTTHROW);
     return false;
   }
//here

items can't be thrown under ppl, they can't be worn, either
and when someone puts an item on, it returns the same cancel msg

with this one
Code:
  if(!canThrowObjectTo(mapFromPos, mapToPos) && !player->hasCustomFlag(PlayerCustomFlag_CanThrowAnywhere))
   {
     player->sendCancelMessage(RET_CANNOTTHROW);
     return false;
   }

   //here
   Tile* toTile = map->getTile(toPos);
   if(toTile->getCreatureCount() && item->isStackable())
   {
     player->sendCancelMessage(RET_CANNOTTHROW);
     return false;
   }
//here

items can't be thrown under ppl and when someone puts an item on the server crashes

I'd appreciate it if someone would tell me what i am missing.
 
never completely change the source, always add to the code, use an else if instead, if it crashes still then you can remove the else if and still have the original code
Code:
if(!canThrowObjectTo(mapFromPos, mapToPos) && !player->hasCustomFlag(PlayerCustomFlag_CanThrowAnywhere))
   {
     player->sendCancelMessage(RET_CANNOTTHROW);
     return false;
   }

   //here
   if(toCylinder->getTile()->getCreatureCount() && item->isStackable())
   {
     player->sendCancelMessage(RET_CANNOTTHROW);
     return false;
   }
//here

    //here
   Tile* toTile = map->getTile(toPos);
   else if(toTile->getCreatureCount() && item->isStackable())
   {
     player->sendCancelMessage(RET_CANNOTTHROW);
     return false;
   }
//here
 
it should be
Code:
if(!canThrowObjectTo(mapFromPos, mapToPos) && !player->hasCustomFlag(PlayerCustomFlag_CanThrowAnywhere))
{
player->sendCancelMessage(RET_CANNOTTHROW);
return false;
}

//here
Tile* toTile = map->getTile(toPos);
if(toCylinder->getTile()->getCreatureCount() && item->isStackable())
{
player->sendCancelMessage(RET_CANNOTTHROW);
return false;
}
else if(toTile->getCreatureCount() && item->isStackable())
{
player->sendCancelMessage(RET_CANNOTTHROW);
return false;
}
//here

Edit: Still not working though
 
Last edited:
Solved. just added "toTile"
here is the code :)

Code:
  Tile* toTile = map->getTile(toPos);
  if(toTile && toTile->getCreatureCount() && item->isStackable())
  {
  player->sendCancelMessage(RET_CANNOTTHROW);
  return false;
  }
 
Back
Top