Strasxni
ღ
Too bad...However i will wait until you update it.Yes, I can do that, but I'm too lazy right now and can't test the scripts.. So I won't be updating it for a while
Too bad...However i will wait until you update it.Yes, I can do that, but I'm too lazy right now and can't test the scripts.. So I won't be updating it for a while
local config = {
redTeamStorage = 9238,
blueTeamStorage = 9839,
redTeamPos = {x = 100, y = 200, z = 7},
blueTeamPos = {x = 100, y = 200, z = 7},
redTeamGlobal = 3482,
blueTeamGlobal = 3483,
redPlayers = {},
bluePlayers = {},
inEvent = 3472
}
local function stopBattle()
for i, v in ipairs(config.redPlayers) do
for i, t in ipairs(config.bluePlayers) do
if #v > #t then
doTeleportThing(v, getTownTemplePosition(getPlayerTown(v)))
table.remove(config.redPlayers, v)
doTeleportThing(t, getTownTemplePosition(getPlayerTown(t)))
table.remove(config.bluePlayers, t)
elseif #t > #v then
doTeleportThing(v, getTownTemplePosition(getPlayerTown(v)))
table.remove(config.redPlayers, v)
doTeleportThing(t, getTownTemplePosition(getPlayerTown(t)))
table.remove(config.bluePlayers, t)
end
end
end
return true
end
local function startBattle(minutes)
local teleportEvent = 0
if minutes == 0 then
for _, cid in ipairs(getPlayersOnline()) do
if getPlayerStorageValue(cid, config.inEvent) == 1 then
if math.random(1, 3) < 3 then
doTeleportThing(cid, config.redTeamPos, true)
setPlayerStorageValue(cid, config.redTeamStorage, 1)
setGlobalStorageValue(config.redTeamGlobal, getGlobalStorageValue(config.redTeamGlobal)+1)
table.insert(config.redPlayers, cid)
else
doTeleportThing(cid, config.blueTeamPos, true)
setPlayerStorageValue(cid, config.blueTeamStorage, 1)
setGlobalStorageValue(config.blueTeamGlobal, getGlobalStorageValue(config.blueTeamGlobal)+1)
table.insert(config.bluePlayers, cid)
end
end
if getGlobalStorageValue(config.redTeamGlobal) > getGlobalStorageValue(config.blueTeamGlobal) then
if getPlayerStorageValue(cid, config.redTeamStorage) == 1 then
setPlayerStorageValue(cid, config.redTeamStorage, -1)
doTeleportThing(cid, config.blueTeamPos, true)
setPlayerStorageValue(cid, config.blueTeamStorage, 1)
setGlobalStorageValue(config.redTeamGlobal, getGlobalStorageValue(config.redTeamGlobal)-1)
end
elseif getGlobalStorageValue(config.blueTeamGlobal) > getGlobalStorageValue(config.redTeamGlobal) then
if getPlayerStorageValue(cid, config.blueTeamStorage) == 1 then
setPlayerStorageValue(cid, config.blueTeamStorage, -1)
doTeleportThing(cid, config.redTeamPos, true)
setPlayerStorageValue(cid, config.redTeamStorage, 1)
setGlobalStorageValue(config.blueTeamGlobal, getGlobalStorageValue(config.blueTeamGlobal)-1)
end
end
end
return true
end
if minutes == 1 then
doBroadcastMessage("Battle event will start in " .. minutes .. " minute!")
elseif minutes <= 3 then
doBroadcastMessage("Battle event will start in " .. minutes .. " minutes!")
else
doBroadcastMessage("Battle event will start in " .. minutes .. " minutes!")
end
teleportEvent = addEvent(startBattle, 60000, minutes - 1)
return true
end
function onThink(interval, lastExecution)
return startBattle(math.abs(math.ceil(5))) and addEvent(stopBattle, 25 * 60000)
end
hah, wrote it fast
;d
Code:local config = { redTeamStorage = 9238, blueTeamStorage = 9839, redTeamPos = {x = 100, y = 200, z = 7}, blueTeamPos = {x = 100, y = 200, z = 7}, redTeamGlobal = 3482, blueTeamGlobal = 3483, redPlayers = {}, bluePlayers = {}, inEvent = 3472 } local function stopBattle() for i, v in ipairs(config.redPlayers) do for i, t in ipairs(config.bluePlayers) do if #v > #t then doTeleportThing(v, getTownTemplePosition(getPlayerTown(v))) table.remove(config.redPlayers, v) doTeleportThing(t, getTownTemplePosition(getPlayerTown(t))) table.remove(config.bluePlayers, t) elseif #t > #v then doTeleportThing(v, getTownTemplePosition(getPlayerTown(v))) table.remove(config.redPlayers, v) doTeleportThing(t, getTownTemplePosition(getPlayerTown(t))) table.remove(config.bluePlayers, t) end end end return true end local function startBattle(minutes) local teleportEvent = 0 if minutes == 0 then for _, cid in ipairs(getPlayersOnline()) do if getPlayerStorageValue(cid, config.inEvent) == 1 then if math.random(1, 3) < 3 then doTeleportThing(cid, config.redTeamPos, true) setPlayerStorageValue(cid, config.redTeamStorage, 1) setGlobalStorageValue(config.redTeamGlobal, getGlobalStorageValue(config.redTeamGlobal)+1) table.insert(config.redPlayers, cid) else doTeleportThing(cid, config.blueTeamPos, true) setPlayerStorageValue(cid, config.blueTeamStorage, 1) setGlobalStorageValue(config.blueTeamGlobal, getGlobalStorageValue(config.blueTeamGlobal)+1) table.insert(config.bluePlayers, cid) end end if getGlobalStorageValue(config.redTeamGlobal) > getGlobalStorageValue(config.blueTeamGlobal) then if getPlayerStorageValue(cid, config.redTeamStorage) == 1 then setPlayerStorageValue(cid, config.redTeamStorage, -1) doTeleportThing(cid, config.blueTeamPos, true) setPlayerStorageValue(cid, config.blueTeamStorage, 1) setGlobalStorageValue(config.redTeamGlobal, getGlobalStorageValue(config.redTeamGlobal)-1) end elseif getGlobalStorageValue(config.blueTeamGlobal) > getGlobalStorageValue(config.redTeamGlobal) then if getPlayerStorageValue(cid, config.blueTeamStorage) == 1 then setPlayerStorageValue(cid, config.blueTeamStorage, -1) doTeleportThing(cid, config.redTeamPos, true) setPlayerStorageValue(cid, config.redTeamStorage, 1) setGlobalStorageValue(config.blueTeamGlobal, getGlobalStorageValue(config.blueTeamGlobal)-1) end end end return true end if minutes == 1 then doBroadcastMessage("Battle event will start in " .. minutes .. " minute!") elseif minutes <= 3 then doBroadcastMessage("Battle event will start in " .. minutes .. " minutes!") else doBroadcastMessage("Battle event will start in " .. minutes .. " minutes!") end teleportEvent = addEvent(startBattle, 60000, minutes - 1) return true end function onThink(interval, lastExecution) return startBattle(math.abs(math.ceil(5))) and addEvent(stopBattle, 25 * 60000) end
Code:<globalevent name="TeamBattle" interval="30" event="script" value="BattleCheck.lua"/>
A question will that script be executed every 30 sec?
09:37 Mr Chinatown: Do you wish to join the battle? There is currently 1/1 players in Punishers team and 0/1 players in Tha Artards team.
09:38 Account Manager [1]: tha artards
09:38 Account Manager [1]: yes
09:38 Mr Chinatown: You are already signed up!
09:38 Account Manager [1]: hi
09:38 Account Manager [1]: leave
09:38 Mr Chinatown: Do you wish to leave the battle?
09:38 Account Manager [1]: yes
09:38 Mr Chinatown: You are not even signed up!
[22/07/2010 09:38:37] [Error - Npc interface]
[22/07/2010 09:38:37] data/npc/scripts/BattleNPC.luanCreatureSay
[22/07/2010 09:38:37] Description:
[22/07/2010 09:38:37] (luaGetCreatureStorage) Creature not found