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

Maybe i will rescript that thing , but if iw ill start it will be tomorrow :p
 
Nice, I will wait... 30 minutes of event and there are like 20 red members searching for the latest blue and can't find him, I don't know his name, and also, they shouldn't be able to change their outfits/colors during the event.
 
Maybe onOutfit(cid, old, current) could help me , i will check. But for change mapp pos etc, to choose which place event will be in , will be ignored :p
It will be too much time , as for max players and reset etc.. I will add to npc.
 
What about adding combat with -1 as time? It would prevent from changing outfit by them, because combat will last untill player dies/logs out, then after event removing that condition?
 
what ccombat type should that combat use?

Edit : Found :) didnt think that there is a combat condition for outfit , thx for tip. Will save time.
 
Last edited:
Updated :

1- players cant change outfit during game.

2- Gms can now reset the event

3- Players in event will recieve a message with nomber Players left in each teams with their names.

Have fun. :p
 
Code:
[4:16:26.808] [Error - CreatureScript Interface] 
[4:16:26.808] domodlib('football-lib')
[4:16:26.808] domodlib('tutorial_m')
[4:16:26.808] local corpse_ids = {
[4:16:26.808]         [0] = 3065, -- female
[4:16:26.808]         [1] = 3058 -- male
[4:16:26.808] }
[4:16:26.808] function onStatsChange(cid, attacker, type, combat, value)
[4:16:26.808]         if combat == COMBAT_HEALING then
[4:16:26.808]                 return true
[4:16:26.808]         end
[4:16:26.808]  
[4:16:26.808]         if getCreatureHealth(cid) > value then
[4:16:26.808]                 return true
[4:16:26.808]         end
[4:16:26.808]  
[4:16:26.808]  
[4:16:26.808] if isInRange(getCreaturePosition(cid), arena.frompos, arena.topos) then
[4:16:26.808]  
[4:16:26.808]    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]") 
[4:16:26.808]          doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), FALSE)
[4:16:26.808]         doSendMagicEffect(getCreaturePosition(cid), 10)
[4:16:26.808]  
[4:16:26.808]         doRemoveConditions(cid)
[4:16:26.808]         doCreatureAddHealth(cid, getCreatureMaxHealth(cid) - getCreatureHealth(cid))
[4:16:26.808]         doCreatureAddMana(cid, getCreatureMaxMana(cid) - getCreatureMana(cid))
[4:16:26.808]  
[4:16:26.808]         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.")
[4:16:26.808]         if isPlayer(attacker) then
[4:16:26.808]                 doPlayerSendTextMessage(attacker, MESSAGE_STATUS_CONSOLE_BLUE, "You killed "..getCreatureName(cid).." in the war event.")
[4:16:26.808]         end
[4:16:26.808]                 if getPlayerStorageValue(cid,joined) == 1 then
[4:16:26.808]                           removeBlue()
[4:16:26.808]  
[4:16:26.808]                    setPlayerStorageValue(cid,10000,-1)
[4:16:26.808]                 elseif getPlayerStorageValue(cid,joined) == 2 then
[4:16:26.808]                    removeRed()
[4:16:26.808]  
[4:16:26.808]                    setPlayerStorageValue(cid,10000,-1)
[4:16:26.808]                   end
[4:16:26.808]   end
[4:16:26.808]         return false
[4:16:26.808]  
[4:16:26.808] end
[4:16:26.808]  
[4:16:26.808] :onStatsChange
[4:16:26.808] Description: 
[4:16:26.808] data/lib/032-position.lua:2: attempt to index local 'fromPosition' (a nil value)
[4:16:26.808] stack traceback:
[4:16:26.808]   data/lib/032-position.lua:2: in function 'isInRange'
[4:16:26.808]   [string "LuaInterface::loadBuffer"]:17: in function <[string "LuaInterface::loadBuffer"]:7>

Using latest lib 0.4 :S
 
You have to copy the new locals (config) did you recopied them?, because i reedited the config names .
 
@Damadger
It doesn't work at all...


LUA:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Team Event" version="1.0" author="Damadgerz" contact="[email protected]" enabled="yes">
 <description>
 
      This is a full auto Team BattleEvent(missing part for site) :
             1- Player will get the ability to talk to the npc event starter to start the event every x times(time between each event)
                 2- players will go to npc and say battle and then join their desired team(you adjust team names) , they also have ability to leave team
                 3- You have ability to set max players per each team, npc will not tp the players to arena except when both teams are full
                 4- Script automatically set the place of event to a pvp arena (players no lose items,levels,geet msg who killed them).Place cant be a non-pvp area.
                 5- if player logged out they will automatically be lifted out from event.
                 6- players in same team cant attack each others even with spells
                 7- each team will have a uniform :)
                 8-you choose where the first team be tped and where the second team be tped
                 9-when event start, you set a max time for event.So if ppl couldnt kill each other( if players in first team = players in second team when event times finish) They will automatically be sent to temple and no one will take reward and broadcast :)
                 10 -during event if max time didnt finish and player of team 1 killed all of those of team2 then players of team1 will be tped to temple broadcasting they won by killing all other members and will recieve a random reward taht you set
                 11 -Then the event will be on hold untill time between each event pass(you set that) , and when it pass a auto broadcast is made every minute to tell player that event is open.
   </description>
 
<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=21365, y=17657, z=7} --place where the red team player be teleported to
      blueposition = {x=21223, y=17491, z=7} --place where the blue team player be teleported to
       stoptime = 30 --in minutes
 
     team1name = "blue" --just put the name without <team>
       team2name = "red" 
       timebetween = 35 -- time between each event 
 
               arena = {{frompos = {x=21106, y=17772, z=7}, topos = {x=21455, y=17361, z=7}}} ----Put you event area here
              conf = {
 
                        rewards_id = {10173}, -- Rewards ID
                    maxplayers = 50 ---maxplayers per team
                }
 
 ]]></config>
 <lib name="football-lib"><![CDATA[
 
function getBlue()
	return getGlobalStorageValue(9888)
end
 function removeBlue()
    return setGlobalStorageValue(9888, getGlobalStorageValue(9888) - 1)
end
function addBlue()
   return setGlobalStorageValue(9888, getGlobalStorageValue(9888) + 1)
end
function resetBlue()
      return setGlobalStorageValue(9888,0)
end
 
function getRed()
	return getGlobalStorageValue(9887)
end
 function removeRed()
    return setGlobalStorageValue(9887, getGlobalStorageValue(9887) - 1)
end
function addRed()
   return setGlobalStorageValue(9887, getGlobalStorageValue(9887) + 1)
end
function resetRed()
      return setGlobalStorageValue(9887,0)
end
]]></lib>
 
 
<event type="login" name="Tutorial Login" event="script"><![CDATA[
domodlib('football-lib')
        function onLogin(cid)
 
		if getPlayerStorageValue(cid,check) > 0 then
           if isInRange(getCreaturePosition(cid), arena.frompos, arena.topos) then
		         doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), FALSE)
                 doSendMagicEffect(getCreaturePosition(cid), 10)
				 setPlayerStorageValue(cid,check,-1)
		   else
               		setPlayerStorageValue(cid,check,-1)   
           end
		end
                registerCreatureEvent(cid, "Log")
                   registerCreatureEvent(cid, "Arena")
               registerCreatureEvent(cid, "Attk")
 
        return true
    end
 
]]></event>
    <event type="combat" name="Attk" event="script"><![CDATA[
        domodlib('tutorial_m')
		domodlib('football-lib')
        function onCombat(cid, target)
        if getPlayerStorageValue(cid, joined) == 1 and getPlayerStorageValue(target, joined) == 1 then
 
                return false
        end
                if getPlayerStorageValue(cid, joined) == 2 and getPlayerStorageValue(target, joined) == 2 then
 
                return false
        end
        return true
end
]]></event>
 <event type="logout" name="Log" event="script"><![CDATA[
 domodlib('football-lib')
 domodlib('tutorial_m')
 function onLogout(cid)
  if getPlayerStorageValue(cid,joined) == 1 then
    doBroadcastMessage(""..getPlayerName(cid).." have left the War-Event")
    setPlayerStorageValue(cid,joined,-1)
	setPlayerStorageValue(cid,check,1)
        removeBlue()
   return true
   end
   if getPlayerStorageValue(cid,joined) == 2 then
    doBroadcastMessage(""..getPlayerName(cid).." have left the War-Event")
   setPlayerStorageValue(cid,check,1)
        removeRed()
   return true
   end
   return true
  end
 
]]></event>
<event type="statschange" name="Arena" event="script"><![CDATA[
domodlib('football-lib')
domodlib('tutorial_m')
local corpse_ids = {
        [0] = 3065, -- female
        [1] = 3058 -- male
}
function onStatsChange(cid, attacker, type, combat, value)
        if combat == COMBAT_HEALING then
                return true
        end
 
        if getCreatureHealth(cid) > value then
                return true
        end
 
 
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)
        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,10000,-1)
                elseif getPlayerStorageValue(cid,joined) == 2 then
                   removeRed()
 
                   setPlayerStorageValue(cid,10000,-1)
                  end
	end
        return false
 
end
 
]]></event>
 <globalevent name="reset" type="start" event="script"><![CDATA[
 domodlib('football-lib')
 domodlib('tutorial_m')
     function onStartup()
	     resetBlue()
          resetRed()
		    setGlobalStorageValue(running1,-1)
  setGlobalStorageValue(running2,-1)
   setGlobalStorageValue(sto,-1)
 
	return true
end
 ]]></globalevent>
  <globalevent name="TeamBattle" interval="7000" event="script"><![CDATA[
		domodlib('football-lib')
        domodlib('tutorial_m')
 
 
 
local bmale = createConditionObject(CONDITION_OUTFIT)
setConditionParam(bmale, CONDITION_PARAM_TICKS, -1)
addOutfitCondition(bmale, {lookType = math.random(128,134), lookHead = 88, lookBody = 88, lookLegs = 88, lookFeet = 88, lookTypeEx = 0, lookAddons = 3})
 
local bfemale = createConditionObject(CONDITION_OUTFIT)
setConditionParam(bfemale, CONDITION_PARAM_TICKS, -1)
addOutfitCondition(bfemale, {lookType = math.random(136,142), lookHead = 88, lookBody = 88, lookLegs = 88, lookFeet = 88, lookTypeEx = 0, lookAddons = 3})
 
local rmale = createConditionObject(CONDITION_OUTFIT)
setConditionParam(rmale, CONDITION_PARAM_TICKS, -1)
addOutfitCondition(rmale, {lookType = math.random(128,134), lookHead = 94, lookBody = 94, lookLegs = 94, lookFeet = 94, lookTypeEx = 0, lookAddons = 3})
 
local rfemale = createConditionObject(CONDITION_OUTFIT)
setConditionParam(rfemale, CONDITION_PARAM_TICKS, -1)
addOutfitCondition(rfemale, {lookType = math.random(136,142),lookHead = 94, lookBody = 94, lookLegs = 94, lookFeet = 94, lookTypeEx = 0, lookAddons = 3})
 
function onStop()
if getGlobalStorageValue(running1) == 1 then
setGlobalStorageValue(running1, -1)
setGlobalStorageValue(sto,1)
end
return true
end
function onStopp()
if getGlobalStorageValue(running2) > 0 then
  setGlobalStorageValue(running2,-1)
  doBroadcastMessage("Event : event is started again , go talk to the Evnet's Npc.")
  end
end
function onThink(interval, lastExecution)
local random_item = conf.rewards_id[math.random(1, #conf.rewards_id)]
 if (getBlue() == conf.maxplayers and getRed() == conf.maxplayers) then 
           if (getGlobalStorageValue(running1) == -1 and getGlobalStorageValue(sto) == -1) then
          setGlobalStorageValue(running1,1)
                 doBroadcastMessage("The Team Battle Event have started.And will end in "..stoptime.." minutes, unless one of the teams has killed all the oponents")
                  addEvent(onStop, stoptime * 60 * 1000)
              addEvent(onStopp, timebetween * 60 * 1000)
         for _, cid in ipairs(getPlayersOnline()) do
 
             if getPlayerStorageValue(cid, joined) == 1 then  
                     if getPlayerSex(cid) == 1 then
                        doAddCondition(cid, bmale)
                elseif getPlayerSex(cid) ~= 1 then
                        doAddCondition(cid, bfemale)
                end
                   doTeleportThing(cid, blueposition, FALSE)
            doSendMagicEffect(blueposition, 10)
                 elseif getPlayerStorageValue(cid, joined) == 2 then 
                       if getPlayerSex(cid) == 1 then
                 doAddCondition(cid, rmale)
               elseif getPlayerSex(cid) ~= 1 then
                  doAddCondition(cid, rfemale)
               end
                   doTeleportThing(cid, redpotision, FALSE)
            doSendMagicEffect(redpotision, 10)
                 end
                end
      end
        end
   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 oponnent team ,they will recieve 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)
                        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 oponnent team,they will recieve their rewards.Event will be reopened in ".. timebetween .." minutes")
                         doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), FALSE)
						 doRemoveConditions(cid, FALSE)
                         doSendMagicEffect(getCreaturePosition(cid), 10)
                         doRemoveConditions(cid)
                          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
return true
end
]]></globalevent>
<globalevent name="Team" interval="3000" event="script"><![CDATA[
domodlib('football-lib')
domodlib('tutorial_m')
 
function onThink(interval, lastExecution)
 
local random_item = conf.rewards_id[math.random(1, #conf.rewards_id)]
if getGlobalStorageValue(sto) == 1 then
 if (getRed() > getBlue()) then
 doBroadcastMessage("The War-Event has finished as the " ..team2name.. "  team has killed all players in oponnent team,they will recieve 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)
        doSendMagicEffect(getCreaturePosition(cid), 10)
		doRemoveConditions(cid, FALSE)
                                         doPlayerAddItem(cid, random_item, 1)
										 doRemoveConditions(cid)
                                doCreatureSay(cid, "You have won a "..getItemNameById(random_item).." as a reward from war event", TALKTYPE_ORANGE_1)
                                setPlayerStorageValue(cid, joined,-1)
 
 
 
         end    
       if getPlayerStorageValue(cid,joined) == 1 then
                           doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), FALSE)
        doSendMagicEffect(getCreaturePosition(cid), 10)
                   doPlayerSendTextMessage(cid,24, "Your team has lost in the war event war event")
                   setPlayerStorageValue(cid, joined,-1)
				   doRemoveConditions(cid, FALSE)
 
                end                                      
        end
 end
  if (getRed() < getBlue()) then
 doBroadcastMessage("The War-Event has finished as the " ..team1name.. "  team has killed all players in oponnent team,they will recieve 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)
                                         doPlayerAddItem(cid, random_item, 1)
										 doRemoveConditions(cid)
										 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)
 
 
 
         end    
       if getPlayerStorageValue(cid,joined) == 2 then
                           doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), FALSE)
						   doRemoveConditions(cid, FALSE)
        doSendMagicEffect(getCreaturePosition(cid), 10)
                   doPlayerSendTextMessage(cid,24, "Your team has lost in the war event war event")
                   setPlayerStorageValue(cid, joined,-1)
 
                end                                      
        end
 end
 if (getRed() == getBlue()) then
    for _, cid in ipairs(getPlayersOnline()) do
          if getPlayerStorageValue(cid,joined) == 2 or getPlayerStorageValue(cid,joined) == 1 then 
                          doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), FALSE)
						  doRemoveConditions(cid, FALSE)
        doSendMagicEffect(getCreaturePosition(cid), 10)
				   doRemoveConditions(cid)
                    setPlayerStorageValue(cid, joined,-1)
                        doBroadcastMessage("Event max time ended.And niether of the teams won the event.Event will be reopened in ".. timebetween .." minutes")
      end                       
    end
 end
 resetBlue()
 resetRed()
 setGlobalStorageValue(sto, -1)
end
return true
end
]]></globalevent>
        <globalevent name="Broad" interval="90000" event="script"><![CDATA[
		domodlib('football-lib')
                domodlib('tutorial_m')
 
function onThink(interval, lastExecution)
  if getGlobalStorageValue(running2) == -1 then
        return true
        end
return true
end
 ]]></globalevent>
 <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>
</mod>


LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
 
function onCreatureAppear(cid)                npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid)            npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg)            npcHandler:onCreatureSay(cid, type, msg) end
function onThink()                    npcHandler:onThink() end
 
    --[[Start edit]]--  
 
        local mingroup = 4 --(updated) minimum group to reset the event
        local joined = 10000 ---must be like the storage in mod
        local maxPlayerEachTeam = 50 ---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]]--
 
 
 --[[End of edit]]--
local function getBlue()
	return getGlobalStorageValue(9888)
end
 local function removeBlue()
    return setGlobalStorageValue(9888, getGlobalStorageValue(9888) - 1)
end
local function addBlue()
   return setGlobalStorageValue(9888, getGlobalStorageValue(9888) + 1)
end
local function resetBlue()
      return setGlobalStorageValue(9888,0)
end
 
local function getRed()
	return getGlobalStorageValue(9887)
end
 local function removeRed()
    return setGlobalStorageValue(9887, getGlobalStorageValue(9887) - 1)
end
local function addRed()
   return setGlobalStorageValue(9887, getGlobalStorageValue(9887) + 1)
end
local function resetRed()
      return setGlobalStorageValue(9887,0)
end
--[[Script start]]--
 
function creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if getPlayerGroupId(cid) >= mingroup then
     npcHandler:say("Oh! Hail, sire. Do you want to reset my event?", cid)
	 talkState[talkUser] = 1
      if msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
	      	     resetBlue()
                 resetRed()
		         setGlobalStorageValue(running1,-1)
                 setGlobalStorageValue(running2,-1)
                 setGlobalStorageValue(sto,-1)
		         npcHandler:say("Event was reseted, sire.", cid)
		         doBroadcastMessage("My Event was reseted on the orders of "..getCreatureName(cid)..". So all who want to join msg me now.")
		 for _,cid in ipairs(getPlayersOnline()) do
		    if getPlayerStorageValue(cid, joined) > 0 then
			   setPlayerStorageValue(cid, joined,-1) 
			     doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), FALSE)
                 doSendMagicEffect(getCreaturePosition(cid), 10)
			 end
		 end
	  elseif msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
	    npcHandler:say("As You wish, sire.", cid)
	     talkState[talkUser] = 0
	 end
else
    if msgcontains(msg, 'battle') then
	     if getGlobalStorageValue(running2) == 1 then   
             npcHandler:say("Battle will start latter, and it will be broadcaste that you can speak to me.", cid)
         elseif getPlayerLevel(cid) < minlevel then
	         npcHandler:say("Go Away noob! Only level 120+ are allowed.",cid)
		 else
         npcHandler:say("Do you wish to join the battle? There is currently " .. getBlue() .. "/" .. maxPlayerEachTeam .. " players in {" .. team1Name .. "} team and " .. getRed() .. "/" .. maxPlayerEachTeam .. " players in {" .. team2Name .. "} team.", cid)
         talkState[talkUser] = 1
	     end
    elseif msgcontains(msg, 'yes') and talkState[talkUser] == 1 then
        if getPlayerStorageValue(cid, joined) ~= 1 and getPlayerStorageValue(cid, joined) ~= 2 then
            npcHandler:say("Do you wish to join {" .. team1Name .. "} team  or {" .. team2Name .. "} team?", cid)
            talkState[talkUser] = 2
        else
            npcHandler:say("You are already signed up!", cid)
            talkState[talkUser] = 0
        end
    elseif msgcontains(msg, 'no') and talkState[talkUser] == 1 then
        npcHandler:say("Okay then.", cid)
        talkState[talkUser] = 0
    elseif msgcontains(msg, team1Name) and talkState[talkUser] == 2 then
        if getBlue() ~= maxPlayerEachTeam then --fixed
            setPlayerStorageValue(cid, joined, 1)
           addBlue()
            npcHandler:say("You have joined " .. team1Name .. " team! When both teams have " .. maxPlayerEachTeam .. " players you will be teleported to the battle arena.Please dont log out.", cid)
 
            talkState[talkUser] = 0
        else
            npcHandler:say("{" .. team1Name .. "} team is currently full, join {" .. team2Name .. "} team or wait for someone to leave {" .. team1Name .. "} team.", cid) --fixed
            talkState[talkUser] = 1
        end
    elseif msgcontains(msg, team2Name) and talkState[talkUser] == 2 then
        if getRed() ~= maxPlayerEachTeam then --fixed
            setPlayerStorageValue(cid, joined, 2) --fixed
           addRed()
            npcHandler:say("You have joined " .. team2Name .. " team! When both teams have " .. maxPlayerEachTeam .. " players you will be teleported to the battle arena.", cid)
 
            talkState[talkUser] = 0
        else
            npcHandler:say("{" .. team2Name .. "} team is currently full, join {" .. team1Name .. "} team or wait for someone to leave {" .. team2Name .. "} team.", cid)
            talkState[talkUser] = 1
        end
 elseif msgcontains(msg, 'leave') then
        npcHandler:say("Do you wish to leave the battle?", cid)
        talkState[talkUser] = 3
    elseif msgcontains(msg, 'yes') and talkState[talkUser] == 3 then
        if getPlayerStorageValue(cid,joined) == 1 then
            setPlayerStorageValue(cid, joined, -1) -- fixed
           removeBlue()
            npcHandler:say("You have left the battle.", cid)
            doBroadcastMessage("Event: " .. getPlayerName(cid) .. " have left the battle between " .. team1Name .. " and " .. team2Name .. "!")
        elseif getPlayerStorageValue(cid,joined) == 2 then --fixed
		      setPlayerStorageValue(cid,joined,-1)
              removeRed()
              npcHandler:say("You have left the battle.", cid)
             doBroadcastMessage("Event: " .. getPlayerName(cid) .. " have left the battle between " .. team1Name .. " and " .. team2Name .. "!")
		else
            npcHandler:say("You are not even signed up!", cid)
        end
        talkState[talkUser] = 0 -- moved
    end 
end	
    return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Seems your (isInRange ) function is wrong

change the one you have in lib -->positions to this :
Code:
function isInRange(position, fromPosition, toPosition)
	return (position.x >= fromPosition.x and position.y >= fromPosition.y and position.z >= fromPosition.z and position.x <= toPosition.x and position.y <= toPosition.y and position.z <= toPosition.z)
end
 
Last edited:
I already have this... What this bugs does? Doesn't kill players... They get 0 HP and don't die :S

This scripts works for you?
 
@update :

Nice , My players was also suffering from not findding each others, I had same error as kito but replace my isInRangs , and it worked like a charm, thanks man
 
Updated all and doesn't work... When players get teleporteds, the same error is displayed...


Code:
[1:6:56.082] [Error - CreatureScript Interface] 
[1:6:56.082] domodlib('football-lib')
[1:6:56.082]         function onLogin(cid)
[1:6:56.082]  
[1:6:56.082]            if getPlayerStorageValue(cid,check) > 0 then
[1:6:56.082]            if isInRange(getCreaturePosition(cid), arena.frompos, arena.topos) then
[1:6:56.082]                     doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), FALSE)
[1:6:56.082]                  doSendMagicEffect(getCreaturePosition(cid), 10)
[1:6:56.082]                             setPlayerStorageValue(cid,check,-1)
[1:6:56.082]               else
[1:6:56.082]                            setPlayerStorageValue(cid,check,-1)   
[1:6:56.082]            end
[1:6:56.082]            end
[1:6:56.082]                 registerCreatureEvent(cid, "Log")
[1:6:56.082]                    registerCreatureEvent(cid, "Arena")
[1:6:56.082]                registerCreatureEvent(cid, "Attk")
[1:6:56.082]  
[1:6:56.082]         return true
[1:6:56.082]     end
[1:6:56.082]  
[1:6:56.082] :onLogin
[1:6:56.082] Description: 
[1:6:56.082] data/lib/032-position.lua:2: attempt to index local 'fromPosition' (a nil value)
[1:6:56.082] stack traceback:
[1:6:56.082]    data/lib/032-position.lua:2: in function 'isInRange'
[1:6:56.082]    [string "LuaInterface::loadBuffer"]:5: in function <[string "LuaInterface::loadBuffer"]:2>
 
Ah, now recopy the mod, it was a little update forgot to add config, to that login script. Keep testing and tell me result

Edit : thought it works 100 % :)
 
Last edited:
Back
Top