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

[CREATURESCRIPTS] OnDeath 8.5 problem

f@bio

Fudera Otserver
Joined
Jul 10, 2007
Messages
213
Reaction score
0
Location
Brasil
Hello friends, i have on my server, a PVP arena, on 8.4 server work fine, because have a PLAYERDEATH script, but on 8.5 servers dont have this options, when a player death on my area, him dont loot nothing, but apear this error on console.

-- Error message:
Lua:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/Pvp_Arena.lua:onPrepareDeath

luaDoPlayerSendTextMessage(). Player not found

Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/Pvp_Arena.lua:onPrepareDeath

luaGetCreatureName(). Creature not found

Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/Pvp_Arena.lua:onPrepareDeath

data/creaturescripts/scripts/Pvp_Arena.lua:14: attempt to concatenate a boolean
value
stack traceback:
        data/creaturescripts/scripts/Pvp_Arena.lua:14: in function <data/creatur
escripts/scripts/Pvp_Arena.lua:7>
-- This DEATH on creaturescript:
Lua:
local arena = {
  frompos = {x=499, y=489, z=9},
  topos = {x=515, y=498, z=9},
  exit = {x=517, y=493, z=8} 
}

function onPrepareDeath(cid, lastHitKiller, mostDamageKiller)
  if isPlayer(cid) == TRUE then
    if isInArea(getPlayerPosition(cid), arena.frompos, arena.topos) then
      if doCreatureAddHealth(cid, getCreatureMaxHealth(cid) - getCreatureHealth(cid), TRUE) == TRUE then
        if doTeleportThing(cid, arena.exit) == TRUE then
          doSendMagicEffect(arena.exit, 10)
          doPlayerSendTextMessage(mostDamageKiller,MESSAGE_STATUS_CONSOLE_BLUE,'[ARENA] Você matou '..getPlayerName(cid)..'!')
          doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,'[ARENA] Você foi morto por '..getPlayerName(mostDamageKiller)..'!')
          return FALSE
        end
      end
    end
  end
  return TRUE
end
-- This TAG on creaturescripts
Lua:
<event type="preparedeath" name="Arenapvp"		event="script" value="Pvp_Arena.lua"/>

--Plx frients help me to solve this problem... thx for all...
 
Don't work for me... when a player death on arena, he come leave then but console reporte this error:
Lua:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/Pvp_Arena.lua:onPrepareDeath

luaDoPlayerSendTextMessage(). Player not found

Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/Pvp_Arena.lua:onPrepareDeath

luaGetCreatureName(). Creature not found

Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/Pvp_Arena.lua:onPrepareDeath

data/creaturescripts/scripts/Pvp_Arena.lua:14: attempt to concatenate a boolean
value
stack traceback:
        data/creaturescripts/scripts/Pvp_Arena.lua:14: in function <data/creatur
escripts/scripts/Pvp_Arena.lua:7>

-- Can help me?
 
Try:

Lua:
ArenaPVP = {
      -- frompos              --topos      -- exit
{{x=499, y=489, z=9}, {x=515, y=498, z=9}, {x=517, y=493, z=8}} --1
}

function onPrepareDeath(cid, deathList)

for i=1, #deathList do

  if isPlayer(deathList[i]) == TRUE then
    for _, area in pairs(ArenaPVP) do
        if isInArea(getPlayerPosition(cid), area[1], area[2]) == TRUE then
doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_RED,'Owned')
doPlayerSendTextMessage(deathList[i],MESSAGE_STATUS_CONSOLE_ORANGE,'You kill: '.. getPlayerName(cid).. '')
if doTeleportThing(cid, area[3])
end

 end
  end
  end
  return TRUE
end
 
@GSMASTER your script have litle errors but i'm edit and now work fine, many thx for help me on it, but ia have other problem with other script, but its equal this erros...

-- This script you make for me its PVP ARENA...

-- My new script is TOURNAMENT ARENA:
-- Here Script:
Lua:
function onPrepareDeath(cid, killer, mostDamageKiller)
---By Far Carder
    setGlobalStorageValue(getPlayerStoredID(cid), -1)
     if AUTO_PVP_ARENA_CONFIG.RECORD_DEATH and isPlayer(cid) then

---from here to next comment line is taken from playerdeaths.lua, not by me!

