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

Add message when player is defeated

Manigold

Active Member
Joined
Nov 2, 2017
Messages
198
Solutions
8
Reaction score
48
i'm using a pvp arena scrip, and works fine , but i want to add a message when player is defeated , and to the player who won , like:
MESSAGE_STATUS_CONSOLE_BLUE,'[ARENA] You defeated (player name) .
MESSAGE_STATUS_CONSOLE_BLUE,'[ARENA] You where defeated by (player name) .
Someone can help me add this? (I'm using tfs 1.2) Here's my script :
Lua:
local arena = {
    frompos = {x=121, y=33, z=10},
    topos = {x=128, y=37, z=10},
    exit = {x=125, y=31, z=9}
}

local function exitArena(p)
    doSendMagicEffect(p.exit, 10)
    doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
    doTeleportThing(p.cid, p.exit, FALSE)
end

function onPrepareDeath(cid, killer)
    if isInArea(getPlayerPosition(cid), arena.frompos, arena.topos) then
    doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
        addEvent(exitArena, 100, {cid=cid, exit=arena.exit})
    end
    return FALSE
end

function isInArea(pos, fromPos, toPos)
    if pos.x >= fromPos.x and pos.x <= toPos.x then
        if pos.y >= fromPos.y and pos.y <= toPos.y then
            if pos.z >= fromPos.z and pos.z <= toPos.z then
                return true
            end
        end
    end
    return false
end 

function onLogin(player)
    player:registerEvent("pvparena")
    return true
end
 
Solution
Nvm, find out by myself =), close please.
Edit : Sorry i forgot to add the answer :p , here's my working script, actually i changed for a better one *--*

Lua:
function onLogin(cid)
cid:registerEvent("Arena_Death")
return true
end

local arena = {
     from = {x=121, y=33, z=10}, -- left top corner of  arena
     to = {x=128, y=37, z=10}, -- right bottom corner of  arena
     temple = { x = 125, y = 31, z = 9 } -- change it to exit pos

}
function onPrepareDeath(cid, killer)
    if isInRange(getPlayerPosition(cid), arena.from,arena.to) then
        if isPlayer(cid) then

            cid:sendTextMessage(MESSAGE_STATUS_WARNING,"[PVP Arena]: You have been defeated by " .. getCreatureName(killer,cid) .. ". You sux.")...
Nvm, find out by myself =), close please.
Edit : Sorry i forgot to add the answer :p , here's my working script, actually i changed for a better one *--*

Lua:
function onLogin(cid)
cid:registerEvent("Arena_Death")
return true
end

local arena = {
     from = {x=121, y=33, z=10}, -- left top corner of  arena
     to = {x=128, y=37, z=10}, -- right bottom corner of  arena
     temple = { x = 125, y = 31, z = 9 } -- change it to exit pos

}
function onPrepareDeath(cid, killer)
    if isInRange(getPlayerPosition(cid), arena.from,arena.to) then
        if isPlayer(cid) then

            cid:sendTextMessage(MESSAGE_STATUS_WARNING,"[PVP Arena]: You have been defeated by " .. getCreatureName(killer,cid) .. ". You sux.")
            Player(cid):addHealth(Player(cid):getMaxHealth())
            Player(cid):teleportTo(arena.temple, true)
            Player(killer):sendTextMessage(MESSAGE_STATUS_WARNING,"[PVP Arena]: You have defeated " .. getCreatureName(cid,killer) .. ". You are the best Fighter.")
            Player(killer):addHealth(Player(cid):getMaxHealth())
            Player(killer):teleportTo(arena.temple, true)
            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
 
Last edited:
Solution
Rules for the Support board
8. Removing Solved Content:
- If you solved your problem, post the solution, do not remove the content in your posts. Instead write the solution you found. This can help other users with the same problem.
- Threads with removed content are useless and are seen as spam.
- If you were able to solve the issue yourself, post the solution and report your own post so a moderator can tag it as the "Best Answer".
 
Back
Top