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
tfs 1.2
thankss
function onThink(cid, interval)
if(getTilePzInfo(getCreaturePosition(cid))) then
doRemoveCondition(cid, CONDITION_INFIGHT)
end
end
<event type="think" name="Removepz" script="removepz.lua" />
player:registerEvent("Removepz")
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;
}
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
k, i'll try to help you laterThe players get pz locked when shoot runes on ground, go into protection zone and some other players walk on runes
=/
thanks
I'm using it, but its not correctly, thankssWouldn'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.
if creature:isPzLocked() then
if flag:PROTECTION_ZONE then
creature:remove()
end
end
function onThink(cid, interval)
if(getTilePzInfo(getCreaturePosition(cid))) then
doRemoveCondition(cid, CONDITION_INFIGHT)
end
end
<event type="think" name="Removepz" script="removepz.lua" />
player:registerEvent("Removepz")