local config = {
	    deathListEnabled = getBooleanFromString(getConfigInfo('deathListEnabled')),
	    sqlType = getConfigInfo('sqlType'),
	    maxDeathRecords = getConfigInfo('maxDeathRecords')
}

        config.sqlType = config.sqlType == "sqlite" and DATABASE_ENGINE_SQLITE or DATABASE_ENGINE_MYSQL
	local lastHitKiller = killer
	local hitKillerName = "field item"
	local damageKillerName = ""
    if(lastHitKiller ~= FALSE) then
    if(isPlayer(lastHitKiller) == TRUE) then
    	hitKillerName = getPlayerGUID(lastHitKiller)
    else
        hitKillerName = getCreatureName(lastHitKiller)
    end
    if(mostDamageKiller ~= FALSE and mostDamageKiller ~= lastHitKiller and getCreatureName(mostDamageKiller) ~= getCreatureName(lastHitKiller)) then
    if(isPlayer(mostDamageKiller) == TRUE) then
        damageKillerName = getPlayerGUID(mostDamageKiller)
    else
        damageKillerName = getCreatureName(mostDamageKiller)
    end 
       end
          end
        db.executeQuery("INSERT INTO `player_deaths` (`player_id`, `time`, `level`, `killed_by`, `altkilled_by`) VALUES (" .. getPlayerGUID(cid) .. ", " .. os.time() .. ", " .. getPlayerLevel(cid) .. ", " .. db.escapeString(hitKillerName) .. ", " .. db.escapeString(damageKillerName) .. ");")
	local rows = db.getResult("SELECT `player_id` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. ";")        if(rows:getID() ~= -1) then
	local amount = rows:getRows(true) - config.maxDeathRecords
    if(amount > 0) then
    if(config.sqlType == DATABASE_ENGINE_SQLITE) then
    for i = 1, amount do
    	db.executeQuery("DELETE FROM `player_deaths` WHERE `rowid` = (SELECT `rowid` FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. " ORDER BY `time` LIMIT 1);")
    end
    else
    	db.executeQuery("DELETE FROM `player_deaths` WHERE `player_id` = " .. getPlayerGUID(cid) .. " ORDER BY `time` LIMIT " .. amount .. ";")
    end
       end
       	  end
       	     ---end of copied code
       	     	   end
    if not isPlayer(killer) then
       killer = getCreatureMaster(killer)
    end
    
    local BODY = getBodyArena(cid, AUTO_PVP_ARENA_CONFIG.ARENAS)
    if BODY ~= 0 then
       local ARENA_DETAILS = AUTO_PVP_ARENA_CONFIG.ARENAS[BODY]
       addEvent(doTheRest, 1000, {killer = killer, ARENA_DETAILS = ARENA_DETAILS, cid = cid})
    end
       doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, AUTO_PVP_ARENA_CONFIG.LOSER_MSG)
    if not AUTO_PVP_ARENA_CONFIG.KILL_LOSER then            
       doCreatureAddHealth(cid, getCreatureMaxHealth(cid))                     
       doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)            
       doTeleportThing(cid, AUTO_PVP_ARENA_CONFIG.LOSER_POS, TRUE)            
       doSendMagicEffect(AUTO_PVP_ARENA_CONFIG.LOSER_POS, CONST_ME_ENERGYAREA)            
       return -1                
    else            
       return TRUE        
    end    
       return TRUE
    end
    
function getBodyArena(body, arenas)local pos = getCreaturePosition(body)    
    for i = 1, 7 do        
    if pos.x >= arenas[i].top_left.x and pos.x <= arenas[i].bottom_right.x then            
    if pos.y >= arenas[i].top_left.y and pos.y <= arenas[i].bottom_right.y then                
       return i            
    end        
    end    
    end        
       return FALSE
    end

function getPlayerStoredID(cid)    
    for x = 1, #AUTO_PVP_ARENA_CONFIG.SWITCH_UIDS do        
    if getGlobalStorageValue(AUTO_PVP_ARENA_CONFIG.SWITCH_UIDS[x]) == cid then            
       return AUTO_PVP_ARENA_CONFIG.SWITCH_UIDS[x]        
    end
       end
       	  end

function getUsedStoreValues()local values = {}    
    for x = 1, #AUTO_PVP_ARENA_CONFIG.SWITCH_UIDS do        
    if getGlobalStorageValue(AUTO_PVP_ARENA_CONFIG.SWITCH_UIDS[x]) > 1 then            
       table.insert(values, AUTO_PVP_ARENA_CONFIG.SWITCH_UIDS[x])        
    end
    end        
    return values
    end 
    
function doTheRest(p)local killer = p.killerlocal ARENA_DETAILS = p.ARENA_DETAILS    																						doSendMagicEffect(getCreaturePosition(killer), CONST_ME_POFF)    
    	doTeleportThing(killer, ARENA_DETAILS.winner_pos)    
    	doSendMagicEffect(ARENA_DETAILS.winner_pos, CONST_ME_ENERGYAREA)    
    for x1 = ARENA_DETAILS.top_left.x, ARENA_DETAILS.bottom_right.x do        
    for y1 = ARENA_DETAILS.top_left.y, ARENA_DETAILS.bottom_right.y do            
    	
    local check_pos = {x = x1, y = y1, z = Z_POS, stackpos = 255}            
    local field_pos = {x = x1, y = y1, z = Z_POS, stackpos = 254}            
    local checked = getThingfromPos(check_pos)            
    local checked2 = getThingfromPos(field_pos)                
    
    while (checked.uid > 0 or checked2.uid > 0) do                    
    if checked.uid > 0 then                        
    if isCreature(checked.uid) then                            
        doRemoveCreature(checked.uid)                            
    	doSendMagicEffect(check_pos, CONST_ME_MAGIC_RED)                        
    else                            
    if doRemoveItem(checked.uid, 1) == 1 then                                
        doSendMagicEffect(check_pos, CONST_ME_MAGIC_RED)                            
    end                        end                    
    elseif checked2.uid > 0 then                        
    if doRemoveItem(checked2.uid, 1) == 1 then                            
        doSendMagicEffect(check_pos, CONST_ME_MAGIC_RED)                        
    end
    end                    
        checked = getThingfromPos(check_pos)                    
    	checked2 = getThingfromPos(field_pos)                
    end            
    	doSendMagicEffect(check_pos, CONST_ME_MAGIC_BLUE)        
    end    
    end         
    if ARENA_DETAILS.winners_for_advance ~= 0 then    
        local WINNER_STORE_VALUES = getUsedStoreValues()        
    if #WINNER_STORE_VALUES == ARENA_DETAILS.winners_for_advance then            
    for a = 1, #WINNER_STORE_VALUES do            
    
    local player = getGlobalStorageValue(WINNER_STORE_VALUES[a])            
    local pos = AUTO_PVP_ARENA_CONFIG.ARENAS[getArenaNumber(player)].next_arena_pos
        doSendMagicEffect(getCreaturePosition(player), CONST_ME_POFF)                
    	doTeleportThing(player,pos)                
    	doSendMagicEffect(pos, CONST_ME_ENERGYAREA)               
     	doPlayerSendTextMessage(player, MESSAGE_STATUS_WARNING, FIGHT_MSG)            
    end                
        setGlobalStorageValue(AUTO_PVP_ARENA_CONFIG.PLAYERS_IN_ARENA_STORE, (getGlobalStorageValue(AUTO_PVP_ARENA_CONFIG.PLAYERS_IN_ARENA_STORE) + 1))        
    end
    else        
        setGlobalStorageValue(AUTO_PVP_ARENA_CONFIG.PLAYERS_IN_ARENA_STORE, -1)    
    end
    end 
     
