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

Remove pz locked if player walk on protection zone

Fortera Global

Intermediate OT User
Joined
Nov 20, 2015
Messages
1,180
Solutions
2
Reaction score
117
Hello, someone can do this please? remove pzlocked if player is on protection zone

tfs 1.2

thankss
 
Solution
creaturescript create
removepz.lua
Lua:
function onThink(cid, interval)
if(getTilePzInfo(getCreaturePosition(cid))) then
doRemoveCondition(cid, CONDITION_INFIGHT)
end
end
creaturescript.lua add
Code:
     <event type="think" name="Removepz" script="removepz.lua" />
login.lua add

Code:
 player:registerEvent("Removepz")

Credits not mine
So.. How does one get onto the pz-zone, when they are pz-zone locked?
 
Usually this happens when you get teleported to the temple or depot, and if you are PZ locked, you have to relog in order to remove it. Perhaps that's what he meant, when player steps PZ tile with PZ locked automatically removes it.
 
replace
Code:
int LuaScriptInterface::luaCreatureTeleportTo(lua_State* L)
{
   // creature:teleportTo(position[, pushMovement = false], [removePZ = true] )
   bool removePZ = getBoolean(L, 4, false);
   bool pushMovement = getBoolean(L, 3, false);

   const Position& position = getPosition(L, 2);
   Creature* creature = getUserdata<Creature>(L, 1);
   if (!creature) {
       lua_pushnil(L);
       return 1;
   }

   const Position oldPosition = creature->getPosition();
   if (g_game.internalTeleport(creature, position, pushMovement) != RETURNVALUE_NOERROR) {
       pushBoolean(L, false);
       return 1;
   }

   if (!pushMovement) {
       if (oldPosition.x == position.x) {
           if (oldPosition.y < position.y) {
               g_game.internalCreatureTurn(creature, DIRECTION_SOUTH);
           } else {
               g_game.internalCreatureTurn(creature, DIRECTION_NORTH);
           }
       } else if (oldPosition.x > position.x) {
           g_game.internalCreatureTurn(creature, DIRECTION_WEST);
       } else if (oldPosition.x < position.x) {
           g_game.internalCreatureTurn(creature, DIRECTION_EAST);
       }
   }

   if (creature->getPlayer() && removePZ)
   {
       creature->removeCondition(CONDITION_INFIGHT, true);
   }
   pushBoolean(L, true);
   return 1;
}

i just added a new param, removePZ, set it to true if you want to remove pz when players get teleported
 
Last edited:
replace
Code:
int LuaScriptInterface::luaCreatureTeleportTo(lua_State* L)
{
   // creature:teleportTo(position[, pushMovement = false], [removePZ = true] )
   bool removePZ = getBoolean(L, 4, false);
   bool pushMovement = getBoolean(L, 3, false);

   const Position& position = getPosition(L, 2);
   Creature* creature = getUserdata<Creature>(L, 1);
   if (!creature) {
       lua_pushnil(L);
       return 1;
   }

   const Position oldPosition = creature->getPosition();
   if (g_game.internalTeleport(creature, position, pushMovement) != RETURNVALUE_NOERROR) {
       pushBoolean(L, false);
       return 1;
   }

   if (!pushMovement) {
       if (oldPosition.x == position.x) {
           if (oldPosition.y < position.y) {
               g_game.internalCreatureTurn(creature, DIRECTION_SOUTH);
           } else {
               g_game.internalCreatureTurn(creature, DIRECTION_NORTH);
           }
       } else if (oldPosition.x > position.x) {
           g_game.internalCreatureTurn(creature, DIRECTION_WEST);
       } else if (oldPosition.x < position.x) {
           g_game.internalCreatureTurn(creature, DIRECTION_EAST);
       }
   }

   if (creature->getPlayer() && removePZ)
   {
       creature->removeCondition(CONDITION_INFIGHT, true);
   }
   pushBoolean(L, true);
   return 1;
}

i just added a new param, removePZ, set it to true if you want to remove pz when players get teleported

The players get pz locked when shoot runes on ground, go into protection zone and some other players walk on runes
=/
thanks
 
Wouldn't a better approach to this be to give the player PZ as soon as he uses the field rune? This way it's not abuse-able by the player.
 
this would be so abusable with field runes
you can just hop in and out of pz freely as long as you're in pz whenever someone walks on the field
 
something like this:

Lua:
if creature:isPzLocked() then
if flag:PROTECTION_ZONE then
creature:remove()
end
end
someone can help figure out how can this work?
 
creaturescript create
removepz.lua
Lua:
function onThink(cid, interval)
if(getTilePzInfo(getCreaturePosition(cid))) then
doRemoveCondition(cid, CONDITION_INFIGHT)
end
end
creaturescript.lua add
Code:
     <event type="think" name="Removepz" script="removepz.lua" />
login.lua add

Code:
 player:registerEvent("Removepz")

Credits not mine
 
Last edited:
Solution
Back
Top