TFS 1.3 PVP Arena Script problem.

CesarZ

Active Member
Joined
Sep 20, 2012
Messages
222
Solutions
2
Reaction score
43
Alright the log is clean no errors appeared but its seems like is not executing the function because the players are dying.
I took the script from a old TFS 1.0 and I'm trying to change it to TFS 1.3.
I'm not running this in script folder I'm running it on XML file.


Lua:
function onLogin(cid)
    local player = Player(cid)
    player:registerEvent("Arena_Death")
return true
    end
  
    local arena = {
        from = {x=822, y=1056, z=9}, -- left top corner of  arena
        to = {x=857, y=1072, z=9}, -- right bottom corner of  arena
        temple = { x = 787, y = 1012, z = 7 } -- change it to temple pos
   }



local conditions = {CONDITION_POISON,
CONDITION_FIRE,
CONDITION_ENERGY,
CONDITION_PARALYZE,
CONDITION_DRUNK,
CONDITION_DROWN,
CONDITION_FREEZING,
CONDITION_DAZZLED,
CONDITION_INFIGHT,
CONDITION_EXHAUST_HEAL,
CONDITION_SPELLCOOLDOWN,
CONDITION_SPELLGROUPCOOLDOWN,
CONDITION_EXHAUST_COMBAT,
CONDITION_EXHAUSTED,
CONDITION_EXHAUST,
CONDITION_EXHAUST_WEAPON,
CONDITION_BLEEDING,
CONDITION_CURSED
}

    function onPrepareDeath(cid, killer)
        local player = creature(cid)
        if isInRange(getPlayerPosition(cid), arena.from,arena.to) then
            if isPlayer(cid) then
                player:addHealth(player:getMaxHealth())
                player:addMana(player:getMaxMana())
                player:teleportTo(arena.temple, true)
                player:removeCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT)
                doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You Have Exit the PVP-ARENA.")
                for _, condition in ipairs(conditions) do
                    if(player:getCondition(condition)) then
                        player:removeCondition(condition)
                    end
                end
                    if isInArray({SKULL_WHITE}, player:getSkull()) then
                    player:setSkull(SKULL_NONE)
                    player:setSkullTime(0)
                    end
              
                return false
            end
        end
       return true
    end
  
    function isInRange(pos, fromPos, toPos)
       return pos.x >= fromPos.x and pos.y >= fromPos.y and pos.z >= fromPos.z and pos.x <= toPos.x and pos.y <= toPos.y and pos.z <= toPos.z
    end
i saw the function registered in the cpp files
Code:
onPrepareDeath

i have it registered on XML as

Code:
<event type="preparedeath" name="Arena_Death" script="Arena_Death.lua"/>
<event type="login" name="Arena_Login" script="Arena_Death.lua"/>

let me know whats wrong thanks!.
 

Evil Puncker

prolonged absenteeism
TFS Developer
Joined
May 30, 2009
Messages
7,760
Solutions
187
Reaction score
3,557
put this on your data/scripts folder and test:

Lua:
local conditions = {
    CONDITION_POISON, CONDITION_FIRE,
    CONDITION_ENERGY, CONDITION_PARALYZE,
    CONDITION_DRUNK, CONDITION_DROWN,
    CONDITION_FREEZING, CONDITION_DAZZLED,
    CONDITION_BLEEDING, CONDITION_CURSED
}

local creatureevent = CreatureEvent("Arena_Death")

function creatureevent.onPrepareDeath(creature, killer)
    if creature:isPlayer() and creature:getPosition():isInRange(Position(822, 1056, 9), Position(857, 1072, 9))
        creature:addHealth(creature:getMaxHealth())
        creature:addMana(creature:getMaxMana())
        creature:teleportTo(arena.temple)
        creature:teleportTo(player:getTown():getTemplePosition())
        creature:removeCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT)
        creature:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You Have Exit the PVP-ARENA.")
        for _, condition in ipairs(conditions) do
            if creature:getCondition(condition) then
                creature:removeCondition(condition)
            end
        end
        if table.contains({SKULL_WHITE}, creature:getSkull()) then
            creature:setSkull(SKULL_NONE)
            creature:setSkullTime(0)
        end
    end
    return true
end

creatureevent:register()

local creatureevent2 = CreatureEvent("example")

function creatureevent2.onLogin(player)
    player:registerEvent("Arena_Death")
    return true
end

creatureevent2:register()
 
OP
CesarZ

CesarZ

Active Member
Joined
Sep 20, 2012
Messages
222
Solutions
2
Reaction score
43
put this on your data/scripts folder and test:

Lua:
local conditions = {
    CONDITION_POISON, CONDITION_FIRE,
    CONDITION_ENERGY, CONDITION_PARALYZE,
    CONDITION_DRUNK, CONDITION_DROWN,
    CONDITION_FREEZING, CONDITION_DAZZLED,
    CONDITION_BLEEDING, CONDITION_CURSED
}

local creatureevent = CreatureEvent("Arena_Death")

function creatureevent.onPrepareDeath(creature, killer)
    if creature:isPlayer() and creature:getPosition():isInRange(Position(822, 1056, 9), Position(857, 1072, 9)) then
        creature:addHealth(creature:getMaxHealth())
        creature:addMana(creature:getMaxMana())
        creature:teleportTo(787, 1012, 7)
        creature:teleportTo(player:getTown():getTemplePosition())
        creature:removeCondition(CONDITION_INFIGHT, CONDITIONID_DEFAULT)
        creature:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You Have Exit the PVP-ARENA.")
        for _, condition in ipairs(conditions) do
            if creature:getCondition(condition) then
                creature:removeCondition(condition)
            end
        end
        if table.contains({SKULL_WHITE}, creature:getSkull()) then
            creature:setSkull(SKULL_NONE)
            creature:setSkullTime(0)
        end
    end
    return true
end

creatureevent:register()

local creatureevent2 = CreatureEvent("example")

function creatureevent2.onLogin(player)
    player:registerEvent("Arena_Death")
    return true
end

creatureevent2:register()
It didn't work :/
 
Top