function getArenaNumber(player)
local round = getGlobalStorageValue(AUTO_PVP_ARENA_CONFIG.PLAYERS_IN_ARENA_STORE)
local player = getPlayerStoredID(player) - AUTO_PVP_ARENA_CONFIG.SWITCH_UIDS[1] + 1    
     if round == 1 then        
     if player == 1 or player == 2 then            
     	return 1        
     elseif player == 3 or player == 4 then
     	return 2        
     elseif player == 5 or player == 6 then            
        return 3        
     elseif player == 7 or player == 8 then            
        return 4        
     end    
     elseif round == 2 then        
local round2a1 = {1, 2, 3, 4}        
local round2a2 = {5, 6, 7, 8}            
     if isInArray(round2a1, player) == TRUE then                
        return 5            
     elseif isInArray(round2a2, player) == TRUE then                
        return 6            
     end    
     
     end         
     
     end
-- On this event have this errors on console when player death on arena:
Lua:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/Tounament.lua:onPrepareDeath

luaGetCreatureMaster(). Creature not found

Lua Script Error: [CreatureScript Interface]
in a timer event called from:
data/creaturescripts/scripts/Tounament.lua:onPrepareDeath

luaGetCreaturePosition(). Creature not found

Lua Script Error: [CreatureScript Interface]
in a timer event called from:
data/creaturescripts/scripts/Tounament.lua:onPrepareDeath

attempt to index a boolean value
stack traceback:
        [C]: in function 'doSendMagicEffect'
        data/creaturescripts/scripts/Tounament.lua:97: in function <data/creatur
escripts/scripts/Tounament.lua:97>

-- Can you help me on it too??? Many thx for your helping and REP++ for you...
 
also had a problem with that, try this:


Lua:
function onKill(cid, Killer, mostDamageKiller)

    setGlobalStorageValue(getPlayerStoredID(Killer), -1)

    if not isPlayer(cid) then
        lastHitKillers = getCreatureMaster(cid)     
    end

    local BODY = getBodyArena(cid, AUTO_PVP_ARENA_CONFIG.ARENAS)
        if BODY ~= 0 then
        local ARENA_DETAILS = AUTO_PVP_ARENA_CONFIG.ARENAS[BODY]
		
        addEvent(doTheRest, 1000, {lastHitKillers = lastHitKillers, ARENA_DETAILS = ARENA_DETAILS, cid = cid})
        
doPlayerSendTextMessage(Killer, MESSAGE_STATUS_WARNING, "Win " .. getPlayerName(cid) .. " - Next time :)")
setPlayerStorageValue(Killer, PLAYERS_IN_BUDOKAI_STORE_PLAYER, 1)
setPlayerStorageValue(cid, PLAYERS_IN_BUDOKAI_STORE_PLAYER, 1)
return 1
end  
    return 1
end

function getBodyArena(body, arenas)
local pos = getCreaturePosition(body)
    for i = 1, 7 do
        if pos.x >= arenas[i].top_left.x and pos.x <= arenas[i].bottom_right.x then
            if pos.y >= arenas[i].top_left.y and pos.y <= arenas[i].bottom_right.y then
                return i
            end
        end
    end
        return 0
end

function getPlayerStoredID(cid)
    for x = 1, #AUTO_PVP_ARENA_CONFIG.SWITCH_UIDS do
        if getGlobalStorageValue(AUTO_PVP_ARENA_CONFIG.SWITCH_UIDS[x]) == cid then
            return AUTO_PVP_ARENA_CONFIG.SWITCH_UIDS[x]
        end
    end
end

function getUsedStoreValues()
local values = {}
    for x = 1, #AUTO_PVP_ARENA_CONFIG.SWITCH_UIDS do
        if getGlobalStorageValue(AUTO_PVP_ARENA_CONFIG.SWITCH_UIDS[x]) > 1 then
            table.insert(values, AUTO_PVP_ARENA_CONFIG.SWITCH_UIDS[x])
        end
    end
        return values
end

function doTheRest(p)
local cid = p.cid
local ARENA_DETAILS = p.ARENA_DETAILS

    doSendMagicEffect(getCreaturePosition(cid), 2)
    doTeleportThing(cid, ARENA_DETAILS.winner_pos)
    doSendMagicEffect(ARENA_DETAILS.winner_pos, 121)
doCreatureAddHealth(cid, getCreatureMaxHealth(cid) - getCreatureHealth(cid), TRUE)
doCreatureAddMana(cid, getCreatureMaxMana(cid) - getCreatureMana(cid), TRUE)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Winner")

    for x1 = ARENA_DETAILS.top_left.x, ARENA_DETAILS.bottom_right.x do
        for y1 = ARENA_DETAILS.top_left.y, ARENA_DETAILS.bottom_right.y do
            local check_pos = {x = x1, y = y1, z = Z_POS, stackpos = 255}
            local field_pos = {x = x1, y = y1, z = Z_POS, stackpos = 254}
            local checked = getThingfromPos(check_pos)
            local checked2 = getThingfromPos(field_pos)
                while (checked.uid > 0 or checked2.uid > 0) do
                    if checked.uid > 0 then
                        if isCreature(checked.uid) then
                            doRemoveCreature(checked.uid)
                        else
                            if doRemoveItem(checked.uid, 1) == 1 then
                            end
                        end
                    elseif checked2.uid > 0 then
                        if doRemoveItem(checked2.uid, 1) == 1 then
                        end
                    end

                    checked = getThingfromPos(check_pos)
                    checked2 = getThingfromPos(field_pos)
                end
        end
    end
   
    if ARENA_DETAILS.winners_for_advance ~= 0 then
    local WINNER_STORE_VALUES = getUsedStoreValues()
        if #WINNER_STORE_VALUES == ARENA_DETAILS.winners_for_advance then
            for a = 1, #WINNER_STORE_VALUES do
            local player = getGlobalStorageValue(WINNER_STORE_VALUES[a])
            local pos = AUTO_PVP_ARENA_CONFIG.ARENAS[getArenaNumber(player)].next_arena_pos
                doSendMagicEffect(getCreaturePosition(player), CONST_ME_POFF)
                doTeleportThing(player,pos)
                doSendMagicEffect(pos, 121)
            end
                setGlobalStorageValue(AUTO_PVP_ARENA_CONFIG.PLAYERS_IN_ARENA_STORE, (getGlobalStorageValue(AUTO_PVP_ARENA_CONFIG.PLAYERS_IN_ARENA_STORE) + 1))
        end
    else
        setGlobalStorageValue(AUTO_PVP_ARENA_CONFIG.PLAYERS_IN_ARENA_STORE, -1)
		setGlobalStorageValue(1101, -1)
		setGlobalStorageValue(1102, -1)
		setGlobalStorageValue(1103, -1)
		setGlobalStorageValue(1104, -1)
		setGlobalStorageValue(1105, -1)
		setGlobalStorageValue(1106, -1)
		setGlobalStorageValue(1107, -1)
		setGlobalStorageValue(1108, -1)
    end
end

function getArenaNumber(player)
local round = getGlobalStorageValue(AUTO_PVP_ARENA_CONFIG.PLAYERS_IN_ARENA_STORE)
local player = getPlayerStoredID(player) - AUTO_PVP_ARENA_CONFIG.SWITCH_UIDS[1] + 1
    if round == 1 then
        if player == 1 or player == 2 then
            return 1
        elseif player == 3 or player == 4 then
            return 2
        elseif player == 5 or player == 6 then
            return 3
        elseif player == 7 or player == 8 then
            return 4
        end
    elseif round == 2 then
        local round2a1 = {1, 2, 3, 4}
        local round2a2 = {5, 6, 7, 8}
            if isInArray(round2a1, player) == TRUE then
                return 5
            elseif isInArray(round2a2, player) == TRUE then
                return 6
            end
    end        
end

remember:
Lua:
<event type="kill" name="PVPArenaDeaths" event="script" value="pvparena_deaths.lua"/>
 
@GSMaster

--Can you send me your complete TOURNAMENT SYSTEM??? On my have errors here, THE CHARACTERS don't sended to AREA of TOURNAMENT, when player DEATH, him dont DEATH and dont TELEPORTED, hum stay with BLACK LIFE and use HEAL SPELLS but don't death.

--Apears this error on console after i'm kill a player on Tournament:
Lua:
Lua Script Error: [CreatureScript Interface]
in a timer event called from:
data/creaturescripts/scripts/Tounament.lua:onKill

data/creaturescripts/scripts/Tounament.lua:58: attempt to index local 'ARENA_DET
AILS' (a nil value)
stack traceback:
        data/creaturescripts/scripts/Tounament.lua:58: in function <data/creatur
escripts/scripts/Tounament.lua:53>

Lua Script Error: [CreatureScript Interface]
in a timer event called from:
data/creaturescripts/scripts/Tounament.lua:onKill

data/creaturescripts/scripts/Tounament.lua:58: attempt to index local 'ARENA_DET
AILS' (a nil value)
stack traceback:
        data/creaturescripts/scripts/Tounament.lua:58: in function <data/creatur
escripts/scripts/Tounament.lua:53>

Lua Script Error: [CreatureScript Interface]
in a timer event called from:
data/creaturescripts/scripts/Tounament.lua:onKill

data/creaturescripts/scripts/Tounament.lua:58: attempt to index local 'ARENA_DET
AILS' (a nil value)
stack traceback:
        data/creaturescripts/scripts/Tounament.lua:58: in function <data/creatur
escripts/scripts/Tounament.lua:53>

Lua Script Error: [CreatureScript Interface]
in a timer event called from:
data/creaturescripts/scripts/Tounament.lua:onKill

data/creaturescripts/scripts/Tounament.lua:58: attempt to index local 'ARENA_DET
AILS' (a nil value)
stack traceback:
        data/creaturescripts/scripts/Tounament.lua:58: in function <data/creatur
escripts/scripts/Tounament.lua:53>
--Can you help me with this?
 
Last edited:
You must set PVP Zone the arenas

remember:
Lua:
  <event type="kill" name="PVPArenaDeaths" event="script" value="pvparena_deaths.lua"/>
 
I'm register this on CREATURESCRIPT, my scripts donts equal name it your.

--when all 8 players step on a special tile, this error apear on console:
Lua:
Lua Script Error: [MoveEvents Interface]
data/movements/scripts/Tournament.lua:onStepIn

luaRegisterCreatureEvent(). Creature not found

Lua Script Error: [MoveEvents Interface]
data/movements/scripts/Tournament.lua:onStepIn

luaGetCreaturePosition(). Creature not found

Lua Script Error: [MoveEvents Interface]
data/movements/scripts/Tournament.lua:onStepIn

attempt to index a boolean value
stack traceback:
        [C]: in function 'doSendMagicEffect'
        data/movements/scripts/Tournament.lua:17: in function <data/movements/sc
ripts/Tournament.lua:1>

-- See here my all scripts of tournament arena:

-- This creaturescript:
Lua:
<event type="kill" name="TourPVP" event="script" value="Tounament.lua"/>
-- This script on creaturescripts named by Tounament.lua
Lua:
function onKill(cid, Killer, mostDamageKiller)

    setGlobalStorageValue(getPlayerStoredID(Killer), -1)

    if not isPlayer(cid) then
        lastHitKillers = getCreatureMaster(cid)     
    end

    local BODY = getBodyArena(cid, AUTO_PVP_ARENA_CONFIG.ARENAS)
        if BODY ~= 0 then
        local ARENA_DETAILS = AUTO_PVP_ARENA_CONFIG.ARENAS[BODY]
                
        addEvent(doTheRest, 1000, {lastHitKillers = lastHitKillers, ARENA_DETAILS = ARENA_DETAILS, cid = cid})
        
doPlayerSendTextMessage(Killer, MESSAGE_STATUS_WARNING, "Win " .. getPlayerName(cid) .. " - Next time :)")
setPlayerStorageValue(Killer, PLAYERS_IN_BUDOKAI_STORE_PLAYER, 1)
setPlayerStorageValue(cid, PLAYERS_IN_BUDOKAI_STORE_PLAYER, 1)
return TRUE
end  
    return TRUE
end

function getBodyArena(body, arenas)
local pos = getCreaturePosition(body)
    for i = 1, 7 do
        if pos.x >= arenas[i].top_left.x and pos.x <= arenas[i].bottom_right.x then
            if pos.y >= arenas[i].top_left.y and pos.y <= arenas[i].bottom_right.y then
                return i
            end
        end
    end
        return FALSE
end

function getPlayerStoredID(cid)
    for x = 1, #AUTO_PVP_ARENA_CONFIG.SWITCH_UIDS do
        if getGlobalStorageValue(AUTO_PVP_ARENA_CONFIG.SWITCH_UIDS[x]) == cid then
            return AUTO_PVP_ARENA_CONFIG.SWITCH_UIDS[x]
        end
    end
end

function getUsedStoreValues()
local values = {}
    for x = 1, #AUTO_PVP_ARENA_CONFIG.SWITCH_UIDS do
        if getGlobalStorageValue(AUTO_PVP_ARENA_CONFIG.SWITCH_UIDS[x]) > 1 then
            table.insert(values, AUTO_PVP_ARENA_CONFIG.SWITCH_UIDS[x])
        end
    end
        return values
end

function doTheRest(p)
local cid = p.cid
local ARENA_DETAILS = p.ARENA_DETAILS

    doSendMagicEffect(getCreaturePosition(cid), 2)
    doTeleportThing(cid, ARENA_DETAILS.winner_pos)
    doSendMagicEffect(ARENA_DETAILS.winner_pos, 121)
doCreatureAddHealth(cid, getCreatureMaxHealth(cid) - getCreatureHealth(cid), TRUE)
doCreatureAddMana(cid, getCreatureMaxMana(cid) - getCreatureMana(cid), TRUE)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Winner")

    for x1 = ARENA_DETAILS.top_left.x, ARENA_DETAILS.bottom_right.x do
        for y1 = ARENA_DETAILS.top_left.y, ARENA_DETAILS.bottom_right.y do
            local check_pos = {x = x1, y = y1, z = Z_POS, stackpos = 255}
            local field_pos = {x = x1, y = y1, z = Z_POS, stackpos = 254}
            local checked = getThingfromPos(check_pos)
            local checked2 = getThingfromPos(field_pos)
                while (checked.uid > 0 or checked2.uid > 0) do
                    if checked.uid > 0 then
                        if isCreature(checked.uid) then
                            doRemoveCreature(checked.uid)
                        else
                            if doRemoveItem(checked.uid, 1) == 1 then
                            end
                        end
                    elseif checked2.uid > 0 then
                        if doRemoveItem(checked2.uid, 1) == 1 then
                        end
                    end

                    checked = getThingfromPos(check_pos)
                    checked2 = getThingfromPos(field_pos)
                end
        end
    end
   
    if ARENA_DETAILS.winners_for_advance ~= 0 then
    local WINNER_STORE_VALUES = getUsedStoreValues()
        if #WINNER_STORE_VALUES == ARENA_DETAILS.winners_for_advance then
            for a = 1, #WINNER_STORE_VALUES do
            local player = getGlobalStorageValue(WINNER_STORE_VALUES[a])
            local pos = AUTO_PVP_ARENA_CONFIG.ARENAS[getArenaNumber(player)].next_arena_pos
                doSendMagicEffect(getCreaturePosition(player), CONST_ME_POFF)
                doTeleportThing(player,pos)
                doSendMagicEffect(pos, 121)
            end
                setGlobalStorageValue(AUTO_PVP_ARENA_CONFIG.PLAYERS_IN_ARENA_STORE, (getGlobalStorageValue(AUTO_PVP_ARENA_CONFIG.PLAYERS_IN_ARENA_STORE) + 1))
        end
    else
        setGlobalStorageValue(AUTO_PVP_ARENA_CONFIG.PLAYERS_IN_ARENA_STORE, -1)
                setGlobalStorageValue(1101, -1)
                setGlobalStorageValue(1102, -1)
                setGlobalStorageValue(1103, -1)
                setGlobalStorageValue(1104, -1)
                setGlobalStorageValue(1105, -1)
                setGlobalStorageValue(1106, -1)
                setGlobalStorageValue(1107, -1)
                setGlobalStorageValue(1108, -1)
    end
