• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

GlobalEvent [MOD]Full auto WAR-TeamBattle Event(with random rewards)

Why is there same thing couple of times? (minlevel,running2)
Code:
        local mingroup = 4 --(updated) minimum group to reset the event
        local joined = 10000 ---must be like the storage in mod
        local maxPlayerEachTeam = 1 ---must be like max number in mod
        local team1Name = "Blue" ---must be like team number i mod
        local team2Name = "Red"
        local minlevel = 120 --(added) min lvl for a player to join.
 
		--[[Storage like in the mod file]]--
	      local minlevel = 120 --(added) min lvl for a player to join.
	      local running2 = 12001 --must be the same storage as in mod
          local  running1 = 12000 --just add a non ussed storage
          local running2 = 12001 --just add a non ussed storage
          local sto = 12223 --just add a non ussed storage
         --[[Storage end]]--


EDIT:
I got every other error fixed, but when the battle ends, the loser team won't get their original outfits back until they relog...


Using rev 3884(8.6)
 
Last edited:
after
"22:05 Eventer: Do you wish to join Blue team or Red team?"

you must say "yes", and then it will say to you something like... "ok then what team you want red or blue", and then you choose ;)

as you say, seems its repited, just delete one minlevel and one running2
 
Got quite big problem with this script. If I let this be like this then, players can't die outside the event area...(Works fine inside the event area)
Code:
if isInRange(getCreaturePosition(cid), arena.frompos, arena.topos) then
		doItemSetAttribute(doCreateItem(corpse_ids[getPlayerSex(cid)], 1, getThingPos(cid)), "description", "You recognize "..getCreatureName(cid)..". He was killed by "..(isMonster(attacker) and "a "..string.lower(getCreatureName(attacker)) or isCreature(attacker) and getCreatureName(attacker) or "a field item")..".\n[War-Event kill]") 
		doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), FALSE)
		doSendMagicEffect(getCreaturePosition(cid), 10)
		doRemoveConditions(cid, FALSE)
		doCreatureAddHealth(cid, getCreatureMaxHealth(cid) - getCreatureHealth(cid))
		doCreatureAddMana(cid, getCreatureMaxMana(cid) - getCreatureMana(cid))
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You got killed by "..(isMonster(attacker) and "a "..string.lower(getCreatureName(attacker)) or isCreature(attacker) and getCreatureName(attacker) or "a field item").." in the war event.")
			if isPlayer(attacker) then
					doPlayerSendTextMessage(attacker, MESSAGE_STATUS_CONSOLE_BLUE, "You killed "..getCreatureName(cid).." in the war event.")
			end
			if getPlayerStorageValue(cid,joined) == 1 then
				removeBlue()
				setPlayerStorageValue(cid,85500,-1)
			elseif getPlayerStorageValue(cid,joined) == 2 then
				removeRed()
				setPlayerStorageValue(cid,85500,-1)
			end
	end
	return false
 
end


but if Change the last "return false" to "return true", like this. Then players can die outside the event area but when they get killed in the event area the server crashes...
Code:
if isInRange(getCreaturePosition(cid), arena.frompos, arena.topos) then
		doItemSetAttribute(doCreateItem(corpse_ids[getPlayerSex(cid)], 1, getThingPos(cid)), "description", "You recognize "..getCreatureName(cid)..". He was killed by "..(isMonster(attacker) and "a "..string.lower(getCreatureName(attacker)) or isCreature(attacker) and getCreatureName(attacker) or "a field item")..".\n[War-Event kill]") 
		doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), FALSE)
		doSendMagicEffect(getCreaturePosition(cid), 10)
		doRemoveConditions(cid, FALSE)
		doCreatureAddHealth(cid, getCreatureMaxHealth(cid) - getCreatureHealth(cid))
		doCreatureAddMana(cid, getCreatureMaxMana(cid) - getCreatureMana(cid))
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You got killed by "..(isMonster(attacker) and "a "..string.lower(getCreatureName(attacker)) or isCreature(attacker) and getCreatureName(attacker) or "a field item").." in the war event.")
			if isPlayer(attacker) then
					doPlayerSendTextMessage(attacker, MESSAGE_STATUS_CONSOLE_BLUE, "You killed "..getCreatureName(cid).." in the war event.")
			end
			if getPlayerStorageValue(cid,joined) == 1 then
				removeBlue()
				setPlayerStorageValue(cid,85500,-1)
			elseif getPlayerStorageValue(cid,joined) == 2 then
				removeRed()
				setPlayerStorageValue(cid,85500,-1)
			end
	end
	return true
 
end

EDIT:
I fixed that one by this:
Code:
	if isInRange(getCreaturePosition(cid), arena.frompos, arena.topos) then
		doItemSetAttribute(doCreateItem(corpse_ids[getPlayerSex(cid)], 1, getThingPos(cid)), "description", "You recognize "..getCreatureName(cid)..". He was killed by "..(isMonster(attacker) and "a "..string.lower(getCreatureName(attacker)) or isCreature(attacker) and getCreatureName(attacker) or "a field item")..".\n[War-Event kill]") 
		doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), FALSE)
		doSendMagicEffect(getCreaturePosition(cid), 10)
		doRemoveConditions(cid, FALSE)
		doCreatureAddHealth(cid, getCreatureMaxHealth(cid) - getCreatureHealth(cid))
		doCreatureAddMana(cid, getCreatureMaxMana(cid) - getCreatureMana(cid))
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You got killed by "..(isMonster(attacker) and "a "..string.lower(getCreatureName(attacker)) or isCreature(attacker) and getCreatureName(attacker) or "a field item").." in the war event.")
			if isPlayer(attacker) then
					doPlayerSendTextMessage(attacker, MESSAGE_STATUS_CONSOLE_BLUE, "You killed "..getCreatureName(cid).." in the war event.")
			end
			if getPlayerStorageValue(cid,joined) == 1 then
				removeBlue()
				setPlayerStorageValue(cid,85500,-1)
			elseif getPlayerStorageValue(cid,joined) == 2 then
				removeRed()
				setPlayerStorageValue(cid,85500,-1)
			end
[COLOR="red"]	return false
	end
	return true[/COLOR]
end

But I got another problem now that the server doesn't crash and that is that not every player of the winning team gets teleported(the one which doesnt get teleported doesnt get reward either)...
The player who did not get tped needs to relog. Other players get this msg when he relogs
Code:
4:50 Tester have left the War-Event

But after that when you go to npc say battle(after event started again)
It says
Code:
14:50 Ground Wars: Do you wish to join the battle? There is currently -1/2 players in Blue team and 0/2 players in Red team.

EDIT 2:
I've been testing this now multiple times with different style of winning/losing and it seems only not be working properly when either of the teams kills the enemy team completely.
The one who didn't get tped, he won't received reward either or get the storages removed.(not even when relogged)
The only way inside the game to get the storages right is this you need to reset the event.

So it works when the time run outs, it doesnt matter if no on idead or just one died. Every one will be tped to temple and winning team get the rewards.

EDIT 3: Fixed it.
I fixed it by changin this
Code:
if getGlobalStorageValue(running1) == 1 then
	setGlobalStorageValue(running2,1)
	for _, cid in ipairs(getPlayersOnline()) do
		if (getBlue() >= 1 and getRed() < 1) then
			if getPlayerStorageValue(cid,joined) == 1 then
				doBroadcastMessage("The War-Event has finished as the " ..team1name.. " team has killed all players in opponent team ,they will receive their rewards.Event will be reopened in ".. timebetween .." minutes")
				doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), FALSE)
				doSendMagicEffect(getCreaturePosition(cid), 10)
				doRemoveConditions(cid, FALSE)
				doPlayerAddItem(cid, random_item, 1)
				doRemoveConditions(cid, FALSE)
				doCreatureSay(cid, "You have won a "..getItemNameById(random_item).." as a reward from war event", TALKTYPE_ORANGE_1)
				setPlayerStorageValue(cid, joined,-1)
				setGlobalStorageValue(running1,-1)
				resetBlue()
			end
		elseif (getBlue() < 1 and getRed() >= 1) then
			if getPlayerStorageValue(cid,joined) == 2 then
				doBroadcastMessage("The War-Event has finished as the " ..team2name.. "  team has killed all players in opponent team,they will receive their rewards.Event will be reopened in ".. timebetween .." minutes")
				doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), FALSE)
				doRemoveConditions(cid, FALSE)
				doSendMagicEffect(getCreaturePosition(cid), 10)
				doRemoveConditions(cid, FALSE)
				doPlayerAddItem(cid, random_item, 1)
				doCreatureSay(cid, "You have won a "..getItemNameById(random_item).." as a reward from war event", TALKTYPE_ORANGE_1)
				setGlobalStorageValue(running1,-1)
				setPlayerStorageValue(cid, joined,-1)
				resetRed()
			end
		end
	end
end
by this
Code:
if getGlobalStorageValue(running1) == 1 then
	setGlobalStorageValue(running2,1)
	if (getBlue() >= 1 and getRed() < 1) then
		doBroadcastMessage("The War-Event has finished as the " ..team1name.. " team has killed all players in opponent team ,they will receive their rewards.Event will be reopened in ".. timebetween .." minutes")
		for _, cid in ipairs(getPlayersOnline()) do
			if getPlayerStorageValue(cid,joined) == 1 then
				doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), FALSE)
				doSendMagicEffect(getCreaturePosition(cid), 10)
				doRemoveConditions(cid, FALSE)
				doPlayerAddItem(cid, random_item, 1)
				doRemoveConditions(cid, FALSE)
				doCreatureSay(cid, "You have won a "..getItemNameById(random_item).." as a reward from war event", TALKTYPE_ORANGE_1)
				setPlayerStorageValue(cid, joined,-1)
				resetBlue()
			end
		end
		setGlobalStorageValue(running1,-1)
	end
	if (getBlue() < 1 and getRed() >= 1) then
		doBroadcastMessage("The War-Event has finished as the " ..team2name.. "  team has killed all players in opponent team,they will receive their rewards.Event will be reopened in ".. timebetween .." minutes")
		for _, cid in ipairs(getPlayersOnline()) do
			if getPlayerStorageValue(cid,joined) == 2 then
				doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), FALSE)
				doRemoveConditions(cid, FALSE)
				doSendMagicEffect(getCreaturePosition(cid), 10)
				doRemoveConditions(cid, FALSE)
				doPlayerAddItem(cid, random_item, 1)
				doCreatureSay(cid, "You have won a "..getItemNameById(random_item).." as a reward from war event", TALKTYPE_ORANGE_1)
				setPlayerStorageValue(cid, joined,-1)
				resetRed()
			end
		end
		setGlobalStorageValue(running1,-1)
	end
end


Btw... You should change this:
Code:
 <globalevent name="Karim" interval="40000" event="script"><![CDATA[
		domodlib('football-lib')
                domodlib('tutorial_m')
 
function onThink(interval, lastExecution)
if getGlobalStorageValue(running1) > 0 then
local blue = {}
local green = {}
for _, pid in ipairs(getPlayersOnline()) do
 if isInRange(getCreaturePosition(pid),arena.frompos, arena.topos) then
    if getPlayerStorageValue(pid, joined) == 1 then  
	   table.insert(blue,getCreatureName(pid))
	elseif getPlayerStorageValue(pid, joined) == 2 then  
	   table.insert(green,getCreatureName(pid))
	end
 end
end
 
local greenn = table.concat(green,', ')
local bluee = table.concat(blue,', ')
for _, tid in ipairs(getPlayersOnline()) do
 
if getPlayerStorageValue(tid, joined) > 0 then
   doPlayerSendTextMessage(tid,19,'<<!-- Players left --!>>\n '..team1name..' team ('..#blue..') : '..bluee..'.\n '..team2name..' team ('..#green..') : '..greenn..'.')
end
end
end
 
return true
end
 ]]></globalevent>
to this
Code:
<globalevent name="Karim" interval="40000" event="script"><![CDATA[
domodlib('football-lib')
domodlib('tutorial_m')
function onThink(interval, lastExecution)
	if getGlobalStorageValue(running1) > 0 then
		local blue = {}
		local red = {}
		for _, pid in ipairs(getPlayersOnline()) do
			if isInRange(getCreaturePosition(pid),arena.frompos, arena.topos) then
				if getPlayerStorageValue(pid, joined) == 1 then  
				   table.insert(blue,getCreatureName(pid))
				elseif getPlayerStorageValue(pid, joined) == 2 then  
				   table.insert(red,getCreatureName(pid))
				end
			end
		end
 
		local redn = table.concat(red,', ')
		local bluee = table.concat(blue,', ')
		for _, tid in ipairs(getPlayersOnline()) do
			if getPlayerStorageValue(tid, joined) > 0 then
			   doPlayerSendTextMessage(tid,19,'<<!-- Players left --!>>\n '..team1name..' team ('..#blue..') : '..bluee..'.\n '..team2name..' team ('..#red..') : '..redn..'.')
			end
		end
	end
return true
end
 ]]></globalevent>

EDIT 4:
The event timer isnt working perfectly.
Code:
stoptime = 3 --in minutes
timebetween = 4 -- time between each event

Code:
18:48 Event: Team Battle has finished as the Blue  team has killed more players than the opponent team has, they will receive their rewards. Team Battle will be started again in 4 minutes
18:49 Event : Team Battle is opened again , go talk to the Team Battle Npc in Thais.
 
Last edited:
Ok for every thing you are right :p , but for the show names every interval of time it dont need to be changed..
 
Ok now i think i have fixed, if you can make more tests and post here i will be glad :D
 
Ah sorry, didn't notice that you said recopy, well anyways I don't really got atm time with it now(but the one I posted works 100%)
 
Works fine! thanks!
but how could i make that the npc is only created one specific day at one specific hour? for example weadnesday at 8pm and after the event ends the npc disappear so people must wait a few days to join again to this event
 
Doggy, could you make me a little fix? I want that this NPCs only be available or talkeable on thursday at 20:00 pm to 21:00 pm?
 
Honestly imma Copy/Paste kinda guy i know Nothing xD
it involve this?

addEvent(onStop, stoptime * 60 * 1000)
addEvent(onStopp, timebetween * 60 * 1000)
 
lol --> search for this :
Lua:
<config name="tutorial_m"><![CDATA[
 
    running1 = 12000 --just add a non ussed storage
	running2 = 12001 --just add a non ussed storage
	joined = 10000 --just add a non ussed storage
	sto = 12223 --just add a non ussed storage
	check = 5454 -- empty storage
	redpotision = {x=1036, y=1021, z=7} --place where the red team player be teleported to
    blueposition = {x=1023, y=1021, z=7} --place where the blue team player be teleported to
	stoptime = 2 --in minutes
	team1name = "Blue" --just put the name without <team>
	team2name = "Red" 
	timebetween = 5 -- time between each event 
	arena = { frompos = {x=1022,y=1017,z=7}, topos = {x=1037,y=1025,z=7} } ----Put you event area here
	conf = {
				rewards_id = {2494, 2472, 2514, 2160}, -- Rewards ID
				maxplayers = 1 ---maxplayers per team
			}
 ]]></config>

and this is what you should edit read the description beside
 
Lol where in there is the duration of how long Event lasts i see
timebetween each event
only thing time related
 
I Sincerely Apologize for my NOOB-Ness i Was blind to Stop Time Lol Sry Btw your a beast xD
You know hwo to change distance between you and your summon?
 
make check in those spell files for the joined storage value so if player have it return false
 
Back
Top