addEventHandler("O
zonapvp = createColRectangle ( 5441.9, -1926.4, 119.5, 133 )
event_iniciado = 1
local spawns = {
{ 5460.70264, -1825.30945, 10.97057 },
{ 5454.74805, -1884.13953, 10.29621 },
{ 5537.57373, -1887.13306, 11.04092 },
{ 5545.14746, -1829.44873, 10.29401 },
{ 5501.95557, -1861.66174, 10.29621 }
}
function start_admin_event (player)
if event_iniciado == 1 then
local accName = getAccountName ( getPlayerAccount ( player ) )
if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Owner" ) ) then
outputDebugString ("Evento Iniciado")
event_iniciado = event_iniciado +1
i = 0
pvp_1 = createTeam("PVP-Red [use /pvp]", 255, 0, 0)
pvp_2 = createTeam("PVP-Green [use /pvp]", 0, 255, 0)
pvp_3 = createTeam("PVP-Blue [use /pvp]", 0, 0, 255)
pvp_4 = createTeam("PVP-Yellow [use /pvp]", 255, 255, 0)
addCommandHandler ( "pvp", tele )
end
else
outputChatBox("O evento ja esta ativado", player, 255, 0, 0)
end
end
addCommandHandler ( "eventStart", start_admin_event )
function entrar_na_zona( thePlayer, matchingDimension )
if getElementType ( thePlayer ) == "player" then
outputChatBox( "Working One" )
redirecionar_team (thePlayer )
end
end
addEventHandler("onColShapeHit", zonapvp, entrar_na_zona)
function sair_da_zona( thePlayer, matchingDimension )
if getElementType ( thePlayer ) == "player" then
outputChatBox( "Working Two" )
retirar_team (thePlayer )
end
end
addEventHandler("onColShapeLeave", zonapvp, sair_da_zona)
function tele(player)
local teles = math.random ( #spawns )
if ( teles ) then
setElementData(player,"inPVP",true)
setElementData ( player, "SavedTeam", getTeamName ( getPlayerTeam ( player ) ) )
setElementPosition(player, unpack ( spawns [ teles ] ))
end
end
function redirecionar_team (thePlayer)
playerTeam = getPlayerTeam(thePlayer)
i = i + 1
if i > 4 then
i = 1
end
if pvp_1 and pvp_2 and pvp_3 and pvp_4 then
if i == 1 then
setPlayerTeam ( thePlayer, pvp_1 )
end
if i == 2 then
setPlayerTeam ( thePlayer, pvp_2 )
end
if i == 3 then
setPlayerTeam ( thePlayer, pvp_3 )
end
if i == 4 then
setPlayerTeam ( thePlayer, pvp_4 )
end
end
end
function retirar_team (player)
local t = getElementData ( player, 'SavedTeam' )
setPlayerTeam ( player, getTeamFromName ( t ) )
setElementData(player,"SavedTeam",false)
end
addCommandHandler("stop123",
function (player)
local accName = getAccountName ( getPlayerAccount ( player ) )
if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Owner" ) ) then
if event_iniciado >= 2 then
for k , v in ipairs(getElementsByType("player")) do
if getElementData(v,"inPVP") then
retirar_team (v)
end
end
for i, team in ipairs(getElementsByType('team') do
destroyElement(team)
end
removeCommandHandler ( "pvp" )
event_iniciado = 1
else
outputChatBox("Não possivel parar, porque não foi iniciado", player, 255, 0, 0)
end
end
end)
Try this
*UPDATED*