Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.67 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <mod name="ArenyDlaAvisio" version="1.0" author="QuaS" contact="otland.net" enabled="yes">
  3. <config name="arenavisio"> <![CDATA[
  4. aconfig={
  5. friendlyfire = 17001,
  6. team = 17002,
  7. infight = 17003,
  8. arenaid = 17004,
  9. datadir= "data/",
  10. ext = ".arena"
  11. }
  12.  
  13. ARENALIB = {}
  14. ARENALIB.setfight = function(cid,ff,team)
  15. setPlayerStorageValue(cid,aconfig.friendlyfire, ff==true and 1 or 0);
  16. setPlayerStorageValue(cid,aconfig.team, team);
  17. setPlayerStorageValue(cid,aconfig.infight, 1);
  18. end
  19.  
  20. ARENALIB.endfight = function(cid)
  21. setPlayerStorageValue(cid,aconfig.infight, 0);
  22. end
  23. ARENALIB.infight = function(cid)
  24. return getPlayerStorageValue(cid,aconfig.infight)>0 and true or false;
  25. end
  26.  
  27. function readFile(arena) --by Quas //Modified for arena script
  28. arena = aconfig.datadir .. arena .. aconfig.ext;
  29. local t = io.open(arena, "r");
  30. local a = {}
  31. while true do
  32. local i = t:read();
  33. if i==nil then break end;
  34. if(i ~= "") then
  35. i = string.explode(i, ' ')
  36. for _,th in pairs(i) do
  37. table.insert(a,tonumber(th));
  38. end
  39. end
  40. end
  41. t:close()
  42. return a;
  43. end
  44.  
  45. function resetFile(arena)
  46. local file = aconfig.datadir .. arena .. aconfig.ext;
  47. local t = io.open(file,"w+")
  48. t:close()
  49. end
  50.  
  51. function addToFile(arena, players)
  52. arena = aconfig.datadir .. arena .. aconfig.ext;
  53. local txt = "";
  54. if(type(players) == "table")then
  55. for _,player in pairs(players) do
  56. if(txt=="")then
  57. txt = txt.. player;
  58. else
  59. txt = txt .. " " .. player;
  60. end
  61. end
  62. else
  63. txt = players;
  64. end
  65. local t = io.open(arena,"a")
  66. t:write(txt);
  67. t:close()
  68. end
  69.  
  70. endpos = {
  71. [1] = {pos = {x=870,y=765,z=7}, state=17001, co = {17011, 17021}}, -- Kopiujesz ENDPOS z danej areny i Current_state
  72. [2] = {pos = {x=870,y=762,z=7}, state=17002, co = {17012, 17022}}, -- Kopiujesz ENDPOS z danej areny i Current_state
  73. [3] = {pos = {x=826,y=765,z=7}, state=17003, co = {17013, 17023}}, -- Kopiujesz ENDPOS z danej areny i Current_state
  74. [4] = {pos = {x=826,y=765,z=7}, state=17004, co = {17014, 17024}}, -- Kopiujesz ENDPOS z danej areny i Current_state
  75. [5] = {pos = {x=846,y=722,z=7}, state=17005, co = {17015, 17025}}, -- Kopiujesz ENDPOS z danej areny i Current_state
  76. [6] = {pos = {x=851,y=722,z=7}, state=17006, co = {17016, 17026}}, -- Kopiujesz ENDPOS z danej areny i Current_state
  77.  
  78. }
  79.  
  80. ]]> </config>
  81. <action actionid = "17090" event = "script"><![CDATA[
  82. local conditions_set = {};
  83. local c;
  84. for i=1,11 do
  85. c = createConditionObject(CONDITION_ATTRIBUTES,-1,true,50)
  86. table.insert(conditions_set,i,c)
  87. end
  88.  
  89. --Merciless Gladiator's Set--
  90. setConditionParam(conditions_set[1],CONDITION_PARAM_STAT_MAXHEALTHPERCENT, 100+1)
  91. setConditionParam(conditions_set[1],CONDITION_PARAM_STAT_MAXMANAPERCENT, 100+1)
  92. setConditionParam(conditions_set[1],CONDITION_PARAM_STAT_MAGICLEVELPERCENT, 100+3)
  93. setConditionParam(conditions_set[1],CONDITION_PARAM_STAT_FISTPERCENT, 100+4)
  94. setConditionParam(conditions_set[1],CONDITION_PARAM_STAT_CLUBPERCENT, 100+4)
  95. setConditionParam(conditions_set[1],CONDITION_PARAM_STAT_SWORDPERCENT, 100+4)
  96. setConditionParam(conditions_set[1],CONDITION_PARAM_STAT_AXEPERCENT, 100+4)
  97. setConditionParam(conditions_set[1],CONDITION_PARAM_STAT_DISTANCEPERCENT, 100+4)
  98. setConditionParam(conditions_set[1],CONDITION_PARAM_STAT_SHIELDPERCENT, 100+2)
  99. function onUse(cid,item)
  100. if(item.itemid == 1945)then
  101. doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You are taking bonus");
  102. doAddCondition(cid, conditions_set[1]);
  103. else
  104. doRemoveCondition(cid, CONDITION_ATTRIBUTES,50)
  105. end
  106. end
  107. ]]></action>
  108. <action fromaid="17001" toaid="17006" event="script"><![CDATA[
  109. domodlib("arenavisio")
  110. local gates =
  111. {
  112. [1] = { -- Arena 1v1 dollewo
  113. closed = { {{x=861,y=775,z=7}, 12522},{{x=861,y=774,z=7}, 12522},{{x=861,y=773,z=7}, 12522},{{x=861,y=772,z=7}, 12522}},
  114. open = { {{x=862,y=775,z=7}, 12517},{{x=863,y=775,z=7}, 12517},{{x=863,y=771,z=7}, 12517},{{x=862,y=771,z=7}, 12517}},
  115. current_state= 17041; -- <0 closed.
  116. },
  117. [2] = { -- Arena 1v1 dolprawo
  118. closed = { {{x=879,y=775,z=7}, 12522},{{x=879,y=774,z=7}, 12522},{{x=879,y=773,z=7}, 12522},{{x=879,y=772,z=7}, 12522}},
  119. open = { {{x=879,y=775,z=7}, 12517},{{x=878,y=775,z=7}, 12517},{{x=878,y=771,z=7}, 12517},{{x=879,y=771,z=7}, 12517}},
  120. current_state= 17042; -- closed.
  121. },
  122. [3] = { -- Arena 1v1 goralewo
  123. closed = { {{x=861,y=753,z=7}, 12522},{{x=861,y=754,z=7}, 12522},{{x=861,y=755,z=7}, 12522},{{x=861,y=756,z=7}, 12522}},
  124. open = { {{x=862,y=752,z=7}, 12517},{{x=863,y=752,z=7}, 12517},{{x=863,y=756,z=7}, 12517},{{x=862,y=756,z=7}, 12517}},
  125. current_state= 17034; -- closed.
  126. },
  127. [4] = { -- Arena 1v1 goraprawo
  128. closed = { {{x=879,y=753,z=7}, 12522},{{x=879,y=754,z=7}, 12522},{{x=879,y=755,z=7}, 12522},{{x=879,y=756,z=7}, 12522}},
  129. open = { {{x=879,y=756,z=7}, 12517},{{x=878,y=756,z=7}, 12517},{{x=878,y=752,z=7}, 12517},{{x=879,y=752,z=7}, 12517}},
  130. current_state= 17044; -- closed.
  131. },
  132. [5] = { -- Arena 2v2 dollewo
  133. closed = { {{x=816,y=778,z=7}, 12522},{{x=816,y=777,z=7}, 12522},{{x=816,y=776,z=7}, 12522},{{x=816,y=775,z=7}, 12522}},
  134. open = { {{x=817,y=778,z=7}, 12517},{{x=818,y=778,z=7}, 12517},{{x=817,y=774,z=7}, 12517},{{x=818,y=774,z=7}, 12517}},
  135. current_state= 17045; -- closed.
  136. },
  137. [6] = { -- Arena 2v2 dolprawo
  138. closed = { {{x=835,y=778,z=7}, 12522},{{x=835,y=777,z=7}, 12522},{{x=835,y=776,z=7}, 12522},{{x=835,y=775,z=7}, 12522}},
  139. open = { {{x=835,y=778,z=7}, 12517},{{x=834,y=778,z=7}, 12517},{{x=835,y=774,z=7}, 12517},{{x=834,y=774,z=7}, 12517}},
  140. current_state= 17046; -- closed.
  141. },
  142. [7] = { -- Arena 2v2 goralewo
  143. closed = { {{x=816,y=753,z=7}, 12522},{{x=816,y=752,z=7}, 12522},{{x=816,y=751,z=7}, 12522},{{x=816,y=750,z=7}, 12522}},
  144. open = { {{x=817,y=753,z=7}, 12517},{{x=818,y=753,z=7}, 12517},{{x=817,y=749,z=7}, 12517},{{x=818,y=749,z=7}, 12517}},
  145. current_state= 17047; -- closed.
  146. },
  147. [8] = { -- Arena 2v2 goraprawo
  148. closed = { {{x=835,y=753,z=7}, 12522},{{x=835,y=752,z=7}, 12522},{{x=835,y=751,z=7}, 12522},{{x=835,y=750,z=7}, 12522}},
  149. open = { {{x=835,y=753,z=7}, 12517},{{x=834,y=753,z=7}, 12517},{{x=835,y=749,z=7}, 12517},{{x=834,y=749,z=7}, 12517}},
  150. current_state= 17048; -- closed.
  151. },
  152. [9] = { -- Arena 3v3 lewogora
  153. closed = { {{x=831,y=708,z=7}, 12522},{{x=832,y=708,z=7}, 12522},{{x=833,y=708,z=7}, 12522},{{x=834,y=708,z=7}, 12522}},
  154. open = { {{x=830,y=709,z=7}, 12517},{{x=830,y=710,z=7}, 12517},{{x=834,y=709,z=7}, 12517},{{x=834,y=710,z=7}, 12517}},
  155. current_state= 17049; -- closed.
  156. },
  157. [10] = { -- Arena 3v3 lewodol
  158. closed = { {{x=831,y=732,z=7}, 12522},{{x=832,y=732,z=7}, 12522},{{x=833,y=732,z=7}, 12522},{{x=834,y=732,z=7}, 12522}},
  159. open = { {{x=830,y=732,z=7}, 12517},{{x=830,y=731,z=7}, 12517},{{x=834,y=732,z=7}, 12517},{{x=834,y=731,z=7}, 12517}},
  160. current_state= 17050; -- closed.
  161. },
  162. [11] = { -- Arena 3v3 prawogora
  163. closed = { {{x=864,y=708,z=7}, 12522},{{x=865,y=708,z=7}, 12522},{{x=866,y=708,z=7}, 12522},{{x=867,y=708,z=7}, 12522}},
  164. open = { {{x=863,y=709,z=7}, 12517},{{x=863,y=710,z=7}, 12517},{{x=867,y=709,z=7}, 12517},{{x=867,y=710,z=7}, 12517}},
  165. current_state= 17051; -- closed.
  166. },
  167. [12] = { -- Arena 3v3 prawodol
  168. closed = { {{x=831,y=732,z=7}, 12522},{{x=832,y=732,z=7}, 12522},{{x=833,y=732,z=7}, 12522},{{x=834,y=732,z=7}, 12522}},
  169. open = { {{x=863,y=732,z=7}, 12517},{{x=863,y=731,z=7}, 12517},{{x=867,y=732,z=7}, 12517},{{x=867,y=731,z=7}, 12517}},
  170. current_state= 17052; -- closed.
  171. }
  172. }
  173. local arenas = {
  174. [1] = { --Arena 1v1 ta na dole.
  175. current_state=17001, --globalStorage
  176. gates = {1,2},
  177. fighttime= 5*60,
  178. friendly_fire = false, -- only 2+vs2+
  179. positionstype="position", --position dla pojedynczych pozycji, range - dla zakresu
  180. enterpos = {[1] = {{x=869,y=766,z=7}}, [2] = {{x=871,y=766,z=7}}},
  181. needed_players=2,
  182. startpos = {team1 = {x=860,y=773,z=7}, team2 = {x=880,y=773,z=7}},
  183. endpos = {x=870,y=765,z=7}
  184. },
  185.  
  186. [2] = { --Arena 1v1 ta na gorze.
  187. current_state=17002, --globalStorage
  188. gates = {3,4},
  189. fighttime= 5*60,
  190. friendly_fire = false, -- only 2+vs2+
  191. positionstype="position", --position dla pojedynczych pozycji, range - dla zakresu
  192. enterpos = {[1] = {{x=869,y=761,z=7}}, [2] = {{x=871,y=761,z=7}}},
  193. needed_players=2,
  194. startpos = {team1 = {x=860,y=754,z=7}, team2 = {x=880,y=754,z=7}},
  195. endpos = {x=870,y=762,z=7}
  196. },
  197.  
  198. [3] = { --Arena 2v2 ta na dole.
  199. current_state=17003, --globalStorage
  200. gates = {5,6},
  201. fighttime= 5*60,
  202. friendly_fire = false, -- only 2+vs2+
  203. positionstype="position", --position dla pojedynczych pozycji, range - dla zakresu
  204. enterpos = {[1] = {{x=824,y=766,z=7}, {x=825,y=766,z=7}}, [2] = {{x=827,y=766,z=7}, {x=828,y=766,z=7}}},
  205. needed_players=4,
  206. startpos = {team1 = {x=813,y=776,z=7}, team2 = {x=838,y=776,z=7}},
  207. endpos = {x=826,y=765,z=7}
  208. },
  209.  
  210. [4] = { --Arena 2v2 ta na gorze.
  211. current_state=17004, --globalStorage
  212. gates = {7,8},
  213. fighttime= 5*60,
  214. friendly_fire = false, -- only 2+vs2+
  215. positionstype="position", --position dla pojedynczych pozycji, range - dla zakresu
  216. enterpos = {[1] = {{x=824,y=761,z=7}, {x=825,y=761,z=7}}, [2] = {{x=827,y=761,z=7}, {x=828,y=761,z=7}}},
  217. needed_players=4,
  218. startpos = {team1 = {x=851,y=776,z=7}, team2 = {x=838,y=751,z=7}},
  219. endpos = {x=826,y=765,z=7}
  220. },
  221.  
  222. [5] = { --Arena 3v3 ta po lewej.
  223. current_state=17005, --globalStorage
  224. gates = {9,10},
  225. fighttime= 5*60,
  226. friendly_fire = false, -- only 2+vs2+
  227. positionstype="position", --position dla pojedynczych pozycji, range - dla zakresu
  228. enterpos = {[1] = {{x=845,y=725,z=7}, {x=845,y=724,z=7}, {x=845,y=723,z=7}}, [2] = {{x=845,y=721,z=7}, {x=845,y=720,z=7}, {x=845,y=719,z=7}}},
  229. needed_players=6,
  230. startpos = {team1 = {x=832,y=735,z=7}, team2 = {x=832,y=705,z=7}},
  231. endpos = {x=846,y=722,z=7}
  232. },
  233.  
  234. [6] = { --Arena 3v3 ta po lewej.
  235. current_state=17006, --globalStorage
  236. gates = {11,12},
  237. fighttime= 5*60,
  238. friendly_fire = false, -- only 2+vs2+
  239. positionstype="position", --position dla pojedynczych pozycji, range - dla zakresu
  240. enterpos = {[1] = {{x=852,y=725,z=7}, {x=852,y=724,z=7}, {x=852,y=723,z=7}}, [2] = {{x=852,y=721,z=7}, {x=852,y=720,z=7}, {x=852,y=719,z=7}}},
  241. needed_players=6,
  242. startpos = {team1 = {x=865,y=735,z=7}, team2 = {x=865,y=705,z=7}},
  243. endpos = {x=851,y=722,z=7}
  244. }
  245. }
  246.  
  247. local lewary = {
  248. [17001] = 1,
  249. [17002] = 2,
  250. [17003] = 3,
  251. [17004] = 4,
  252. [17005] = 5,
  253. [17006] = 6,
  254. }
  255.  
  256.  
  257.  
  258. function closeGate(id)
  259. local itm;
  260. local gg = gates[id];
  261. if(getStorage(gg.current_state) > 0) then
  262. for i = 1,#gg.open do
  263. itm = getTileItemById(gg.open[i][1],gg.open[i][2]).uid;
  264. if(itm>0)then
  265. doRemoveItem(itm);
  266. end
  267. itm = getTileItemById(gg.closed[i][1],gg.closed[i][2]).uid;
  268. if(itm < 1) then
  269. doCreateItem(gg.closed[i][2],1,gg.closed[i][1]);
  270. end
  271. end
  272. doSetStorage(gg.current_state,0);
  273. end
  274. end
  275.  
  276. function openGate(id)
  277. local itm;
  278. local gg = gates[id];
  279. if(getStorage(gg.current_state) < 1) then
  280. for i = 1,#gg.closed do
  281. itm = getTileItemById(gg.closed[i][1],gg.closed[i][2]).uid;
  282. if(itm>0)then
  283. doRemoveItem(itm);
  284. end
  285. itm = getTileItemById(gg.open[i][1],gg.open[i][2]).uid;
  286. if(itm < 1) then
  287. doCreateItem(gg.open[i][2],1,gg.open[i][1]);
  288. end
  289. end
  290. doSetStorage(gg.current_state,1)
  291. end
  292. end
  293.  
  294. function endFight(arenaid)
  295. if(getStorage(arenas[arenaid].current_state) < 1) then
  296. return 0;
  297. end
  298. local players = readFile(arenaid);
  299. for _,player in pairs(players) do
  300. if(isPlayer(player) and ARENALIB.infight(player) and getPlayerStorageValue(player,aconfig.arenaid) == arenaid)then
  301.  
  302. doTeleportThing(player,arenas[arenaid].endpos);
  303. doSendMagicEffect(arenas[arenaid].endpos,10);
  304. ARENALIB.endfight(player);
  305. end
  306. end
  307. doSetStorage(arenas[arenaid].current_state,0)
  308. end
  309.  
  310.  
  311. function onUse(cid, item, fromPosition, itemEx, toPosition)
  312. if(item.itemid == 1946) then
  313. doTransformItem(item.uid,1945);
  314. return true;
  315. end
  316.  
  317. if(not lewary[item.actionid]) then
  318. return false;
  319. end
  320. local arena = arenas[lewary[item.actionid]];
  321. if(getStorage(arena.current_state) > 0) then
  322. doPlayerSendCancel(cid, "You can't enter this Arena. Somebody has duel in there.")
  323. return true;
  324. end
  325. local players={{},{}};
  326. local tempvar=0;
  327. if(arena.positionstype == "position") then
  328. for i,teams in pairs(arena.enterpos) do
  329. for a,poz in pairs(teams) do
  330. tempvar=getTopCreature(poz).uid;
  331. if(isPlayer(tempvar))then
  332. table.insert(players[i],tempvar);
  333. end
  334. tempvar=0;
  335. end
  336. end
  337. else
  338. doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Error Occured: [Arena System] Unknown Position Type With Message : 0x"..lewary[item.actionid]..". Please Report It To Gamemaster.")
  339. return true;
  340. end
  341. local playercount=0;
  342. local pls={};
  343. for i,teams in pairs(players) do
  344. for _,playe in pairs(teams) do
  345. playercount=playercount+1;
  346. table.insert(pls,playe);
  347. end
  348. end
  349. if(playercount ~= arena.needed_players) then
  350. doPlayerSendCancel(cid, "You need ".. arena.needed_players .." to duel on this arena.")
  351. return true;
  352. end
  353. if(not isInArray(pls,cid)) then
  354. doPlayerSendCancel(cid, "Only the one which is going to fight can push a lever.")
  355. return true;
  356. end
  357.  
  358.  
  359. for _,gate in pairs(arena.gates) do
  360. closeGate(gate);
  361. addEvent(openGate,15000,gate);
  362. end
  363. for i,teams in pairs(players) do
  364. for _,player in pairs(teams) do
  365. top = i==1 and arena.startpos.team1 or arena.startpos.team2;
  366. ARENALIB.setfight(player,arena.friendly_fire,i);
  367. doSendMagicEffect(getCreaturePosition(player),2);
  368. doTeleportThing(player,top)
  369. doSendMagicEffect(top,2);
  370. setPlayerStorageValue(player,aconfig.arenaid,lewary[item.actionid]);
  371. doPlayerSendTextMessage(player, MESSAGE_STATUS_WARNING, "Prepare to fight!");
  372. end
  373. end
  374. for i=1,2 do
  375. setGlobalStorageValue(endpos[lewary[item.actionid]].co[i], arena.needed_players/2);
  376. end
  377. resetFile(lewary[item.actionid]);
  378. addToFile(lewary[item.actionid],pls);
  379. setGlobalStorageValue(arena.current_state,addEvent(endFight,arena.fighttime*1000,lewary[item.actionid]));
  380. doTransformItem(item.uid,1946);
  381. end
  382. ]]></action>
  383. <event type="login" name="avisioarena" event="script"><![CDATA[
  384. function onLogin(cid)
  385. domodlib("arenavisio")
  386. if(ARENALIB.infight(cid))then
  387. ARENALIB.endfight(cid)
  388. end
  389. registerCreatureEvent(cid, "avisioarenad")
  390. return true;
  391. end
  392. ]]></event>
  393. <event type="preparedeath" name="avisioarenad" event="script"><![CDATA[
  394. function onPrepareDeath(cid, deathList)
  395. domodlib("arenavisio")
  396. if(ARENALIB.infight(cid))then
  397. local arenaid = getPlayerStorageValue(cid,aconfig.arenaid);
  398. local team = getPlayerStorageValue(cid,aconfig.team);
  399. local teamc = getStorage(endpos[arenaid].co[team]);
  400. if(teamc-1 == 0) then
  401. local players = readFile(arenaid);
  402. for _,player in pairs(players) do
  403. if(ARENALIB.infight(player) and getPlayerStorageValue(player,aconfig.arenaid) == arenaid)then
  404. ARENALIB.endfight(player)
  405. doTeleportThing(player,endpos.pos)
  406. doSendMagicEffect(endpos.pos,10);
  407.  
  408. end
  409. end
  410. --cos z wygranymi
  411. resetFile(arenaid);
  412. stopEvent(getStorage(endpos[arenaid].state))
  413. doSetStorage(endpos[arenaid].state,0);
  414. return true;
  415. else
  416. doSetStorage(endpos[arenaid].co[team], teamc-1);
  417. end
  418. ARENALIB.endfight(cid)
  419. end
  420. return true;
  421. end
  422. ]]></event>
  423. </mod>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement