• Sign up for September Mapping Competition! The prize includes Otland Premium time.
  • 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!

CreatureEvent [TFS 1.1] Classic PVP Arena

Zeroone

Active Member
Joined
Dec 11, 2007
Messages
225
Best answers
0
Reaction score
27
Location
Sweden
Can someone help me add 2v2, 3v3 and 5v5 aswell?

Thanks alot!

Also this error comes up:

[!] --> [Warning - Function::getCreaturesInQuestArea] Unknown type (nil value)

Lua Script Error: [Main Interface]
in a timer event called from:
(Unknown scriptfile)
data/actions/scripts/arenapvp.lua:23: attempt to compare number with nil
stack traceback:
[C]: in function '__lt'
data/actions/scripts/arenapvp.lua:23: in function <data/actions/scripts/arenapvp.lua:22>
 
Last edited:

Thorn

Spriting since 2013
Joined
Sep 24, 2012
Messages
2,197
Best answers
1
Reaction score
871
Location
Chile
i get this error :S
Code:
[Warning - Event::checkScript] Event onPrepareDeath not found. scripts/pvparena.lua
[Warning - Event::checkScript] Event onLogin not found. scripts/pvparena.lua
i use tfs 1.3 and i have
player:registerEvent("pvparena") in login.lua
 

theduck

Member
Joined
Dec 6, 2018
Messages
241
Best answers
0
Reaction score
18
Code:
Lua Script Error: [Action Interface] 
data/actions/scripts/arenapvp/pvplever.lua:onUse
data/actions/scripts/arenapvp/pvplever.lua:68: attempt to call method 'getTopCreature' (a nil value)
stack traceback:
[C]: in function 'getTopCreature'
data/actions/scripts/arenapvp/pvplever.lua:68: in function 'getCreaturesInQuestArea'
data/actions/scripts/arenapvp/pvplever.lua:91: in function <data/actions/scripts/arenapvp/pvplever.lua:86>
 

strutZ

Australian OT Member {AKA Beastn}
Joined
Nov 16, 2014
Messages
1,354
Best answers
6
Reaction score
494
Code:
Lua Script Error: [Action Interface]
data/actions/scripts/arenapvp/pvplever.lua:onUse
data/actions/scripts/arenapvp/pvplever.lua:68: attempt to call method 'getTopCreature' (a nil value)
stack traceback:
[C]: in function 'getTopCreature'
data/actions/scripts/arenapvp/pvplever.lua:68: in function 'getCreaturesInQuestArea'
data/actions/scripts/arenapvp/pvplever.lua:91: in function <data/actions/scripts/arenapvp/pvplever.lua:86>
Try chaing this

pvplever.lua line 63

Lua:
thing = getTopCreature(pos)
to
Lua:
thing = pos:getTopCreature()
 

theduck

Member
Joined
Dec 6, 2018
Messages
241
Best answers
0
Reaction score
18
Code:
-- CONFIG BEGINS HERE --

local arena = {
	frompos = {x = 32235, y = 32170, z = 9},
	topos = {x = 32271, y = 32191, z = 9},
	exitpos = {x = 32252, y = 32192, z = 8} ---exit
}

 

local checkpvparena = false -- checks if someone is blocking the arena
local duel_limit = 2 * 60 -- in seconds

local leverpos = {x = 32239, y = 32198, z = 8}
 
local player1pos = {x = 32239, y = 32199, z = 8}
local player2pos = {x = 32240, y = 32199, z = 8}


local nplayer1pos = {x = 32255, y = 32186, z = 9}
local nplayer2pos = {x = 32255, y = 32170, z = 9}

-- CONFIG ENDS HERE --

local TYPE_PLAYER = 1
local TYPE_MONSTER = 2
local TYPE_NPC = 3
local TYPE_ALL = 4
local GET_COUNT = 1
local GET_UID = 2

function lever_back(uid)
doTransformItem(uid,10029)
return true
end

function kick_r()
if getCreaturesInQuestArea(TYPE_PLAYER, arena.frompos, arena.topos, GET_COUNT) > 1 then
for a = arena.frompos.x, arena.topos.x do
for b = arena.frompos.y, arena.topos.y do
pos = {x=a,y=b,z=9,stackpos = 255}
if(isPlayer(getTopCreature(pos).uid)) then
doPlayerSendTextMessage(getTopCreature(pos).uid,MESSAGE_INFO_DESCR,"Time up. Round drawn.")
doTeleportThing(getTopCreature(pos).uid,arena.exitpos)
end
end
end
end
return true
end

function getCreaturesInQuestArea(type, fromPos, toPos, get, countSummon)
   local types =
{
[TYPE_PLAYER] = isPlayer,
[TYPE_MONSTER] = isMonster,
[TYPE_NPC] = isNpc,
[TYPE_ALL] = isCreature
}
   local tmp = {}
   local t = types[type]
   if not t then
     return print("[!] --> [Warning - Function::getCreaturesInQuestArea] Unknown type " .. (type or "(nil value)"))
   end
   local thing
   local pos
   for x = fromPos.x, toPos.x do
     for y = fromPos.y, toPos.y do
       for z = fromPos.z, toPos.z do
         pos = Position(x, y, z)
         thing = pos:getTopCreature()
         if t(thing) then
           table.insert(tmp, thing:getId())
           if not countSummon and thing:isSummon() then
             for i = 1, #tmp do
               if tmp[i] == thing:getId() then
                 table.remove(tmp, i)
                 break
               end
             end
           end
         end
       end
     end
   end
   return (get == GET_COUNT and #tmp or get == GET_UID and tmp or print("[Warning - Function::getCreaturesInQuestArea] Unknown type to get " .. (get or "(nil value)")))
end

function onUse(player, item, frompos, item2, topos)
local cid = player:getId()
if item.itemid == 10029 then
if isPlayer(getTopCreature(player1pos).uid) == true and isPlayer(getTopCreature(player2pos).uid) == true then
if checkpvparena then
if getCreaturesInQuestArea(TYPE_PLAYER, arena.frompos, arena.topos, GET_COUNT) > 0 then
if getCreaturesInQuestArea(TYPE_PLAYER, arena.frompos, arena.topos, GET_COUNT) == 1 then
for c = arena.frompos.x, arena.topos.x do
for d = arena.frompos.y, arena.topos.y do
pos = {x=c,y=d,z=8, stackpos = 255}

if(isPlayer(getTopCreature(pos).uid)) then
doPlayerSendTextMessage(getTopCreature(pos).uid,MESSAGE_INFO_DESCR,"You have been kicked from the arena.")
doTeleportThing(getTopCreature(pos).uid,arena.exitpos)
end
end
end
else
arena_counter = getGlobalStorageValue(24510) - os.time()
if arena_counter < 0 then
for c = arena.frompos.x, arena.topos.x do
for d = arena.frompos.y, arena.topos.y do
pos = {x=c,y=d,z=8, stackpos = 255}
if(isPlayer(getTopCreature(pos).uid)) then
doPlayerSendTextMessage(getTopCreature(pos).uid,MESSAGE_INFO_DESCR,"You have been kicked from the arena.")
doTeleportThing(getTopCreature(pos).uid,arena.exitpos)
end
end
end
else
doCreatureSay(cid, "There is still active duel.\n" .. showTimeLeft(arena_counter, true) .. " left.\nPlease wait for your turn.", TALKTYPE_ORANGE_1)
pvpaback = addEvent(lever_back, 5000, item.uid)
return false
end
end
end
end
-- let the match begin
doSendMagicEffect(player1pos,CONST_ME_POFF)
doSendMagicEffect(player2pos,CONST_ME_POFF)
doPlayerSendTextMessage(getTopCreature(player1pos).uid,MESSAGE_STATUS_WARNING,"\nThe battle has begun! duration time 5 minutes\nFight!")
doPlayerSendTextMessage(getTopCreature(player2pos).uid,MESSAGE_STATUS_WARNING,"\nThe battle has begun! duration time 5 minutes\nFight!")
doTeleportThing(getTopCreature(player1pos).uid,nplayer1pos)
doTeleportThing(getTopCreature(player2pos).uid,nplayer2pos)
doSendMagicEffect(nplayer1pos,CONST_ME_TELEPORT)
doSendMagicEffect(nplayer2pos,CONST_ME_TELEPORT)
doTransformItem(getTileItemById(leverpos, 10029).uid,item.itemid+1)
setGlobalStorageValue(24510,os.time() + duel_limit)
pvpaback = addEvent(lever_back, 5000, item.uid)
if arena_kick_r then
stopEvent(arena_kick_r)
end
arena_kick_r = addEvent(kick_r, duel_limit * 1000)
else
doCreatureSay(cid, "You need two players to enter the arena.", TALKTYPE_ORANGE_1)
pvpaback = addEvent(lever_back, 5000, item.uid)
return false
end
else
-- if timer or checking is offline player can push the lever manually
if pvpaback then
doPlayerSendDefaultCancel(cid, RETURNVALUE_CANNOTUSETHISOBJECT)
else
doTransformItem(getTileItemById(leverpos, 10030).uid,10029)
end
end
return true
end


--- arena pos z= 9
--- exit pos z = 8

Thanks for the reply you are already having the function this way,
I think it can if something with the pos Z configuration more have already tried 8 and 9


Code:
Lua Script Error: [Main Interface] 
 in a timer event called from: 
  (Unknown scriptfile)
  data/actions/scripts/arenapvp/pvplever.lua:72: attempt to call method 'getTopCreature' (a nil value)
 stack traceback:
  [C]: in function 'getTopCreature'
   data/actions/scripts/arenapvp/pvplever.lua:72: in function 'getCreaturesInQuestArea'
   data/actions/scripts/arenapvp/pvplever.lua:39: in function <data/actions/scripts/arenapvp/pvplever.lua:38>
 

theduck

Member
Joined
Dec 6, 2018
Messages
241
Best answers
0
Reaction score
18
bump
......edit ....
Fixed
 
Last edited:

derimax3

New Member
Joined
Feb 20, 2009
Messages
11
Best answers
0
Reaction score
0
I have this error... When player HP is low it doesnt tp him to exitpos. Anybody know how to fix it please?


Code:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/pvparena.lua:onPrepareDeath
data/creaturescripts/scripts/pvparena.lua:10: attempt to call global 'isInRange' (a nil value)
stack traceback:
        [C]: in function 'isInRange'
        data/creaturescripts/scripts/pvparena.lua:10: in function <data/creaturescripts/scripts/pvparena.lua:7>
 
Last edited:
Top