end

function getArenaNumber(player)
local round = getGlobalStorageValue(AUTO_PVP_ARENA_CONFIG.PLAYERS_IN_ARENA_STORE)
local player = getPlayerStoredID(player) - AUTO_PVP_ARENA_CONFIG.SWITCH_UIDS[1] + 1
    if round == 1 then
        if player == 1 or player == 2 then
            return 1
        elseif player == 3 or player == 4 then
            return 2
        elseif player == 5 or player == 6 then
            return 3
        elseif player == 7 or player == 8 then
            return 4
        end
    elseif round == 2 then
        local round2a1 = {1, 2, 3, 4}
        local round2a2 = {5, 6, 7, 8}
            if isInArray(round2a1, player) == TRUE then
                return 5
            elseif isInArray(round2a2, player) == TRUE then
                return 6
            end
    end        
end
-- This registered on my CONSTANT.lua in LIB folder:
Lua:
------------------------------------------------ PVP Tounament -----------------------------------------------------

Z_POS = 8 --- all the arena's must be on the same floor, put the floor number here (this cannot be put inside the table since it is used in the table)

AUTO_PVP_ARENA_CONFIG = {    
    PLAYERS_IN_ARENA_STORE = 110000, ---only change this if its being used by another quest    
    SWITCH_UIDS = {1101, 1102, 1103, 1104, 1105, 1106, 1107, 1108}, ---only change these if they are being used by other quests, make sure they run in order and they are the UID of the switches    
    PLAYER_TP_POS = {        
    {x = 549, y = 478, z = Z_POS},   ---where player 1 will be teleported to for the first arena (must be in the first arena)        
    {x = 549, y = 480, z = Z_POS},  ---where player 2 will be teleported to for the first arena (must be in the first arena)        
    {x = 549, y = 482, z = Z_POS},  ---where player 3 will be teleported to for the first arena (must be in the second arena)        
    {x = 550, y = 481, z = Z_POS},  ---where player 4 will be teleported to for the first arena (must be in the second arena)        
    {x = 551, y = 479, z = Z_POS},  ---where player 5 will be teleported to for the first arena (must be in the third arena)        
    {x = 552, y = 478, z = Z_POS},  ---where player 6 will be teleported to for the first arena (must be in the third arena)        
    {x = 552, y = 480, z = Z_POS},  ---where player 7 will be teleported to for the first arena (must be in the fourth arena)        
    {x = 551, y = 482, z = Z_POS}   ---where player 8 will be teleported to for the first arena (must be in the fourth arena)    
    },    
    CANCEL_MSG = "You cannot enter while a tournament is already being held.",   ---the message a player gets if they stand on the switch and a tournament is already being held    
    FIGHT_MSG = "Fight!!!",   ---the message each player gets as the next round starts      
    KILL_LOSER = false,   ---if this is true then the loser really dies, if its false then the player gets teleported to LOSER_POS with full health and no losses    
    RECORD_DEATH = false,   ---change this to false if you dont want the players death to be recorded on their deathlist (you can record the death even if KILL_LOSER is true)    
    LOSER_POS = {x = 551, y = 475, z = Z_POS},   ---if KILL_LOSER is false then the losers will be teleported here    
    LOSER_MSG = "You lost.",   ---if KILL_LOSER is false then the player gets this message as they are teleported out    
    ARENAS = {    
    --[[This next part is pretty trick to work out.            
    	     *Each line is a new arena, starting with the first and finishing with the seventh.            
	     *for top_left put the position of the top left hand corner of the arena            
	     *for bottom_right put the position of the bottom right hand corner of the arena            
	     *for winner_pos put the position the winner will first be teleported to. This should be a little room near by for while he waits for the other winner            
	     *for next_arena_pos you should put the starting position for the next round, so it must be in the next arena (NOTE: this is where they will be teleported to AFTER winner_pos when there next round begins)
	     *DO NOT touch winners_for_advance, you dont need to change it ;)    
    ]]--        
    {top_left = {x = 501, y = 400, z = Z_POS}, bottom_right = {x = 508, y = 410, z = Z_POS}, winner_pos = {x = 546, y = 381, z = Z_POS}, next_arena_pos = {x = 506, y = 382, z = Z_POS}, winners_for_advance = 4},  ---1st arena        
    {top_left = {x = 516, y = 400, z = Z_POS}, bottom_right = {x = 523, y = 410, z = Z_POS}, winner_pos = {x = 549, y = 384, z = Z_POS}, next_arena_pos = {x = 506, y = 392, z = Z_POS}, winners_for_advance = 4},  ---2nd arena        
    {top_left = {x = 531, y = 400, z = Z_POS}, bottom_right = {x = 538, y = 410, z = Z_POS}, winner_pos = {x = 547, y = 389, z = Z_POS}, next_arena_pos = {x = 521, y = 382, z = Z_POS}, winners_for_advance = 4},  ---3rd arena        
    {top_left = {x = 546, y = 400, z = Z_POS}, bottom_right = {x = 553, y = 410, z = Z_POS}, winner_pos = {x = 548, y = 392, z = Z_POS}, next_arena_pos = {x = 521, y = 392, z = Z_POS}, winners_for_advance = 4},  ---4th arena        
    {top_left = {x = 503, y = 382, z = Z_POS}, bottom_right = {x = 510, y = 392, z = Z_POS}, winner_pos = {x = 558, y = 381, z = Z_POS}, next_arena_pos = {x = 536, y = 382, z = Z_POS}, winners_for_advance = 2},  ---5th arena        
    {top_left = {x = 518, y = 762, z = Z_POS}, bottom_right = {x = 525, y = 392, z = Z_POS}, winner_pos = {x = 555, y = 384, z = Z_POS}, next_arena_pos = {x = 536, y = 392, z = Z_POS}, winners_for_advance = 2},  ---6th arena        
    {top_left = {x = 533, y = 782, z = Z_POS}, bottom_right = {x = 540, y = 392, z = Z_POS}, winner_pos = {x = 557, y = 392, z = Z_POS}, winners_for_advance = 0}                                                   ---7th arena    
    }
    }
-- This my movements.xml
Lua:
<!-- PVP Tournament -->
	<movevent type="StepIn" uniqueid="1101" event="script" value="Tournament.lua"/>    
	<movevent type="StepOut" uniqueid="1101" event="script" value="Tournament.lua"/>    
	<movevent type="StepIn" uniqueid="1102" event="script" value="Tournament.lua"/>    
	<movevent type="StepOut" uniqueid="1102" event="script" value="Tournament.lua"/>    
	<movevent type="StepIn" uniqueid="1103" event="script" value="Tournament.lua"/>    
	<movevent type="StepOut" uniqueid="1103" event="script" value="Tournament.lua"/>    
	<movevent type="StepIn" uniqueid="1104" event="script" value="Tournament.lua"/>    
	<movevent type="StepOut" uniqueid="1104" event="script" value="Tournament.lua"/>    
	<movevent type="StepIn" uniqueid="1105" event="script" value="Tournament.lua"/>    
	<movevent type="StepOut" uniqueid="1105" event="script" value="Tournament.lua"/>    
	<movevent type="StepIn" uniqueid="1106" event="script" value="Tournament.lua"/>    
	<movevent type="StepOut" uniqueid="1106" event="script" value="Tournament.lua"/>    
	<movevent type="StepIn" uniqueid="1107" event="script" value="Tournament.lua"/>    
	<movevent type="StepOut" uniqueid="1107" event="script" value="Tournament.lua"/>    
	<movevent type="StepIn" uniqueid="1108" event="script" value="Tournament.lua"/>    
	<movevent type="StepOut" uniqueid="1108" event="script" value="Tournament.lua"/>
-- This my Tournament.lua on folder scripts of movements:
Lua:
function onStepIn(cid, item, pos)
---By Far Carderlocal

PLAYERS_IN_ARENA = getGlobalStorageValue(AUTO_PVP_ARENA_CONFIG.PLAYERS_IN_ARENA_STORE)

        doTransformItem(item.uid, 425)        
    if PLAYERS_IN_ARENA < 1 and isPlayer(cid) then            
        setGlobalStorageValue(item.uid, cid)                
    
    if getNumberOfPlayersOnSwitchs() == #AUTO_PVP_ARENA_CONFIG.SWITCH_UIDS then                    
        setGlobalStorageValue(AUTO_PVP_ARENA_CONFIG.PLAYERS_IN_ARENA_STORE, 1)                        
    
    for a = 1, #AUTO_PVP_ARENA_CONFIG.SWITCH_UIDS do                            
    	local player = getGlobalStorageValue(AUTO_PVP_ARENA_CONFIG.SWITCH_UIDS[a])                            
    	local pos = AUTO_PVP_ARENA_CONFIG.PLAYER_TP_POS[a]                            
    	registerCreatureEvent(player, "TourPVP")                            
    	doSendMagicEffect(getCreaturePosition(player), CONST_ME_POFF)                            
    	doTeleportThing(player, pos)                            
    	doSendMagicEffect(pos, CONST_ME_ENERGYAREA)                            
    	doPlayerSendTextMessage(player, MESSAGE_STATUS_WARNING, AUTO_PVP_ARENA_CONFIG.FIGHT_MSG)
    end                
    
    end        
    else            
        doPlayerSendTextMessage(cid, 19, AUTO_PVP_ARENA_CONFIG.CANCEL_MSG)        
    end    
    	return TRUE
    end 
    
function onStepOut(cid, item, pos, frompos)doTransformItem(item.uid, 426)    
    if getGlobalStorageValue(AUTO_PVP_ARENA_CONFIG.PLAYERS_IN_ARENA_STORE) < 1 then        
       setGlobalStorageValue(item.uid, -1)    
    end    
       return TRUE
    end 
    
function getNumberOfPlayersOnSwitchs()local NUMBER = 0    
    for i = 1, #AUTO_PVP_ARENA_CONFIG.SWITCH_UIDS do        
    if getGlobalStorageValue(AUTO_PVP_ARENA_CONFIG.SWITCH_UIDS[i]) > 0 then            
       NUMBER = NUMBER + 1        
    end   
    end        
       return NUMBER
    end

-- Help me with this plx... many thx.
 
try Tournament.lua:

Lua:
function onStepIn(cid, item, pos, fromPosition)
	if(not isPlayer(cid)) then
		return true
	end
	doTransformItem(item.uid, 425)

	
	local PLAYERS_IN_ARENA = getGlobalStorageValue(AUTO_PVP_ARENA_CONFIG.PLAYERS_IN_ARENA_STORE)
	if(PLAYERS_IN_ARENA == -1) then
		PLAYERS_IN_ARENA = 0
	end
	
	if(PLAYERS_IN_ARENA > 0) then
		doPlayerSendTextMessage(cid, 19, AUTO_PVP_ARENA_CONFIG.CANCEL_MSG)
		doTeleportThing(cid, fromPosition, TRUE)
		return true
	end
	
	
	setGlobalStorageValue(item.uid, cid)
	if(getNumberOfPlayersOnSwitchs()) ~= #AUTO_PVP_ARENA_CONFIG.SWITCH_UIDS then
		return true
	end
	
	setGlobalStorageValue(AUTO_PVP_ARENA_CONFIG.PLAYERS_IN_ARENA_STORE, 1)

	
	for a = 1, #AUTO_PVP_ARENA_CONFIG.SWITCH_UIDS do
		local player = getGlobalStorageValue(AUTO_PVP_ARENA_CONFIG.SWITCH_UIDS[a])
		local pos = AUTO_PVP_ARENA_CONFIG.PLAYER_TP_POS[a]
		doSendMagicEffect(getCreaturePosition(player), CONST_ME_POFF)
		registerCreatureEvent(player, "TourPVP")          
                doTeleportThing(player, pos, false)
		doSendMagicEffect(pos, 10)
		doPlayerSendTextMessage(player, MESSAGE_STATUS_WARNING, AUTO_PVP_ARENA_CONFIG.FIGHT_MSG)
	end
	return true
end


function onStepOut(cid, item, pos, frompos)
	doTransformItem(item.uid, 426)
	mayNotMove(cid, 0)
	if(getGlobalStorageValue(5111) == 1) then
		return true
	end
	
    if(getGlobalStorageValue(AUTO_PVP_ARENA_CONFIG.PLAYERS_IN_ARENA_STORE) == 0) then
        setGlobalStorageValue(item.uid, -1)
    end
    return true
end

function getNumberOfPlayersOnSwitchs()
	local NUMBER = 0
    for i = 1, #AUTO_PVP_ARENA_CONFIG.SWITCH_UIDS do
        if(getGlobalStorageValue(AUTO_PVP_ARENA_CONFIG.SWITCH_UIDS[i]) > 0) then
            NUMBER = NUMBER + 1
        end
    end
	return NUMBER
end
 
Hum... with this... nobody players send to arena, all players stay on a starter tile of arena, and report this error on console:
Lua:
[Error - MoveEvent::executeStep] Call stack overflow.
[Error - MoveEvent::executeStep] Call stack overflow.
[Error - MoveEvent::executeStep] Call stack overflow.
[Error - MoveEvent::executeStep] Call stack overflow.

-- And when player death or logout on area of tiles, send this error on console:
Lua:
data/creaturescripts/scripts/Tounament.lua:57: attempt to index local 'ARENA_DET
AILS' (a nil value)
stack traceback:
        data/creaturescripts/scripts/Tounament.lua:57: in function <data/creatur
escripts/scripts/Tounament.lua:52>

Lua Script Error: [CreatureScript Interface]
in a timer event called from:
data/creaturescripts/scripts/Tounament.lua:onKill

data/creaturescripts/scripts/Tounament.lua:57: attempt to index local 'ARENA_DET
AILS' (a nil value)
stack traceback:
        data/creaturescripts/scripts/Tounament.lua:57: in function <data/creatur
escripts/scripts/Tounament.lua:52>
Ortelha has logged out.

Lua Script Error: [CreatureScript Interface]
in a timer event called from:
data/creaturescripts/scripts/Tounament.lua:onKill

data/creaturescripts/scripts/Tounament.lua:57: attempt to index local 'ARENA_DET
AILS' (a nil value)
stack traceback:
        data/creaturescripts/scripts/Tounament.lua:57: in function <data/creatur
escripts/scripts/Tounament.lua:52>

Lua Script Error: [CreatureScript Interface]
in a timer event called from:
data/creaturescripts/scripts/Tounament.lua:onKill

data/creaturescripts/scripts/Tounament.lua:57: attempt to index local 'ARENA_DET
AILS' (a nil value)
stack traceback:
        data/creaturescripts/scripts/Tounament.lua:57: in function <data/creatur
escripts/scripts/Tounament.lua:52>
-- Can help me??? Thx for helping...
 
Last edited:
Send me your SYSTEM FULL for me plx???? Your system its very good and work, my system dont, send me plx your system... many thx
 
Back
Top