Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="UTF-8"?>
- <mod name="ArenyDlaAvisio" version="1.0" author="QuaS" contact="otland.net" enabled="yes">
- <config name="arenavisio"> <![CDATA[
- aconfig={
- friendlyfire = 17001,
- team = 17002,
- infight = 17003,
- arenaid = 17004,
- datadir= "data/",
- ext = ".arena"
- }
- ARENALIB = {}
- ARENALIB.setfight = function(cid,ff,team)
- setPlayerStorageValue(cid,aconfig.friendlyfire, ff==true and 1 or 0);
- setPlayerStorageValue(cid,aconfig.team, team);
- setPlayerStorageValue(cid,aconfig.infight, 1);
- end
- ARENALIB.endfight = function(cid)
- setPlayerStorageValue(cid,aconfig.infight, 0);
- end
- ARENALIB.infight = function(cid)
- return getPlayerStorageValue(cid,aconfig.infight)>0 and true or false;
- end
- function readFile(arena) --by Quas //Modified for arena script
- arena = aconfig.datadir .. arena .. aconfig.ext;
- local t = io.open(arena, "r");
- local a = {}
- while true do
- local i = t:read();
- if i==nil then break end;
- if(i ~= "") then
- i = string.explode(i, ' ')
- for _,th in pairs(i) do
- table.insert(a,tonumber(th));
- end
- end
- end
- t:close()
- return a;
- end
- function resetFile(arena)
- local file = aconfig.datadir .. arena .. aconfig.ext;
- local t = io.open(file,"w+")
- t:close()
- end
- function addToFile(arena, players)
- arena = aconfig.datadir .. arena .. aconfig.ext;
- local txt = "";
- if(type(players) == "table")then
- for _,player in pairs(players) do
- if(txt=="")then
- txt = txt.. player;
- else
- txt = txt .. " " .. player;
- end
- end
- else
- txt = players;
- end
- local t = io.open(arena,"a")
- t:write(txt);
- t:close()
- end
- endpos = {
- [1] = {pos = {x=870,y=765,z=7}, state=17001, co = {17011, 17021}}, -- Kopiujesz ENDPOS z danej areny i Current_state
- [2] = {pos = {x=870,y=762,z=7}, state=17002, co = {17012, 17022}}, -- Kopiujesz ENDPOS z danej areny i Current_state
- [3] = {pos = {x=826,y=765,z=7}, state=17003, co = {17013, 17023}}, -- Kopiujesz ENDPOS z danej areny i Current_state
- [4] = {pos = {x=826,y=765,z=7}, state=17004, co = {17014, 17024}}, -- Kopiujesz ENDPOS z danej areny i Current_state
- [5] = {pos = {x=846,y=722,z=7}, state=17005, co = {17015, 17025}}, -- Kopiujesz ENDPOS z danej areny i Current_state
- [6] = {pos = {x=851,y=722,z=7}, state=17006, co = {17016, 17026}}, -- Kopiujesz ENDPOS z danej areny i Current_state
- }
- ]]> </config>
- <action actionid = "17090" event = "script"><![CDATA[
- local conditions_set = {};
- local c;
- for i=1,11 do
- c = createConditionObject(CONDITION_ATTRIBUTES,-1,true,50)
- table.insert(conditions_set,i,c)
- end
- --Merciless Gladiator's Set--
- setConditionParam(conditions_set[1],CONDITION_PARAM_STAT_MAXHEALTHPERCENT, 100+1)
- setConditionParam(conditions_set[1],CONDITION_PARAM_STAT_MAXMANAPERCENT, 100+1)
- setConditionParam(conditions_set[1],CONDITION_PARAM_STAT_MAGICLEVELPERCENT, 100+3)
- setConditionParam(conditions_set[1],CONDITION_PARAM_STAT_FISTPERCENT, 100+4)
- setConditionParam(conditions_set[1],CONDITION_PARAM_STAT_CLUBPERCENT, 100+4)
- setConditionParam(conditions_set[1],CONDITION_PARAM_STAT_SWORDPERCENT, 100+4)
- setConditionParam(conditions_set[1],CONDITION_PARAM_STAT_AXEPERCENT, 100+4)
- setConditionParam(conditions_set[1],CONDITION_PARAM_STAT_DISTANCEPERCENT, 100+4)
- setConditionParam(conditions_set[1],CONDITION_PARAM_STAT_SHIELDPERCENT, 100+2)
- function onUse(cid,item)
- if(item.itemid == 1945)then
- doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You are taking bonus");
- doAddCondition(cid, conditions_set[1]);
- else
- doRemoveCondition(cid, CONDITION_ATTRIBUTES,50)
- end
- end
- ]]></action>
- <action fromaid="17001" toaid="17006" event="script"><![CDATA[
- domodlib("arenavisio")
- local gates =
- {
- [1] = { -- Arena 1v1 dollewo
- 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}},
- 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}},
- current_state= 17041; -- <0 closed.
- },
- [2] = { -- Arena 1v1 dolprawo
- 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}},
- 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}},
- current_state= 17042; -- closed.
- },
- [3] = { -- Arena 1v1 goralewo
- 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}},
- 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}},
- current_state= 17034; -- closed.
- },
- [4] = { -- Arena 1v1 goraprawo
- 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}},
- 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}},
- current_state= 17044; -- closed.
- },
- [5] = { -- Arena 2v2 dollewo
- 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}},
- 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}},
- current_state= 17045; -- closed.
- },
- [6] = { -- Arena 2v2 dolprawo
- 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}},
- 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}},
- current_state= 17046; -- closed.
- },
- [7] = { -- Arena 2v2 goralewo
- 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}},
- 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}},
- current_state= 17047; -- closed.
- },
- [8] = { -- Arena 2v2 goraprawo
- 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}},
- 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}},
- current_state= 17048; -- closed.
- },
- [9] = { -- Arena 3v3 lewogora
- 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}},
- 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}},
- current_state= 17049; -- closed.
- },
- [10] = { -- Arena 3v3 lewodol
- 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}},
- 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}},
- current_state= 17050; -- closed.
- },
- [11] = { -- Arena 3v3 prawogora
- 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}},
- 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}},
- current_state= 17051; -- closed.
- },
- [12] = { -- Arena 3v3 prawodol
- 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}},
- 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}},
- current_state= 17052; -- closed.
- }
- }
- local arenas = {
- [1] = { --Arena 1v1 ta na dole.
- current_state=17001, --globalStorage
- gates = {1,2},
- fighttime= 5*60,
- friendly_fire = false, -- only 2+vs2+
- positionstype="position", --position dla pojedynczych pozycji, range - dla zakresu
- enterpos = {[1] = {{x=869,y=766,z=7}}, [2] = {{x=871,y=766,z=7}}},
- needed_players=2,
- startpos = {team1 = {x=860,y=773,z=7}, team2 = {x=880,y=773,z=7}},
- endpos = {x=870,y=765,z=7}
- },
- [2] = { --Arena 1v1 ta na gorze.
- current_state=17002, --globalStorage
- gates = {3,4},
- fighttime= 5*60,
- friendly_fire = false, -- only 2+vs2+
- positionstype="position", --position dla pojedynczych pozycji, range - dla zakresu
- enterpos = {[1] = {{x=869,y=761,z=7}}, [2] = {{x=871,y=761,z=7}}},
- needed_players=2,
- startpos = {team1 = {x=860,y=754,z=7}, team2 = {x=880,y=754,z=7}},
- endpos = {x=870,y=762,z=7}
- },
- [3] = { --Arena 2v2 ta na dole.
- current_state=17003, --globalStorage
- gates = {5,6},
- fighttime= 5*60,
- friendly_fire = false, -- only 2+vs2+
- positionstype="position", --position dla pojedynczych pozycji, range - dla zakresu
- 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}}},
- needed_players=4,
- startpos = {team1 = {x=813,y=776,z=7}, team2 = {x=838,y=776,z=7}},
- endpos = {x=826,y=765,z=7}
- },
- [4] = { --Arena 2v2 ta na gorze.
- current_state=17004, --globalStorage
- gates = {7,8},
- fighttime= 5*60,
- friendly_fire = false, -- only 2+vs2+
- positionstype="position", --position dla pojedynczych pozycji, range - dla zakresu
- 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}}},
- needed_players=4,
- startpos = {team1 = {x=851,y=776,z=7}, team2 = {x=838,y=751,z=7}},
- endpos = {x=826,y=765,z=7}
- },
- [5] = { --Arena 3v3 ta po lewej.
- current_state=17005, --globalStorage
- gates = {9,10},
- fighttime= 5*60,
- friendly_fire = false, -- only 2+vs2+
- positionstype="position", --position dla pojedynczych pozycji, range - dla zakresu
- 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}}},
- needed_players=6,
- startpos = {team1 = {x=832,y=735,z=7}, team2 = {x=832,y=705,z=7}},
- endpos = {x=846,y=722,z=7}
- },
- [6] = { --Arena 3v3 ta po lewej.
- current_state=17006, --globalStorage
- gates = {11,12},
- fighttime= 5*60,
- friendly_fire = false, -- only 2+vs2+
- positionstype="position", --position dla pojedynczych pozycji, range - dla zakresu
- 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}}},
- needed_players=6,
- startpos = {team1 = {x=865,y=735,z=7}, team2 = {x=865,y=705,z=7}},
- endpos = {x=851,y=722,z=7}
- }
- }
- local lewary = {
- [17001] = 1,
- [17002] = 2,
- [17003] = 3,
- [17004] = 4,
- [17005] = 5,
- [17006] = 6,
- }
- function closeGate(id)
- local itm;
- local gg = gates[id];
- if(getStorage(gg.current_state) > 0) then
- for i = 1,#gg.open do
- itm = getTileItemById(gg.open[i][1],gg.open[i][2]).uid;
- if(itm>0)then
- doRemoveItem(itm);
- end
- itm = getTileItemById(gg.closed[i][1],gg.closed[i][2]).uid;
- if(itm < 1) then
- doCreateItem(gg.closed[i][2],1,gg.closed[i][1]);
- end
- end
- doSetStorage(gg.current_state,0);
- end
- end
- function openGate(id)
- local itm;
- local gg = gates[id];
- if(getStorage(gg.current_state) < 1) then
- for i = 1,#gg.closed do
- itm = getTileItemById(gg.closed[i][1],gg.closed[i][2]).uid;
- if(itm>0)then
- doRemoveItem(itm);
- end
- itm = getTileItemById(gg.open[i][1],gg.open[i][2]).uid;
- if(itm < 1) then
- doCreateItem(gg.open[i][2],1,gg.open[i][1]);
- end
- end
- doSetStorage(gg.current_state,1)
- end
- end
- function endFight(arenaid)
- if(getStorage(arenas[arenaid].current_state) < 1) then
- return 0;
- end
- local players = readFile(arenaid);
- for _,player in pairs(players) do
- if(isPlayer(player) and ARENALIB.infight(player) and getPlayerStorageValue(player,aconfig.arenaid) == arenaid)then
- doTeleportThing(player,arenas[arenaid].endpos);
- doSendMagicEffect(arenas[arenaid].endpos,10);
- ARENALIB.endfight(player);
- end
- end
- doSetStorage(arenas[arenaid].current_state,0)
- end
- function onUse(cid, item, fromPosition, itemEx, toPosition)
- if(item.itemid == 1946) then
- doTransformItem(item.uid,1945);
- return true;
- end
- if(not lewary[item.actionid]) then
- return false;
- end
- local arena = arenas[lewary[item.actionid]];
- if(getStorage(arena.current_state) > 0) then
- doPlayerSendCancel(cid, "You can't enter this Arena. Somebody has duel in there.")
- return true;
- end
- local players={{},{}};
- local tempvar=0;
- if(arena.positionstype == "position") then
- for i,teams in pairs(arena.enterpos) do
- for a,poz in pairs(teams) do
- tempvar=getTopCreature(poz).uid;
- if(isPlayer(tempvar))then
- table.insert(players[i],tempvar);
- end
- tempvar=0;
- end
- end
- else
- doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Error Occured: [Arena System] Unknown Position Type With Message : 0x"..lewary[item.actionid]..". Please Report It To Gamemaster.")
- return true;
- end
- local playercount=0;
- local pls={};
- for i,teams in pairs(players) do
- for _,playe in pairs(teams) do
- playercount=playercount+1;
- table.insert(pls,playe);
- end
- end
- if(playercount ~= arena.needed_players) then
- doPlayerSendCancel(cid, "You need ".. arena.needed_players .." to duel on this arena.")
- return true;
- end
- if(not isInArray(pls,cid)) then
- doPlayerSendCancel(cid, "Only the one which is going to fight can push a lever.")
- return true;
- end
- for _,gate in pairs(arena.gates) do
- closeGate(gate);
- addEvent(openGate,15000,gate);
- end
- for i,teams in pairs(players) do
- for _,player in pairs(teams) do
- top = i==1 and arena.startpos.team1 or arena.startpos.team2;
- ARENALIB.setfight(player,arena.friendly_fire,i);
- doSendMagicEffect(getCreaturePosition(player),2);
- doTeleportThing(player,top)
- doSendMagicEffect(top,2);
- setPlayerStorageValue(player,aconfig.arenaid,lewary[item.actionid]);
- doPlayerSendTextMessage(player, MESSAGE_STATUS_WARNING, "Prepare to fight!");
- end
- end
- for i=1,2 do
- setGlobalStorageValue(endpos[lewary[item.actionid]].co[i], arena.needed_players/2);
- end
- resetFile(lewary[item.actionid]);
- addToFile(lewary[item.actionid],pls);
- setGlobalStorageValue(arena.current_state,addEvent(endFight,arena.fighttime*1000,lewary[item.actionid]));
- doTransformItem(item.uid,1946);
- end
- ]]></action>
- <event type="login" name="avisioarena" event="script"><![CDATA[
- function onLogin(cid)
- domodlib("arenavisio")
- if(ARENALIB.infight(cid))then
- ARENALIB.endfight(cid)
- end
- registerCreatureEvent(cid, "avisioarenad")
- return true;
- end
- ]]></event>
- <event type="preparedeath" name="avisioarenad" event="script"><![CDATA[
- function onPrepareDeath(cid, deathList)
- domodlib("arenavisio")
- if(ARENALIB.infight(cid))then
- local arenaid = getPlayerStorageValue(cid,aconfig.arenaid);
- local team = getPlayerStorageValue(cid,aconfig.team);
- local teamc = getStorage(endpos[arenaid].co[team]);
- if(teamc-1 == 0) then
- local players = readFile(arenaid);
- for _,player in pairs(players) do
- if(ARENALIB.infight(player) and getPlayerStorageValue(player,aconfig.arenaid) == arenaid)then
- ARENALIB.endfight(player)
- doTeleportThing(player,endpos.pos)
- doSendMagicEffect(endpos.pos,10);
- end
- end
- --cos z wygranymi
- resetFile(arenaid);
- stopEvent(getStorage(endpos[arenaid].state))
- doSetStorage(endpos[arenaid].state,0);
- return true;
- else
- doSetStorage(endpos[arenaid].co[team], teamc-1);
- end
- ARENALIB.endfight(cid)
- end
- return true;
- end
- ]]></event>
- </mod>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement