Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 20.56 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <mod name="Team Event" version="2.0" author="Damadgerz" contact="support@lualand.net" enabled="yes">
  3. <description>
  4. Full auto Team BattleEvent(v2.0) for 0.3.6PL1 :
  5.  
  6. 1- I currently rescripted this event from scratch again.
  7.  
  8. 2- This version is much more better than the one before, it is more cleaner, clearer and with more options.
  9.  
  10. 3- This version dislike the previous one , was tested on 0.3.6PL1 and works just fine.
  11.  
  12. 4- Removed the npc part it is now based on tp creation.
  13.  
  14. 5- More silent boradcasting for in event progress and no spam, I hope!
  15.  
  16. 6- you now get the options to show event stats on cancel msg area and (to / not to) show left players with names each x interval.
  17.  
  18. 8- Team balancer have been added to only balance count in both teams.
  19.  
  20. 9- Added a countdown option before fight starts.
  21.  
  22. 10- Now starts on a defined time every day
  23.  
  24. </description>
  25.  
  26. <config name="teamSetting"><![CDATA[
  27. --[[Local Config]]--
  28.  
  29. --//storages
  30.  
  31. inBlue = 9900
  32. inRed = 9901
  33. joiner = 9907
  34.  
  35. blueKills = 9902
  36. redKills = 9903
  37.  
  38. eventRecruiting = 9904
  39. eventStarted = 9905
  40. eventTime = 9906
  41.  
  42. itemToGet = 9908
  43. countItemToGet = 9909
  44.  
  45. nextExecute = 9910
  46.  
  47. blueCount = 9911
  48. redCount = 9912
  49.  
  50. --// Positions
  51.  
  52. teleporterPosition = {x = 1504, y = 2611, z = 7} --Place where the event tp will be created
  53.  
  54. waitRoomPlace = {x = 1530, y = 2580, z = 7} --Place of the waitnig room (the place ppl will wait for team to be full)
  55.  
  56. waitRoomDimensions = { --Enter the start pos[top left sqm] and end pos[bottom right sqm] of waitnig room here
  57. startPos = {x = 1523, y = 2575, z = 7},
  58. endPos = {x = 1537, y = 2585, z = 7}
  59. }
  60.  
  61.  
  62. eventPlaceDimensions = { --Enter the start pos[top left sqm] and end pos[bottom right sqm] of event place here
  63. startPos = {x = 461, y = 2457, z = 2},
  64. endPos = {x = 582, y = 2585, z = 7}
  65. }
  66. blueTeamPos = {x = 493, y = 2480, z = 6}
  67. redTeamPos = {x = 561, y = 2545, z = 6}
  68.  
  69.  
  70. --// General settings
  71.  
  72. recruitTime = 5 -- Time in minutes to gather players to event, will broadcast event started each min
  73.  
  74. minimumPlayersJoins = 4 --If the number of layer joined is less than that then event would be cancelled
  75.  
  76. balanceTeams = true -- This will balance number of players in both teams the extra player will be kicked out of event
  77.  
  78.  
  79. removeTeleportOnEventEnd = true -- if you want to remove the tp when the event finish set it to true, normally tp will just be diabled
  80.  
  81. eventMaxTime = 10 -- Time in minutes, this is the max time event will be running. After checks are caried winner is declared
  82.  
  83. showEventSats = true -- This is like a timer that is always there about event stats (time,oponents left, teammates left). It appears in the cancel messages place.
  84.  
  85. sendLeftPlayers = true -- Well this will send to all alive players the names& numebr of the oponents left each interval defined down
  86. intervalToSendLeftPlayers = 11 -- interval(in seconds) to sendLeftPlayers , must be more than 10 sec
  87.  
  88.  
  89. countDownOnStart = true -- Well this occurs when players are teleported to their places in the arena , so if this is true it start to count down to the joined players then when count down finish they can start killing each other(event really begins)
  90.  
  91. countDownFrom = 10 -- Starts count down from this number when event start, if above is set true
  92.  
  93. minJoinLevel = 100 -- minimm lvl that can join event
  94.  
  95. rewards = { --Example [%] = { {itemid/name, count} ,..........} count isnt more than 100
  96.  
  97. [100] = { {"12661",1} }
  98. }
  99.  
  100. --[[ Note : make sure if you edited % that sum should be equal to 100, you can add more % elements to suit your needs also more items if you want in each %
  101. [65],[25],[10] -> is the % of this item to be found the rest is clear ,items in each % and it will be chosen randomly]]--
  102.  
  103.  
  104. ]]></config>
  105. <lib name="teamFunctions"><![CDATA[
  106. domodlib('teamSetting')
  107.  
  108. --[[Conditions don't touch]]--
  109. local bmale = createConditionObject(CONDITION_OUTFIT)
  110. setConditionParam(bmale, CONDITION_PARAM_TICKS, -1)
  111. addOutfitCondition(bmale, {lookType = math.random(128,134), lookHead = 88, lookBody = 88, lookLegs = 88, lookFeet = 88, lookTypeEx = 0, lookAddons = 3})
  112.  
  113. local bfemale = createConditionObject(CONDITION_OUTFIT)
  114. setConditionParam(bfemale, CONDITION_PARAM_TICKS, -1)
  115. addOutfitCondition(bfemale, {lookType = math.random(136,142), lookHead = 88, lookBody = 88, lookLegs = 88, lookFeet = 88, lookTypeEx = 0, lookAddons = 3})
  116.  
  117. local rmale = createConditionObject(CONDITION_OUTFIT)
  118. setConditionParam(rmale, CONDITION_PARAM_TICKS, -1)
  119. addOutfitCondition(rmale, {lookType = math.random(128,134), lookHead = 94, lookBody = 94, lookLegs = 94, lookFeet = 94, lookTypeEx = 0, lookAddons = 3})
  120.  
  121. local rfemale = createConditionObject(CONDITION_OUTFIT)
  122. setConditionParam(rfemale, CONDITION_PARAM_TICKS, -1)
  123. addOutfitCondition(rfemale, {lookType = math.random(136,142),lookHead = 94, lookBody = 94, lookLegs = 94, lookFeet = 94, lookTypeEx = 0, lookAddons = 3})
  124.  
  125. local infight = createConditionObject(CONDITION_INFIGHT,-1)
  126. --[[Local Config]]--
  127.  
  128. --[[Functions]]--
  129.  
  130. -- General info
  131. function isFightOn()
  132. return getStorage(eventStarted) > 0
  133. end
  134. function isRecruitOn()
  135. return getStorage(eventRecruiting) > 0
  136. end
  137. function getMinJoinLevel()
  138. return minJoinLevel
  139. end
  140. function getJoiners()
  141. joiners = {}
  142. for _,cid in ipairs(getPlayersOnline()) do
  143. if isJoiner(cid) then
  144. if isInRecruitArea(cid) or isInFightArea(cid) then
  145. table.insert(joiners,cid)
  146. end
  147. end
  148. end
  149. return joiners
  150. end
  151.  
  152. function getLeftMembersNames(team)
  153. str = "Oponents left("..#team..") :"
  154. left = ""
  155. for k,cid in ipairs(team) do left = (left ..""..(k == 1 and "" or ", ")..""..getCreatureName(cid).."["..getPlayerLevel(cid).."]" ) end
  156. str = str .." " .. (left == "" and "none" or left).. "."
  157. return str
  158. end
  159. function disPlayEventStats()
  160. if not showEventSats then return false end
  161. if getStorage(eventTime) - os.time() <= 0 then return false end
  162.  
  163. left = os.date("%M:%S",(getStorage(eventTime) - os.time()))
  164. for _,cid in ipairs(getJoiners()) do
  165. oponentsLeft = isBlue(cid) and #getRedMembers() or #getBlueMembers()
  166. teamMatesLeft = isBlue(cid) and math.max(0,#getBlueMembers()-1) or math.max(0,#getRedMembers()-1)
  167. doPlayerSendCancel(cid,"Time left: ".. left.." || Oponents left: "..oponentsLeft.."/"..oponentCount(cid).." || Team-mates left: "..teamMatesLeft.."/".. math.max(0,matesCount(cid)-1))
  168. end
  169.  
  170. end
  171.  
  172. function doSendLeftPlayers()
  173. if not sendLeftPlayers then return false end
  174. if intervalToSendLeftPlayers <= 10 then return false end
  175. for _,cid in ipairs(getJoiners()) do
  176. doPlayerSendTextMessage(cid,MESSAGE_TYPES["orange"],getLeftMembersNames(isRed(cid) and getBlueMembers() or getRedMembers()))
  177. end
  178. end
  179.  
  180. function getBlueMembers()
  181. members = {}
  182. for _,cid in ipairs(getPlayersOnline()) do
  183. if isBlue(cid) then
  184. table.insert(members,cid)
  185. end
  186. end
  187. return members
  188. end
  189. function getRedMembers()
  190. members = {}
  191. for _,cid in ipairs(getPlayersOnline()) do
  192. if isRed(cid) then
  193. table.insert(members,cid)
  194. end
  195. end
  196. return members
  197. end
  198.  
  199.  
  200. -- starting fight
  201.  
  202. function startRecruiting()
  203. doSetStorage(eventRecruiting,1)
  204. end
  205. function startEvent()
  206. doSetStorage(eventRecruiting,-1)
  207.  
  208. if removeTeleportOnEventEnd then
  209. tp = getTileItemById(teleporterPosition,1387).uid
  210. if tp > 0 then doRemoveItem(tp) end
  211. end
  212.  
  213. if not balanceTeams() then
  214. resetEvent()
  215. return false
  216. end
  217. for _,cid in ipairs(getBlueMembers()) do
  218. doTeleportThing(cid,blueTeamPos,false)
  219. doSendMagicEffect(getThingPos(cid),10)
  220. end
  221. setBlueCount(#getBlueMembers())
  222. for _,cid in ipairs(getRedMembers()) do
  223. doTeleportThing(cid,redTeamPos,false)
  224. doSendMagicEffect(getThingPos(cid),10)
  225. end
  226. setRedCount(#getRedMembers())
  227. startCountDown()
  228. return true
  229. end
  230.  
  231. function setBlueCount(count)
  232. doSetStorage(blueCount,-1)
  233. doSetStorage(blueCount,count)
  234. end
  235. function oponentCount(cid)
  236. return isBlue(cid) and getStorage(redCount) or getStorage(blueCount)
  237. end
  238. function matesCount(cid)
  239. return isBlue(cid) and getStorage(blueCount) or getStorage(redCount)
  240. end
  241.  
  242. function setRedCount(count)
  243. doSetStorage(redCount,-1)
  244. doSetStorage(redCount,count)
  245. end
  246. function balanceTeams()
  247. members = getJoiners()
  248. if #members < minimumPlayersJoins then
  249. doBroadcastMessage("Team-Battle event was cancelled as only ".. #members .. " players joined.")
  250. return false
  251. end
  252. if (math.mod(#members,2) ~= 0) then
  253. kicked = members[#members]
  254. clearTeamEventStorages(kicked)
  255. doPlayerSendTextMessage(kicked,MESSAGE_TYPES["info"],"Sorry, you have been kicked out of event for balancing both teams.")
  256. end
  257. count = 1
  258. for _,cid in ipairs(getJoiners()) do
  259. if (math.mod(count,2) ~= 0) then
  260. addToBlue(cid)
  261. else
  262. addToRed(cid)
  263. end
  264. count = count + 1
  265. end
  266. return true
  267. end
  268. function startCountDown()
  269. if(countDownOnStart) then
  270. for _,cid in ipairs(getJoiners()) do
  271. doCreatureSetNoMove(cid,true)
  272. for i = 0,countDownFrom do
  273. addEvent(doPlayerSendTextMessage,i*1000, cid, MESSAGE_TYPES["info"], (i == 0 and countDownFrom or countDownFrom-i) )
  274. end
  275. end
  276. addEvent(startFight,(countDownFrom+1)*1000)
  277. else
  278. startFight()
  279. end
  280. end
  281. function startFight()
  282. doSetStorage(eventStarted,1)
  283. for _,cid in ipairs(getJoiners()) do
  284. doCreatureSetNoMove(cid,false)
  285. doPlayerSendTextMessage(cid,MESSAGE_TYPES["warning"],"Fight Starts!")
  286. end
  287. addEvent(endTeamEvent,eventMaxTime*60*1000,"maxTime")
  288. doSetStorage(eventTime,os.time()+eventMaxTime*60)
  289. end
  290.  
  291. function teleportToWaitRoom(cid)
  292. doTeleportThing(cid,waitRoomPlace)
  293. doSendMagicEffect(waitRoomPlace,10)
  294. if getPlayerGroupId(cid) < 4 then
  295. addToJoiners(cid)
  296. end
  297. doPlayerSendTextMessage(cid,MESSAGE_TYPES["blue"],"Please be patient till the event starts and don't logout.")
  298. return true
  299. end
  300.  
  301.  
  302.  
  303. -- Modifing teams & checking member states
  304. function isBlue(cid)
  305. return (getPlayerStorageValue(cid,inBlue) > 0)
  306. end
  307. function isRed(cid)
  308. return (getPlayerStorageValue(cid,inRed) > 0)
  309. end
  310. function isJoiner(cid)
  311. return (getPlayerStorageValue(cid,joiner) > 0)
  312. end
  313. function addToBlue(cid)
  314. setPlayerStorageValue(cid,inBlue,1)
  315. doAddCondition(cid, (getPlayerSex(cid) == 1) and bmale or bfemale)
  316. doAddCondition(cid,infight)
  317. end
  318. function addToRed(cid)
  319. setPlayerStorageValue(cid,inRed,1)
  320. doAddCondition(cid, (getPlayerSex(cid) == 1) and rmale or rfemale)
  321. doAddCondition(cid,infight)
  322. end
  323. function addToJoiners(cid)
  324. setPlayerStorageValue(cid,joiner,1)
  325. end
  326. function removeFromBlue(cid)
  327. setPlayerStorageValue(cid,inBlue,-1)
  328. end
  329. function removeFromRed(cid)
  330. setPlayerStorageValue(cid,inRed,-1)
  331. end
  332. function removeFromjoiners(cid)
  333. setPlayerStorageValue(cid,joiner,-1)
  334. end
  335. function isInRecruitArea(cid)
  336. return isInRange(getThingPos(cid),waitRoomDimensions.startPos,waitRoomDimensions.endPos)
  337. end
  338. function isInFightArea(cid)
  339. return isInRange(getThingPos(cid),eventPlaceDimensions.startPos,eventPlaceDimensions.endPos)
  340. end
  341. function clearTeamEventStorages(cid)
  342.    if isPlayer(cid) then -- does player exist?
  343.        if isInRecruitArea(cid) or isInFightArea(cid) then
  344.            doTeleportThing(cid,getTownTemplePosition(getPlayerTown(cid)))
  345.            doSendMagicEffect(getThingPos(cid),10)
  346.        end
  347.    
  348.        if isFightOn() then
  349.            if isJoiner(cid) then
  350.                if isBlue(cid) then
  351.                    addRedKills()
  352.                elseif isRed(cid) then
  353.                    addBlueKills()
  354.                end
  355.                doPlayerSendTextMessage(cid,MESSAGE_TYPES["orange"],"You have died in Team-Battle Event.")
  356.            end
  357.        end
  358.    
  359.        removeFromjoiners(cid)
  360.        removeFromBlue(cid)
  361.        removeFromRed(cid)
  362.        doRemoveConditions(cid)
  363.         if getCreatureCondition(cid, CONDITION_OUTFIT) then
  364.         doRemoveCondition(cid, CONDITION_OUTFIT)
  365.         end
  366.    end
  367. end
  368. function haveUnrecivedReward(cid)
  369. return getPlayerStorageValue(cid,itemToGet) > 0 and getPlayerStorageValue(cid,countItemToGet) > 0
  370. end
  371. function recieveLateReward(cid)
  372. if haveUnrecivedReward(cid) then
  373. if not doPlayerAddItem(cid,getPlayerStorageValue(cid,itemToGet),getPlayerStorageValue(cid,countItemToGet),false) then
  374. msg = "You need to free some space then relog to take your reward."
  375. doPlayerSendTextMessage(cid,MESSAGE_TYPES["warning"],msg)
  376. else
  377. setPlayerStorageValue(cid,itemToGet,-1)
  378. setPlayerStorageValue(cid,countItemToGet,-1)
  379. doPlayerSendTextMessage(cid,MESSAGE_TYPES["info"],"You have recieved your reward.")
  380. end
  381. end
  382. end
  383.  
  384. -- Win or lose
  385. function thereIsAWinner()
  386. if redWon() or blueWon() then
  387. return true
  388. end
  389. return false
  390. end
  391. function blueWon()
  392. return( (#getBlueMembers() > 0 ) and ( #getRedMembers() == 0) )
  393. end
  394. function redWon()
  395. return( (#getRedMembers() > 0) and (#getBlueMembers() == 0) )
  396. end
  397. function isDraw()
  398. return #getBlueMembers() == #getRedMembers()
  399. end
  400. function getWinner()
  401. if #getBlueMembers() > #getRedMembers() then
  402. return {getBlueMembers(),getRedMembers(),"Blue team won."}
  403. elseif #getRedMembers() > #getBlueMembers() then
  404. return {getRedMembers(),getBlueMembers(),"Red team won."}
  405. else
  406. return { {},{},"it was a draw."}
  407. end
  408. end
  409.  
  410.  
  411. -- Adding kills
  412. function addBlueKills()
  413. doSetStorage(blueKills, math.max(1,getStorage(blueKills)+1))
  414. end
  415. function addRedKills()
  416. doSetStorage(redKills, math.max(1,getStorage(redKills)+1))
  417. end
  418.  
  419. -- Ending event
  420.  
  421. function endTeamEvent(type)
  422. if isFightOn() then
  423. doSetStorage(eventStarted,-1)
  424. doBroadcastMessage("Team-Battle event ended and "..getWinner()[3])
  425. if not isDraw() then
  426. win(getWinner()[1],type)
  427. lose(getWinner()[2],type)
  428. else
  429. draw()
  430. end
  431. end
  432. addEvent(resetEvent,2 * 1000) --- tp player to home remove all storages and reset event global storages
  433. end
  434.  
  435. function getPercent()
  436. rand= math.random(1,100)
  437. prev = 0
  438. chosenItem = 0
  439. for k, v in pairs(rewards) do
  440. if rand > prev and rand <= k+prev then
  441. chosenItem = k
  442. break
  443. else
  444. prev = k+prev
  445. end
  446. end
  447. return chosenItem
  448. end
  449.  
  450. function generateReward(cid)
  451. percent = getPercent()
  452. if percent == 0 then
  453. print("Error in the reward item. Please inform Administrator.")
  454. return true
  455. end
  456.  
  457. randomizer = rewards[percent][math.random(1,#rewards[percent])]
  458. item = not tonumber(randomizer[1]) and getItemIdByName(randomizer[1]) or randomizer[1]
  459. count = isItemStackable(item) and math.min(randomizer[2],100) or 1
  460. if item == nil or item == 0 then
  461. print("Error in the item format. Please inform Administrator.")
  462. return true
  463. end
  464.  
  465. msg = "You have won ".. (count == 1 and "a" or count) .." " .. getItemNameById(item) .. "" .. (count == 1 and "" or "s").."."
  466.  
  467. if not doPlayerAddItem(cid,item,count,false) then
  468. msg = msg.. "You need to free some space then relog to take your reward."
  469. setPlayerStorageValue(cid,itemToGet,item)
  470. setPlayerStorageValue(cid,countItemToGet,count)
  471. end
  472.  
  473. doPlayerSendTextMessage(cid,MESSAGE_TYPES["white"],msg)
  474.  
  475. end
  476.  
  477.  
  478.  
  479. function generateStatsMessage(cid, type, stats)
  480. msg = {
  481. ["KO"] = { ["win"] = "Event ended. Your team have won by killing all oponent's team members. You will recieve your reward shortly, check incoming messages.",
  482. ["lose"] = "Event ended. Your team have lost as the Oponent team killed all your team's members."
  483. },
  484. ["maxTime"] = {
  485. ["win"] = "Event max-time finished and your team have won. You will recieve your reward shortly, check incoming messages.",
  486. ["lose"] = "Event max-time finished and your team have lost.",
  487. ["draw"] = "Event max-time finished and it is a draw.(no team won)"
  488. }
  489. }
  490. doPlayerSendTextMessage(cid,MESSAGE_TYPES["info"],msg[type][stats])
  491.  
  492. end
  493. function win(winners,type)
  494. for _,cid in ipairs(winners) do
  495. generateStatsMessage(cid, type, "win")
  496. generateReward(cid)
  497. end
  498. end
  499. function lose(losers,type)
  500. for _,cid in ipairs(losers) do
  501. generateStatsMessage(cid, type, "lose")
  502. end
  503. end
  504. function draw()
  505. for _,cid in ipairs(getJoiners()) do
  506. generateStatsMessage(cid, "maxTime", "draw")
  507. end
  508. end
  509.  
  510. function resetEvent()
  511. doSetStorage(eventRecruiting,-1)
  512. doSetStorage(nextExecute,-1)
  513. doSetStorage(eventStarted,-1)
  514. doSetStorage(eventTime,-1)
  515. doSetStorage(blueKills,-1)
  516. doSetStorage(redKills,-1)
  517. for _,cid in ipairs(getPlayersOnline()) do
  518. if isBlue(cid) or isRed(cid) or isJoiner(cid) then
  519. clearTeamEventStorages(cid)
  520. end
  521. end
  522. end
  523.  
  524.  
  525. ]]></lib>
  526. <event type="login" name="teambattleLogin" event="script"><![CDATA[
  527. domodlib('teamFunctions')
  528.  
  529. function onLogin(cid)
  530. clearTeamEventStorages(cid)
  531. recieveLateReward(cid)
  532.  
  533. registerCreatureEvent(cid, "teamEventStats")
  534. registerCreatureEvent(cid, "teambattleLogout")
  535. registerCreatureEvent(cid, "teambattleCombat")
  536. return true
  537. end
  538. ]]></event>
  539. <event type="combat" name="teambattleCombat" event="script"><![CDATA[
  540. domodlib('teamFunctions')
  541.  
  542. function onCombat(cid, target)
  543. if isFightOn() then
  544. if isBlue(cid) and isBlue(target) then
  545. return false
  546. end
  547. if isRed(cid) and isRed(target) then
  548. return false
  549. end
  550. end
  551. return true
  552. end
  553.  
  554. ]]></event>
  555. <event type="logout" name="teambattleLogout" event="script"><![CDATA[
  556. domodlib('teamFunctions')
  557.  
  558. function onLogout(cid)
  559. clearTeamEventStorages(cid)
  560. if thereIsAWinner() then
  561. endTeamEvent("KO")
  562. end
  563. return true
  564. end
  565.  
  566. ]]></event>
  567. <event type="statschange" name="teamEventStats" event="script"><![CDATA[
  568. domodlib('teamFunctions')
  569.  
  570. corpse_ids = {
  571. [0] = 3065, -- female
  572. [1] = 3058 -- male
  573. }
  574. function onStatsChange(cid, attacker, type, combat, value)
  575. if combat == COMBAT_HEALING then
  576. return true
  577. end
  578. if getCreatureHealth(cid) > value then
  579. return true
  580. end
  581.  
  582. if isInFightArea(cid) and isFightOn() then
  583. if isBlue(cid) or isRed(cid) then
  584. corpse = doCreateItem(corpse_ids[getPlayerSex(cid)], 1, getThingPos(cid))
  585. doCreateItem(2016, 2, getThingPos(cid))
  586. clearTeamEventStorages(cid)
  587. doItemSetAttribute(corpse, "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[Team-Event kill]")
  588. doCreatureAddHealth(cid,getCreatureMaxHealth(cid))
  589. if thereIsAWinner() then
  590. endTeamEvent("KO")
  591. end
  592.  
  593. return false
  594.  
  595. end
  596.  
  597. end
  598.  
  599. return true
  600. end
  601. ]]></event>
  602.  
  603. <globalevent name = "teamBattleStart" time="12:00:00" event="script"><![CDATA[
  604.  
  605. domodlib('teamFunctions')
  606.  
  607. function onTime()
  608. resetEvent()
  609. if getTileItemById(teleporterPosition,1387).uid < 1 then
  610. tp = doCreateItem(1387,1,teleporterPosition)
  611. doItemSetAttribute(tp, "aid", 9990)
  612. end
  613.  
  614. startRecruiting()
  615. for i = 0, recruitTime-1 do
  616. addEvent(doBroadcastMessage, i * 60* 1000,"Team-Battle event is recruting players by entering event tp. Fight begins in "..(i == 0 and recruitTime or recruitTime-i).." minutes.",MESSAGE_TYPES["warning"])
  617. end
  618.  
  619. addEvent(startEvent, recruitTime * 60 * 1000)
  620.  
  621. return true
  622. end
  623.  
  624.  
  625. ]]></globalevent>
  626. <globalevent name = "teamBattleStart2" time="17:00:00" event="script"><![CDATA[
  627.  
  628. domodlib('teamFunctions')
  629.  
  630. function onTime()
  631. resetEvent()
  632. if getTileItemById(teleporterPosition,1387).uid < 1 then
  633. tp = doCreateItem(1387,1,teleporterPosition)
  634. doItemSetAttribute(tp, "aid", 9990)
  635. end
  636.  
  637. startRecruiting()
  638. for i = 0, recruitTime-1 do
  639. addEvent(doBroadcastMessage, i * 60* 1000,"Team-Battle event is recruting players by entering event tp. Fight begins in "..(i == 0 and recruitTime or recruitTime-i).." minutes.",MESSAGE_TYPES["warning"])
  640. end
  641.  
  642. addEvent(startEvent, recruitTime * 60 * 1000)
  643.  
  644. return true
  645. end
  646.  
  647.  
  648. ]]></globalevent>
  649. <globalevent name = "teamBattleStart3" time="22:00:00" event="script"><![CDATA[
  650.  
  651. domodlib('teamFunctions')
  652.  
  653. function onTime()
  654. resetEvent()
  655. if getTileItemById(teleporterPosition,1387).uid < 1 then
  656. tp = doCreateItem(1387,1,teleporterPosition)
  657. doItemSetAttribute(tp, "aid", 9990)
  658. end
  659.  
  660. startRecruiting()
  661. for i = 0, recruitTime-1 do
  662. addEvent(doBroadcastMessage, i * 60* 1000,"Team-Battle event is recruting players by entering event tp. Fight begins in "..(i == 0 and recruitTime or recruitTime-i).." minutes.",MESSAGE_TYPES["warning"])
  663. end
  664.  
  665. addEvent(startEvent, recruitTime * 60 * 1000)
  666.  
  667. return true
  668. end
  669.  
  670.  
  671. ]]></globalevent>
  672.  
  673. <globalevent name = "teamBattletime" interval="1" event="script"><![CDATA[
  674. domodlib('teamFunctions')
  675.  
  676. function onThink()
  677. if isFightOn() then
  678. disPlayEventStats()
  679.  
  680. if getStorage(nextExecute) == -1 or getStorage(nextExecute) <= os.time() then
  681. doSendLeftPlayers()
  682. doSetStorage(nextExecute,os.time()+intervalToSendLeftPlayers)
  683. end
  684. end
  685. return true
  686. end
  687.  
  688. ]]></globalevent>
  689. <movevent type="StepIn" actionid="9990" event="script"><![CDATA[
  690. domodlib('teamFunctions')
  691.  
  692. function onStepIn(cid, item, position, fromPosition)
  693. if not isRecruitOn() then
  694. doPlayerSendTextMessage(cid,MESSAGE_TYPES["orange"],"Event isn't currently opened.")
  695. doTeleportThing(cid,fromPosition)
  696. doSendMagicEffect(fromPosition,2)
  697. return true
  698. end
  699. if getPlayerLevel(cid) < getMinJoinLevel() then
  700. doPlayerSendTextMessage(cid,MESSAGE_TYPES["orange"],"Only players of level ".. getMinJoinLevel().. "+ can join this event.")
  701. doTeleportThing(cid,fromPosition)
  702. return true
  703. end
  704. teleportToWaitRoom(cid)
  705. return true
  706. end
  707.  
  708.  
  709.  
  710.  
  711. ]]> </movevent>
  712. </mod>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement