Main Code Bedwar
Main Code Bedwar
cancel=false
lvlist="datalist_1684823720"
bxh="rank_1684857774"
topkill="rank_1685010377"
wintop="rank_1685010349"
up_time=os.time()
load_speed=os.time()
antiafk_time=os.time()
xp_time=os.time()+120
rst=os.time()+5
button={[[7209287037543967807_15]],[[7209287037543967807_16]],[[7209287037543967807_17]],
[[7209287037543967807_18]],[[7209287037543967807_19]]}
home_pos={{x=88,y=49,z=8},{x=8,y=49,z=86},{x=-72,y=49,z=8},{x=9,y=49,z=-70}}
red_bed,blue_bed,green_bed,yellow_bed=2001,2002,2003,2004
bed_gone={false,false,false,false}
top={{x=9,y=112,z=19},{x=9,y=111,z=19},{x=9,y=110,z=19},{x=9,y=109,z=19},{x=9,y=108,z=19},
{x=9,y=107,z=19},{x=9,y=106,z=19},{x=9,y=105,z=19},{x=9,y=104,z=19},{x=9,y=103,z=19}}
is_start=false
plteam_list={}
forbidden_list={12964,845,846,1055,1056}
fb_sl=5
plteam_count=0
tower_load={}
tower_amount=0
change_amount=14
_tong_so=0
change={[[10099]],[[10333]],[[10337]],[[10342]],[[10350]],[[10343]],[[10348]],[[10545]],[[10546]],
[[10547]],[[10548]],[[10549]],[[10550]],[[10339]]}
change_time=os.time()+60
give_list={11203,11204,11207,11209}
upblist={2012,2009,2010,2011,2015,2014,2013}
uptlist={{sword=false,def=false,deflv=0,mfastlv=0,mf=false,mfast=false,fur=false,furlv=0,hp=false,blind=f
alse},
{sword=false,def=false,deflv=0,mf=false,mfastlv=0,mfast=false,fur=false,furlv=0,hp=false,blind=false},
{sword=false,def=false,deflv=0,mf=false,mfastlv=0,mfast=false,fur=false,furlv=0,hp=false,blind=false},
{sword=false,def=false,deflv=0,mf=false,mfastlv=0,mfast=false,fur=false,furlv=0,hp=false,blind=false}}
wool_list={614,611,613,604}
glass_list={647,644,646,637}
sandbl_list={681,678,680,671}
here=os.time()
tspir=os.time()+10
tspg=os.time()+10
tspe=os.time()+60
tspdi=os.time()+30
diarl_time=30
erl_time=60
leg_id=12203
boot_id=12204
hspawnir_pos={{x=115,y=48,z=8},{x=8,y=48,z=113},{x=-99,y=48,z=8},{x=9,y=48,z=-97}}
hspawng_pos={{x=115,y=48,z=8},{x=8,y=48,z=113},{x=-99,y=48,z=8},{x=9,y=48,z=-97}}
espawn_pos={{x=9,y=63,z=8},{x=9,y=48,z=8}}
dspawn_pos={{x=73,y=52,z=77},{x=-59,y=52,z=74},{x=-59,y=52,z=-62},{x=77,y=52,z=-57}}
tghienthi=os.time()+1
thongtin=Graphics:makeGraphicsText("",12,1,1)
slhs=4
slhg=4
sld=4
sle=2
team_area={}
___,team_area[1]=Area:createAreaRectByRange({x=83,y=45,z=-9},{x=120,y=66,z=65})
___,team_area[2]=Area:createAreaRectByRange({x=25,y=43,z=77},{x=-11,y=64,z=118})
___,team_area[3]=Area:createAreaRectByRange({x=-61,y=41,z=25},{x=-101,y=65,z=-12})
___,team_area[4]=Area:createAreaRectByRange({x=-7,y=41,z=-65},{x=32,y=68,z=-100})
___,start_area=Area:createAreaRectByRange({x=38,y=115,z=37},{x=-21,y=101,z=-21})
pl={}
sl=0
id_ender_pearl=4100
sponid=2018
function findb(A,n,gt)
for i=1,n do
if A[i].id==gt then
return i
end
end
return -1
end
function splitid(s)
local x=string.find(s,".xp")
return string.sub(s,1,x-1)
end
function splitid2(s)
local x=string.find(s,".win")
return string.sub(s,1,x-1)
end
function is_forbidden(id)
for i=1,fb_sl do
if forbidden_list[i]==id then
return true
end
end
return false
end
function addwin(__,k,v)
local id=splitid2(k)
if type(v)=="nil" then
CloudSever:setOrderDataBykey(wintop,id,1)
CloudSever:setDataListBykey(lvlist,k,1)
else
CloudSever:setOrderDataBykey(wintop,id,v+1)
CloudSever:setDataListBykey(lvlist,k,v+1)
end
end
function addkill(__,k,v)
if type(v)=="nil" then
CloudSever:setOrderDataBykey(topkill,k,0)
else
CloudSever:setOrderDataBykey(topkill,k,v+1)
end
end
function get_color(level)
if level<10 then
return "#W"
return "#B"
return "#G"
elseif level<50 then
return "#Y"
return "#R"
return "#K"
return "#b#R"
end
end
function get_gradientcl(cs)
if cs==1 then
return "#K"
return "#R"
return "#Y"
return "#G"
return "#B"
else
return "#b"
end
end
function test(__,k,v,ix)
local pldata
if ix<4 then
else
end
Graphics:createGraphicsTxtByPos(top[ix].x,top[ix].y,top[ix].z,pldata)
end
function ss(a,b)
if a.lv<b.lv then
return true
return a.xp<b.xp
else
return false
end
end
function QS(A,l,h)
local i,j,mid=l,h,A[math.floor((l+h)/2)]
if i<=j then
local x=A[i]
A[i]=A[j]
A[j]=x
i=i+1
j=j-1
end
while i<=j do
if i<=j then
local x=A[i]
A[i]=A[j]
A[j]=x
i=i+1
j=j-1
end
end
end
function intop(__,k,v,ix)
print(here)
print(k.." "..v)
end
function taosl(__,k,v)
if type(v)=="nil" then
CloudSever:setDataListBykey(lvlist,"sl",0)
else
_tong_so=v
--for i=1,10 do
-- CloudSever:getOrderDataIndexValue(bxh,i,test)
--end
end
end
CloudSever:getDataListByKey(lvlist,"sl",taosl)
function reset()
back_pl={}
back_sl=0
button={[[7209287037543967807_15]],[[7209287037543967807_16]],[[7209287037543967807_17]],
[[7209287037543967807_18]],[[7209287037543967807_19]]}
red_bed,blue_bed,green_bed,yellow_bed=2001,2002,2003,2004
bed_gone={false,false,false,false}
is_start=false
plteam_list={}
plteam_count=0
give_list={11203,11204,11207,11209}
upblist={2012,2009,2010,2011,2015,2014,2013}
uptlist={{sword=false,def=false,deflv=0,mfastlv=0,mf=false,mfast=false,fur=false,furlv=0,hp=false,blind=f
alse},
{sword=false,def=false,deflv=0,mf=false,mfastlv=0,mfast=false,fur=false,furlv=0,hp=false,blind=false},
{sword=false,def=false,deflv=0,mf=false,mfastlv=0,mfast=false,fur=false,furlv=0,hp=false,blind=false},
{sword=false,def=false,deflv=0,mf=false,mfastlv=0,mfast=false,fur=false,furlv=0,hp=false,blind=false}}
wool_list={614,611,613,604}
glass_list={647,644,646,637}
sandbl_list={681,678,680,671}
here=os.time()
tspir=os.time()+1
tspg=os.time()+4
tspe=os.time()+60
tspdi=os.time()+30
diarl_time=30
erl_time=60
leg_id=12203
boot_id=12204
hspawnir_pos={{x=115,y=48,z=8},{x=8,y=48,z=113},{x=-99,y=48,z=8},{x=9,y=48,z=-97}}
hspawng_pos={{x=115,y=48,z=8},{x=8,y=48,z=113},{x=-99,y=48,z=8},{x=9,y=48,z=-97}}
espawn_pos={{x=9,y=63,z=8},{x=9,y=48,z=8}}
dspawn_pos={{x=73,y=52,z=77},{x=-59,y=52,z=74},{x=-59,y=52,z=-62},{x=77,y=52,z=-57}}
tghienthi=os.time()+1
thongtin=Graphics:makeGraphicsText("",12,1,1)
slhs=4
slhg=4
sld=4
sle=2
pl={}
sl=0
id_ender_pearl=4100
sponid=2018
Block:setBlockSettingAttState(891, 1, false)
end
function app(e)
if e.itemid==id_ender_pearl then
sl=sl+1
pl[sl]={}
pl[sl].vn=e.toobjid
pl[sl].pl=e.eventobjid
end
end
function PQ(e)
if e.itemid==id_ender_pearl then
i=1
while i<=sl do
if pl[i].vn==e.eventobjid then
pl[sl+1]={}
for j=i,sl do
pl[j]=pl[j+1]
end
sl=sl-1
end
i=i+1
end
end
end
function isinlist(itemid)
for i=1,4 do
if itemid==give_list[i] then
return true
end
end
return false
end
function kt(array)
local dem=0
for i=1,4 do
end
end
if dem==3 then
for i=1,4 do
end
end
else
return -1
end
end
function get_limit_xp(level)
if level<10 then
return 400+level*100
return 900+level*100
return 3900+level*100
return 6900+level*200
return 9900+level*500
return 15900+level*2000
else
return 30000+level*3000
end
end
function up_level(level,xp)
return xp>=get_limit_xp(level+1)
end
function get_data(s)
local __,arr=CloudSever:getlistCache(lvlist)
for i=1,_tong_so+1 do
if s==arr[i].k then
return arr[i].v
end
end
return -1
end
function updatexp(__,k,v)
local r=math.random(300,450)
local id=splitid(k)
CloudSever:setDataListBykey(lvlist,k,v+r)
local dat=get_data(id)
local lm=get_limit_xp(dat.lv+1)
Chat:sendSystemMsg("#G+"..r.."XP!#Y("..dat.xp.."/"..lm..")",tonumber(id))
if up_level(dat.lv,dat.xp) then
CloudSever:setDataListBykey(lvlist,id..".lv",dat.lv+1)
CloudSever:setOrderDataBykey(bxh,id,dat.lv)
CloudSever:setDataListBykey(lvlist,id..".xp",dat.xp-lm)
end
end
function updatexp2(__,k,v)
local r=math.random(10,100)
local id=splitid(k)
CloudSever:setDataListBykey(lvlist,k,v+r)
local dat=get_data(id)
local lm=get_limit_xp(dat.lv+1)
Chat:sendSystemMsg("#G+"..r.."XP!#Y("..dat.xp.."/"..lm..")",tonumber(id))
if up_level(dat.lv,dat.xp) then
CloudSever:setDataListBykey(lvlist,id..".lv",dat.lv+1)
CloudSever:setOrderDataBykey(bxh,id,dat.lv)
CloudSever:setDataListBykey(lvlist,id..".xp",dat.xp-lm)
end
end
function updatexp3(__,k,v)
local r=10
local id=splitid(k)
CloudSever:setDataListBykey(lvlist,k,v+r)
local dat=get_data(id)
local lm=get_limit_xp(dat.lv+1)
Chat:sendSystemMsg("#G+"..r.."XP!#Y("..dat.xp.."/"..lm..")[Sống sót]",tonumber(id))
if up_level(dat.lv,dat.xp) then
CloudSever:setDataListBykey(lvlist,id..".lv",dat.lv+1)
CloudSever:setOrderDataBykey(bxh,id,dat.lv)
CloudSever:setDataListBykey(lvlist,id..".xp",dat.xp-lm)
end
end
function win()
if os.time()>=load_speed then
local __,num,arr=World:getAllPlayers(-1)
for i=1,num do
Player:setAttr(arr[i],10,10)
Player:setAttr(arr[i],11,12)
end
load_speed=os.time()+1
end
if os.time()>=antiafk_time then
local __,num,arr=World:getAllPlayers(-1)
for i=1,antiafk_sl do
if antiafk_pl[i].is_stand then
if os.time()>=antiafk_pl[i].sttime then
antiafk_pl[i].isafk=true
local __,name=Player:getNickname(antiafk_pl[i].id)
for j=1,num do
end
Player:setActionAttrState(antiafk_pl[i].id,256, false)
end
end
end
end
antiafk_time=os.time()+1
end
if os.time()>=rst then
CloudSever:getDataListByKey(lvlist,"sl",taosl)
rst=os.time()+3
end
if started then
if os.time()>=xp_time then
local __,num,arr=World:getAllPlayers(-1)
for i=1,num do
local __,team=Player:getTeam(arr[i])
if team~=5 then
CloudSever:getDataListByKey(lvlist,tostring(arr[i])..".xp",updatexp3)
end
end
xp_time=os.time()+120
end
if os.time()>=change_time then
local vt=math.random(change_amount)
local __,num,arr=World:getAllPlayers(-1)
for i=1,num do
DisPlayBoard:setBoardPicture(arr[i],40000001,change[vt])
end
change_time=os.time()+60
end
if os.time()>=here then
local __,amount,players=World:getAllPlayers(-1)
if amount<=0 then
Team:setTeamPlayersResults(0, 1)
Game:doGameEnd(nil)
end
local arr={0,0,0,0}
for i=1,4 do
arr[i]=x
end
local vt=kt(arr)
if vt~=-1 then
local all_gone=true
for i=1,4 do
if i~=vt then
all_gone=false
break
end
end
end
if all_gone then
local __,num,arr=Team:getTeamPlayers(vt,2)
for i=1,num do
CloudSever:getDataListByKey(lvlist,tostring(arr[i])..".xp",updatexp)
--CloudSever:getDataListByKey(lvlist,tostring(arr[i])..".win",addwin)
end
Team:setTeamResults(vt,1)
here=os.time()+100
Game:doGameEnd(nil)
return
end
end
here=os.time()+3
end
if os.time()>=tspir then
for i=1,slhs do
local x,y,z=hspawnir_pos[i].x,hspawnir_pos[i].y,hspawnir_pos[i].z
local iron=0
for j=1,num do
local __,iteid=Item:getItemId(objids[j])
if iteid==11209 then
local __,slroi=Item:getDropItemNum(objids[j])
iron=iron+slroi
end
end
if iron<128 then
local __,n,a=World:getActorsByBox(1,x+3,y+3,z+3,x-3,y-3,z-3)
World:spawnItem(x,y, z, 11209, n)
end
end
tspir=os.time()+1
end
if os.time()>=tspg then
for i=1,slhg do
local x,y,z=hspawng_pos[i].x,hspawng_pos[i].y,hspawng_pos[i].z
local gold=0
for j=1,num do
local __,iteid=Item:getItemId(objids[j])
if iteid==11207 then
local __,slroi=Item:getDropItemNum(objids[j])
gold=gold+slroi
end
end
if gold<24 then
local __,n,a=World:getActorsByBox(1,x+3,y+3,z+3,x-3,y-3,z-3)
end
end
tspg=os.time()+4
end
if os.time()>=tspdi then
for i=1,sld do
local x,y,z=dspawn_pos[i].x,dspawn_pos[i].y,dspawn_pos[i].z
local dia=0
for j=1,num do
local __,iteid=Item:getItemId(objids[j])
if iteid==11203 then
local __,slroi=Item:getDropItemNum(objids[j])
dia=dia+slroi
end
end
if dia<4 then
World:spawnItem(x,y,z, 11203, 1)
end
end
tspdi=os.time()+diarl_time
end
if os.time()>=tspe then
for i=1,sle do
local x,y,z=espawn_pos[i].x,espawn_pos[i].y,espawn_pos[i].z
local co=false
for i=1,4 do
co=true
break
end
end
if co then
World:spawnItem(x,y,z, 11204, 1)
else
local __,num,objids=World:getActorsByBox(3, x+3, y+3, z+3, x-3, y-3, z-3)
local emer=0
for j=1,num do
local __,iteid=Item:getItemId(objids[j])
if iteid==11204 then
local __,slroi=Item:getDropItemNum(objids[j])
emer=emer+slroi
end
end
if emer<4 then
World:spawnItem(x,y,z, 11204, 1)
end
end
end
tspe=os.time()+erl_time
end
if os.time()>=tghienthi then
for i=1,4 do
local x,y,z=dspawn_pos[i].x,dspawn_pos[i].y+4,dspawn_pos[i].z
Graphics:createGraphicsTxtByPos(x,y,z,thongtin)
end
for i=1,2 do
local x,y,z=espawn_pos[i].x,espawn_pos[i].y+4,espawn_pos[i].z
Graphics:createGraphicsTxtByPos(x,y,z,thongtin)
end
tghienthi=os.time()+1
end
if os.time()>=up_time then
luot=2
local __,apn,aplayer=World:getAllPlayers(-1)
for i=1,apn do
end
local __,la,player_e=World:getAllPlayers(-1)
MiniTimer:startBackwardTimer(tmid,360,false)
erl_time=30
luot=3
local __,apn,aplayer=World:getAllPlayers(-1)
for i=1,apn do
end
local __,la,player_e=World:getAllPlayers(-1)
MiniTimer:deleteTimer(tmid)
___,tmid=MiniTimer:createTimer("test",nil,true)
MiniTimer:startBackwardTimer(tmid,360,false)
for i=1,4 do
sld=sld+1
dspawn_pos[sld]=dspawn_pos[i]
end
luot=4
local __,apn,aplayer=World:getAllPlayers(-1)
for i=1,apn do
end
local __,la,player_e=World:getAllPlayers(-1)
MiniTimer:deleteTimer(tmid)
___,tmid=MiniTimer:createTimer("test",nil,true)
MiniTimer:startBackwardTimer(tmid,360,false)
for i=1,2 do
sle=sle+1
espawn_pos[sle]=espawn_pos[i]
end
luot=5
local __,apn,aplayer=World:getAllPlayers(-1)
for i=1,apn do
end
local __,la,player_e=World:getAllPlayers(-1)
MiniTimer:deleteTimer(tmid)
___,tmid=MiniTimer:createTimer("test",nil,true)
MiniTimer:startBackwardTimer(tmid,360,false)
local __,amount,arr=World:getAllPlayers(-1)
for i=1,amount do
Customui:setTexture(arr[i],[[7217067675743349823]],[[7217067675743349823_18]],[[10024]])
Customui:setTexture(arr[i],[[7217067675743349823]],[[7217067675743349823_19]],[[10024]])
Customui:setTexture(arr[i],[[7217067675743349823]],[[7217067675743349823_20]],[[10024]])
Customui:setTexture(arr[i],[[7217067675743349823]],[[7217067675743349823_21]],[[10024]])
end
for i=1,4 do
bed_gone[i]=true
end
___,dragon=World:spawnCreature(9,68,8,3504,1)
Creature:setAttr(dragon[1],13,1000)
Creature:setAttr(dragon[1],16,10)
luot=6
local __,apn,aplayer=World:getAllPlayers(-1)
for i=1,apn do
end
Block:destroyBlock(8,49,86,false)
Block:destroyBlock(8,49,87,false)
Block:destroyBlock(89,49,8,false)
Block:destroyBlock(88,49,8,false)
Block:destroyBlock(9,49,-70,false)
Block:destroyBlock(9,49,-71,false)
Block:destroyBlock(-72,49,8,false)
Block:destroyBlock(-73,49,8,false)
MiniTimer:deleteTimer(tmid)
___,tmid=MiniTimer:createTimer("test",nil,true)
end
up_time=os.time()+360
end
if back_sl>0 then
local i=1
while i<=back_sl do
if os.time()>back_pl[i].time then
Backpack:removeGridItemByItemID(back_pl[i].id, 4115, 2)
Backpack:addItem(back_pl[i].id, 4114, 1)
for j=i,back_sl do
back_pl[j]=back_pl[j+1]
end
back_sl=back_sl-1
end
i=i+1
end
end
if tower_amount>0 then
local i=1
while i<=tower_amount do
if tower_load[i].load_t<=os.time() then
if tower_load[i].tang==2 then
tang2(tower_load[i].x,tower_load[i].y+1,tower_load[i].z,tower_load[i].c)
local __=Block:isAirBlock(tower_load[i].x-1,tower_load[i].y+2,tower_load[i].z+1)
if __==0 then
Block:placeBlock(813,tower_load[i].x-1,tower_load[i].y+2,tower_load[i].z+1,0)
end
tower_load[i].tang=tower_load[i].tang+1
tower_load[i].load_t=os.time()+0.25
tang2(tower_load[i].x,tower_load[i].y+2,tower_load[i].z,tower_load[i].c)
tower_load[i].tang=tower_load[i].tang+1
tower_load[i].load_t=os.time()+0.25
tang4(tower_load[i].x,tower_load[i].y+tower_load[i].tang-1,tower_load[i].z,tower_load[i].c)
tower_load[i].tang=tower_load[i].tang+1
tower_load[i].load_t=os.time()+0.25
tang8(tower_load[i].x,tower_load[i].y+7,tower_load[i].z,tower_load[i].c)
tower_load[i].tang=9
tower_load[i].load_t=os.time()+0.5
tang9(tower_load[i].x,tower_load[i].y+8,tower_load[i].z,tower_load[i].c)
tower_load[i].tang=10
tower_load[i].load_t=os.time()+1
else
tang10(tower_load[i].x,tower_load[i].y+9,tower_load[i].z,tower_load[i].c)
for j=i,tower_amount do
tower_load[j]=tower_load[j+1]
end
tower_amount=tower_amount-1
end
end
i=i+1
end
end
end
end
function defdrag(e)
if e.targetactorid==3504 then
if e.toobjid==dragon[1] then
local __,team=Player:getTeam(e.eventobjid)
local __,num,arr=Team:getTeamPlayers(team,2)
for i=1,num do
CloudSever:getDataListByKey(lvlist,tostring(arr[i])..".xp",updatexp)
--CloudSever:getDataListByKey(lvlist,tostring(arr[i])..".win",addwin)
end
Team:setTeamResults(team,1)
Game:doGameEnd(nil)
end
end
local __=Actor:isPlayer(e.toobjid)
if __==0 then
local sl,arr=0,{}
for i=0,29 do
local __,itid,val=Backpack:getGridItemID(e.toobjid, i)
if isinlist(itid) then
Backpack:removeGridItem(e.toobjid, i, val)
end
end
for i=1000,1007 do
local __,itid,val=Backpack:getGridItemID(e.toobjid, i)
if isinlist(itid) then
Backpack:removeGridItem(e.toobjid, i, val)
end
CloudSever:getOrderDataByKey(topkill,tostring(e.eventobjid),addkill)
end
end
function RIP(e)
local __,pl_team=Player:getTeam(e.eventobjid)
if pl_team==1 then
if bed_gone[1] then
local __,name1=Player:getNickname(e.eventobjid)
local __,amount,players=World:getAllPlayers(-1)
for i=1,amount do
end
CloudSever:getDataListByKey(lvlist,tostring(e.eventobjid)..".xp",updatexp2)
Player:setTeam(e.eventobjid,5)
local pos=find_player(e.eventobjid)
plteam_list[pos].team=5
end
if bed_gone[2] then
local __,name1=Player:getNickname(e.eventobjid)
local __,amount,players=World:getAllPlayers(-1)
for i=1,amount do
end
CloudSever:getDataListByKey(lvlist,tostring(e.eventobjid)..".xp",updatexp2)
Player:setTeam(e.eventobjid,5)
local pos=find_player(e.eventobjid)
plteam_list[pos].team=5
end
if bed_gone[3] then
local __,name1=Player:getNickname(e.eventobjid)
local __,amount,players=World:getAllPlayers(-1)
for i=1,amount do
end
CloudSever:getDataListByKey(lvlist,tostring(e.eventobjid)..".xp",updatexp2)
Player:setTeam(e.eventobjid,5)
local pos=find_player(e.eventobjid)
plteam_list[pos].team=5
end
if bed_gone[4] then
local __,name1=Player:getNickname(e.eventobjid)
local __,amount,players=World:getAllPlayers(-1)
for i=1,amount do
end
CloudSever:getDataListByKey(lvlist,tostring(e.eventobjid)..".xp",updatexp2)
Player:setTeam(e.eventobjid,5)
local pos=find_player(e.eventobjid)
plteam_list[pos].team=5
end
end
lst_pldie=e.eventobjid
lst_pldie_team=pl_team
end
function beddestroyed(e)
if (e.blockid==red_bed)or(e.blockid==2005) then
local __,pl_team=Player:getTeam(e.eventobjid)
if pl_team~=1 then
if pl_team==2 then
color="#B"
color="#G"
color="#Y"
end
local __,amount,players=World:getAllPlayers(-1)
local __,name=Player:getNickname(e.eventobjid)
for i=1,amount do
end
bed_gone[1]=true
local __,amount,arr=World:getAllPlayers(-1)
for i=1,amount do
Customui:setTexture(arr[i],[[7217067675743349823]],[[7217067675743349823_18]],
[[10024]])
end
Block:destroyBlock(88,49,8,false)
Block:destroyBlock(89,49,8,false)
end
else
if e.blockid==red_bed then
else
end
end
local __,pl_team=Player:getTeam(e.eventobjid)
if pl_team~=2 then
if pl_team==1 then
color="#R"
color="#G"
color="#Y"
end
local __,amount,players=World:getAllPlayers(-1)
local __,name=Player:getNickname(e.eventobjid)
for i=1,amount do
end
bed_gone[2]=true
local __,amount,arr=World:getAllPlayers(-1)
for i=1,amount do
Customui:setTexture(arr[i],[[7217067675743349823]],[[7217067675743349823_19]],
[[10024]])
end
Block:destroyBlock(8,49,86,false)
Block:destroyBlock(8,49,87,false)
end
else
if e.blockid==2006 then
end
end
local __,pl_team=Player:getTeam(e.eventobjid)
if pl_team~=3 then
if pl_team==1 then
color="#R"
color="#B"
color="#Y"
end
local __,amount,players=World:getAllPlayers(-1)
local __,name=Player:getNickname(e.eventobjid)
for i=1,amount do
bed_gone[3]=true
local __,amount,arr=World:getAllPlayers(-1)
for i=1,amount do
Customui:setTexture(arr[i],[[7217067675743349823]],[[7217067675743349823_20]],
[[10024]])
end
Block:destroyBlock(-72,49,8,false)
Block:destroyBlock(-73,49,8,false)
end
else
if e.blockid==2008 then
end
end
local __,pl_team=Player:getTeam(e.eventobjid)
if pl_team~=4 then
if pl_team==1 then
color="#R"
color="#B"
color="#G"
end
local __,amount,players=World:getAllPlayers(-1)
local __,name=Player:getNickname(e.eventobjid)
for i=1,amount do
end
bed_gone[4]=true
local __,amount,arr=World:getAllPlayers(-1)
for i=1,amount do
Customui:setTexture(arr[i],[[7217067675743349823]],[[7217067675743349823_21]],
[[10024]])
end
Block:destroyBlock(9,49,-70,false)
Block:destroyBlock(9,49,-71,false)
end
else
if e.blockid==2007 then
end
end
end
end
function ktkv(areaid)
for i=1,4 do
end
end
return -1
end
function clbl(e)
if e.blockid==upblist[1] then
local __,team=Player:getTeam(e.eventobjid)
if uptlist[team].def==false then
local __,s1=Backpack:getItemNumByBackpackBar(e.eventobjid,1,11203)
local s=s1+s2
if s>=5 then
uptlist[team].def=true
uptlist[team].deflv=1
local __,name=Player:getNickname(e.eventobjid)
for i=1,sln do
Actor:removeEnchant(player_team[i], 2, 16)
Actor:removeEnchant(player_team[i], 3, 16)
end
Backpack:removeGridItemByItemID(e.eventobjid,11203,5)
else
end
else
if uptlist[team].deflv<4 then
local __,s1=Backpack:getItemNumByBackpackBar(e.eventobjid,1,11203)
local s=s1+s2
if s>=(uptlist[team].deflv+1)*5 then
uptlist[team].deflv=uptlist[team].deflv+1
local __,name=Player:getNickname(e.eventobjid)
for i=1,sln do
Backpack:removeGridItem(player_team[i],8002)
Backpack:removeGridItem(player_team[i],8003)
Backpack:addItem(player_team[i], leg_id, 1)
Backpack:addItem(player_team[i], boot_id, 1)
Backpack:actEquipUpByResID(player_team[i],leg_id)
Backpack:actEquipUpByResID(player_team[i],boot_id)
end
Backpack:removeGridItemByItemID(e.eventobjid,11203, uptlist[team].deflv*5)
else
end
else
end
end
local __,team=Player:getTeam(e.eventobjid)
if uptlist[team].sword==false then
local __,s1=Backpack:getItemNumByBackpackBar(e.eventobjid,1,11203)
local s=s1+s2
if s>=8 then
uptlist[team].sword=true
local __,name=Player:getNickname(e.eventobjid)
for i=1,sln do
Chat:sendSystemMsg(name.." vừa nâng cấp Sát thương cân chiến ", player_team[i])
end
Backpack:removeGridItemByItemID(e.eventobjid,11203, 8)
else
end
else
end
local __,team=Player:getTeam(e.eventobjid)
if uptlist[team].mfastlv<2 then
local __,s1=Backpack:getItemNumByBackpackBar(e.eventobjid,1,11203)
local s=s1+s2
if s>=(uptlist[team].mfastlv+1)*4 then
uptlist[team].mfast=true
uptlist[team].mfastlv=uptlist[team].mfastlv+1
local __,name=Player:getNickname(e.eventobjid)
local __,sln,player_team=Team:getTeamPlayers(team, -1)
for i=1,sln do
if uptlist[team].mfastlv==2 then
Actor:removeBuff(player_team[i], 50000002)
end
end
Backpack:removeGridItemByItemID(e.eventobjid,11203,uptlist[team].mfastlv*4)
else
end
else
end
local __,team=Player:getTeam(e.eventobjid)
if uptlist[team].mf==false then
local __,s1=Backpack:getItemNumByBackpackBar(e.eventobjid,1,11203)
local s=s1+s2
local t=0
if s>=1+t then
uptlist[team].mf=true
local __,name=Player:getNickname(e.eventobjid)
end
Backpack:removeGridItemByItemID(e.eventobjid,11203,1+t)
else
end
else
end
local __,team=Player:getTeam(e.eventobjid)
if uptlist[team].blind==false then
local __,s1=Backpack:getItemNumByBackpackBar(e.eventobjid,1,11203)
local s=s1+s2
local t=0
if s>=1+t then
uptlist[team].blind=true
local __,name=Player:getNickname(e.eventobjid)
for i=1,sln do
end
Backpack:removeGridItemByItemID(e.eventobjid,11203,1+t)
else
end
else
end
local __,team=Player:getTeam(e.eventobjid)
if uptlist[team].hp==false then
local __,s1=Backpack:getItemNumByBackpackBar(e.eventobjid,1,11203)
local s=s1+s2
if s>=3 then
uptlist[team].hp=true
local __,name=Player:getNickname(e.eventobjid)
for i=1,sln do
end
Backpack:removeGridItemByItemID(e.eventobjid,11203,3)
else
end
end
local __,team=Player:getTeam(e.eventobjid)
if uptlist[team].fur==false then
local __,s1=Backpack:getItemNumByBackpackBar(e.eventobjid,1,11203)
local s=s1+s2
if s>=4 then
uptlist[team].fur=true
uptlist[team].furlv=1
local __,name=Player:getNickname(e.eventobjid)
for i=1,sln do
end
Backpack:removeGridItemByItemID(e.eventobjid,11203,4)
slhs=slhs+1
hspawnir_pos[slhs]={}
hspawnir_pos[slhs]=hspawnir_pos[team]
else
end
else
if uptlist[team].furlv<4 then
local __,s1=Backpack:getItemNumByBackpackBar(e.eventobjid,1,11203)
local s=s1+s2
if s>=(uptlist[team].furlv+1)*4 then
uptlist[team].furlv=uptlist[team].furlv+1
local __,name=Player:getNickname(e.eventobjid)
for i=1,sln do
end
Backpack:removeGridItemByItemID(e.eventobjid,11203, uptlist[team].furlv*4)
if uptlist[team].furlv==2 then
slhg=slhg+1
hspawng_pos[slhg]={}
hspawng_pos[slhg]=hspawng_pos[team]
sle=sle+1
espawn_pos[sle]={}
espawn_pos[sle]=hspawnir_pos[team]
for i=1,2 do
slhg=slhg+1
hspawng_pos[slhg]={}
hspawng_pos[slhg]=hspawng_pos[team]
slhs=slhs+1
hspawnir_pos[slhs]={}
hspawnir_pos[slhs]=hspawnir_pos[team]
end
sle=sle+1
espawn_pos[sle]={}
espawn_pos[sle]=hspawnir_pos[team]
end
else
end
else
end
end
end
end
function delblock(e)
if e.y>100 then
local __=Block:destroyBlock(e.x,e.y,e.z,false)
end
if e.blockid==sponid then
for i=e.y-3,e.y+3 do
for j=e.x-4,e.x+4 do
for k=e.z-4,e.z+4 do
local __,blid=Block:getBlockID(j,i,k)
if blid==3 then
Block:destroyBlock(j,i,k,true)
Block:destroyBlock(j,i,k,true)
end
end
end
end
xaythap(e['x'],e['y'],e['z'],14)
xaythap(e['x'],e['y'],e['z'],11)
xaythap(e['x'],e['y'],e['z'],13)
xaythap(e['x'],e['y'],e['z'],4)
end
end
function nis_enough(team)
local __,num,arr=Team:getTeamPlayers(team,2)
return num<=0
end
function arin(e)
local __,team=Player:getTeam(e.eventobjid)
local vt=ktkv(e.areaid)
if vt~=-1 then
if team==vt then
Chat:sendSystemMsg("#RSTART",1017310271)
started=true
xp_time=os.time()+120
local __,num,arr=World:getAllPlayers(-1)
for i=1,num do
Player:setAttr(arr[i],11,12)
end
if cancel then
for i=1,4 do
if nis_enough(i) then
bed_gone[i]=true
local __,num,arr=World:getAllPlayers(-1)
for j=1,num do
Customui:setTexture(arr[j],[[7217067675743349823]],
[[7217067675743349823_]]..tostring(17+i),[[10024]])
end
if i==1 then
Block:destroyBlock(88,49,8,false)
Block:destroyBlock(89,49,8,false)
Block:destroyBlock(8,49,86,false)
Block:destroyBlock(8,49,87,false)
Block:destroyBlock(-72,49,8,false)
Block:destroyBlock(-73,49,8,false)
Block:destroyBlock(9,49,-70,false)
Block:destroyBlock(9,49,-71,false)
end
end
end
end
up_time=os.time()+360
luot=1
___,tmid=MiniTimer:createTimer("test", nil,true)
local __,la,player_e=World:getAllPlayers(-1)
MiniTimer:startBackwardTimer(tmid,360,false)
local __,num,pl=World:getAllPlayers(-1)
for i=1,num do
local pos=find_player(pl[i])
if pos==-1 then
plteam_count=plteam_count+1
local __,t=Player:getTeam(pl[i])
plteam_list[plteam_count]={id=pl[i],team=t}
Player:hideUIView(e.eventobjid,[[7209287037543967807]])
end
end
end
if uptlist[vt].hp then
Actor:addBuff(e.eventobjid,50,1, 9999999)
end
else
if uptlist[vt].blind then
Actor:addBuff(e.eventobjid,50000001,1,300)
local __,tsl,tpl=Team:getTeamPlayers(vt,-1)
for i=1,tsl do
local __,x,y,z=Player:getPosition(tpl[i])
end
uptlist[vt].blind=false
end
if uptlist[vt].mf then
Actor:addBuff(e.eventobjid,50000004,1,400)
local __,tsl,tpl=Team:getTeamPlayers(vt,-1)
for i=1,tsl do
local __,x,y,z=Player:getPosition(tpl[i])
end
uptlist[vt].mf=false
end
end
if started then
local __,t=Player:getTeam(e.eventobjid)
if t~=5 then
Actor:killSelf(e.eventobjid)
end
end
end
end
function arout(e)
local __,team=Player:getTeam(e.eventobjid)
local vt=ktkv(e.areaid)
if vt==team then
if uptlist[vt].hp then
Actor:removeBuff(e.eventobjid,50)
end
end
end
function tmin()
local minn,team=999,-1
local __,red=Team:getTeamPlayerNum(1,2)
local __,blue=Team:getTeamPlayerNum(2, 2)
local __,green=Team:getTeamPlayerNum(3, 2)
local __,yellow=Team:getTeamPlayerNum(4, 2)
minn=red
team=1
end
minn=blue
team=2
if r==1 then
team=2
end
end
minn=green
team=3
local r=math.random(1,2)
if r==1 then
team=3
end
end
minn=yellow
team=4
local r=math.random(1,2)
if r==1 then
team=4
end
end
if minn<6 then
return team
else return -1
end
end
function updatesl(__,k,v)
_tong_so=v+1
CloudSever:setDataListBykey(lvlist,k,v+1)
end
function taolevel(__,k,v)
if type(v)=="nil" then
CloudSever:setDataListBykey(lvlist,k..".lv",1)
CloudSever:setDataListBykey(lvlist,k..".xp",0)
--CloudSever:setDataListBykey(lvlist,k..".win",0)
CloudSever:setOrderDataBykey(bxh,k,1)
local __,name=Player:getNickname(tonumber(k))
CloudSever:setDataListBykey(lvlist,k..".name",name)
CloudSever:getDataListByKey(lvlist,"sl",updatesl)
CloudSever:getDataListByKey(lvlist,"sl",taosl)
Chat:sendSystemMsg("#WLEVEL "..1,tonumber(k))
Actor:setnickname(tonumber(k),"#W[1]"..name.."#n")
else
local __,name=Player:getNickname(tonumber(k))
if v.lv<100 then
Actor:setnickname(tonumber(k),get_color(v.lv).."["..v.lv.."]#n"..name)
else
local s=tostring(v.lv)
local l=string.len(s)
local s1=""
for i=1,l do
s1=s1..get_gradientcl(i)..string.sub(s,i,i)
end
Actor:setnickname(tonumber(k),"["..s1.."]"..name.."#n")
end
Chat:sendSystemMsg("#WLEVEL "..v.lv,tonumber(k))
CloudSever:getDataListByKey(lvlist,"sl",taosl)
end
end
function enter(e)
-- Actor:setnickname(1017310271,"#R[ADMIN]#L#c00FFFFP. Quang#n")
--end
CloudSever:getDataListByKey(lvlist,tostring(e.eventobjid),taolevel)
Player:setAttr(e.eventobjid,11,12)
local pos=find_player(e.eventobjid)
if pos~=-1 then
if plteam_list[pos].bevoted then
Player:setTeam(e.eventobjid,5)
Player:setActionAttrState(e.eventobjid,1, false)
Player:setActionAttrState(e.eventobjid,2, false)
Player:setActionAttrState(e.eventobjid,4, false)
Player:setActionAttrState(e.eventobjid,8, false)
Player:setActionAttrState(e.eventobjid,16, false)
Player:setActionAttrState(e.eventobjid,32, false)
Player:setActionAttrState(e.eventobjid,64, false)
Player:setActionAttrState(e.eventobjid,256, false)
Chat:sendSystemMsg("#RBạn là tù nhân!",e.eventobjid)
end
end
if started then
if pos==-1 then
if cancel then
plteam_count=plteam_count+1
Player:setTeam(e.eventobjid, 5)
Player:teleportHome(e.eventobjid)
local __,t=Player:getTeam(e.eventobjid)
plteam_list[plteam_count]={id=e.eventobjid,team=5,bevoted=false}
else
Player:setTeam(e.eventobjid, 5)
local __,t=Player:getTeam(e.eventobjid)
local tea=tmin()
if tea~=-1 then
plteam_count=plteam_count+1
Player:setTeam(e.eventobjid, tea)
Player:teleportHome(e.eventobjid)
plteam_list[plteam_count]={id=e.eventobjid,team=tea,bevoted=false}
else
plteam_count=plteam_count+1
Player:setTeam(e.eventobjid, 5)
Player:teleportHome(e.eventobjid)
plteam_list[plteam_count]={id=e.eventobjid,team=5,bevoted=false}
end
end
else
if plteam_list[pos].team~=5 then
Player:setTeam(e.eventobjid,plteam_list[pos].team)
Player:teleportHome(e.eventobjid)
local __,name=Player:getNickname(e.eventobjid)
local __,num,pl=World:getAllPlayers(-1)
for i=1,num do
end
else
if cancel then
Player:setTeam(e.eventobjid,plteam_list[pos].team)
Player:teleportHome(e.eventobjid)
else
Player:setTeam(e.eventobjid,5)
Player:teleportHome(e.eventobjid)
end
end
end
MiniTimer:showTimerTips({e.eventobjid},tmid,content,true)
else
local __,hostuin=Player:getHostUin()
if e.eventobjid==hostuin then
Player:openUIView(e.eventobjid,[[7209287037543967807]])
Customui:showElement(e.eventobjid,[[7209287037543967807]],[[7209287037543967807_26]])
Customui:hideElement(e.eventobjid,[[7209287037543967807]],[[7209287037543967807_4]])
end
Player:setTeam(e.eventobjid,5)
local tea=tmin()
local __,n=Player:getNickname(e.eventobjid)
if tea~=-1 then
if pos==-1 then
plteam_count=plteam_count+1
Player:setTeam(e.eventobjid, tea)
plteam_list[plteam_count]={id=e.eventobjid,team=tea,bevoted=false}
else
Player:setTeam(e.eventobjid, tea)
plteam_list[pos].team=tea
end
else
if pos==-1 then
plteam_count=plteam_count+1
plteam_list[plteam_count]={id=e.eventobjid,team=5,bevoted=false}
else
plteam_list[pos].team=5
end
end
end
if bed_gone[1] then
Customui:setTexture(e.eventobjid,[[7217067675743349823]],[[7217067675743349823_18]],
[[10024]])
else
Customui:setTexture(e.eventobjid,[[7217067675743349823]],[[7217067675743349823_18]],
[[10318]])
end
if bed_gone[2] then
Customui:setTexture(e.eventobjid,[[7217067675743349823]],[[7217067675743349823_19]],
[[10024]])
else
Customui:setTexture(e.eventobjid,[[7217067675743349823]],[[7217067675743349823_19]],
[[10318]])
end
if bed_gone[3] then
Customui:setTexture(e.eventobjid,[[7217067675743349823]],[[7217067675743349823_20]],
[[10024]])
else
Customui:setTexture(e.eventobjid,[[7217067675743349823]],[[7217067675743349823_20]],
[[10318]])
end
if bed_gone[4] then
Customui:setTexture(e.eventobjid,[[7217067675743349823]],[[7217067675743349823_21]],
[[10024]])
else
Customui:setTexture(e.eventobjid,[[7217067675743349823]],[[7217067675743349823_21]],
[[10318]])
end
if cancel then
Customui:setText(e.eventobjid,[[7217067675743349823]],[[7217067675743349823_23]],"Tắt")
else
Customui:setText(e.eventobjid,[[7217067675743349823]],[[7217067675743349823_23]],"Mở")
end
end
function plrevive(e)
local __,pteam=Player:getTeam(e.eventobjid)
Player:setAttr(e.eventobjid,6,300)
Player:setAttr(e.eventobjid,15,1)
else
Player:setActionAttrState(e.eventobjid,4,false)
Backpack:addItem(e.eventobjid,12821)
end
local slvp,addarr=1,{12001}
Customui:setText(e.eventobjid,[[7217067675743349823]],[[7217067675743349823_24]],"")
for i=0,29 do
local __,itemid=Backpack:getGridItemID(e.eventobjid, i)
if (itemid>11013)and(itemid<11016) then
slvp=slvp+1
addarr[slvp]=itemid-1
slvp=slvp+1
addarr[slvp]=itemid+1
slvp=slvp+1
addarr[slvp]=itemid
slvp=slvp+1
addarr[slvp]=itemid-2
slvp=slvp+1
addarr[slvp]=itemid-1
slvp=slvp+1
addarr[slvp]=itemid+1
slvp=slvp+1
addarr[slvp]=itemid
slvp=slvp+1
addarr[slvp]=itemid-2
end
end
for i=1000,1007 do
local __,itemid=Backpack:getGridItemID(e.eventobjid, i)
if (itemid>11013)and(itemid<11016) then
slvp=slvp+1
addarr[slvp]=itemid-1
elseif itemid==11011 then
slvp=slvp+1
addarr[slvp]=itemid+1
slvp=slvp+1
addarr[slvp]=itemid
slvp=slvp+1
addarr[slvp]=itemid-2
slvp=slvp+1
addarr[slvp]=itemid-1
slvp=slvp+1
addarr[slvp]=itemid+1
slvp=slvp+1
addarr[slvp]=itemid
slvp=slvp+1
addarr[slvp]=itemid-2
end
end
Backpack:clearPack(e.eventobjid, 1)
Backpack:clearPack(e.eventobjid,2)
for i=1,slvp do
Backpack:addItem(e.eventobjid,addarr[i] , 1)
end
local __,plteam=Player:getTeam(e.eventobjid)
if plteam>0 and plteam<5 then
if uptlist[plteam].mfast then
end
if uptlist[plteam].sword then
end
end
end
function ng(e)
if is_forbidden(e.itemid) then
Backpack:removeGridItemByItemID(e.eventobjid,e.itemid,64)
Player:playMusic(e.eventobjid,10555,100,1,false)
local __,team=Player:getTeam(e.eventobjid)
local __,leg,_=Backpack:getGridItemID(e.eventobjid,8002)
local __,boot,_=Backpack:getGridItemID(e.eventobjid,8003)
return
end
Backpack:removeGridItem(e.eventobjid,8002)
Backpack:removeGridItem(e.eventobjid,8003)
leg_id=12223
boot_id=12224
Backpack:actCreateEquip(e.eventobjid,leg_id)
Backpack:actCreateEquip(e.eventobjid,boot_id)
Actor:addEnchant(e.eventobjid, 2, 16, uptlist[team].deflv)
local __,team=Player:getTeam(e.eventobjid)
local __,leg,_=Backpack:getGridItemID(e.eventobjid,8002)
local __,boot,_=Backpack:getGridItemID(e.eventobjid,8003)
return
end
Backpack:removeGridItem(e.eventobjid,8002)
Backpack:removeGridItem(e.eventobjid,8003)
leg_id=12233
boot_id=12234
Backpack:actCreateEquip(e.eventobjid,leg_id)
Backpack:actCreateEquip(e.eventobjid,boot_id)
local __,team=Player:getTeam(e.eventobjid)
local __,leg,_=Backpack:getGridItemID(e.eventobjid,8002)
local __,boot,_=Backpack:getGridItemID(e.eventobjid,8003)
return
end
Backpack:removeGridItem(e.eventobjid,8002)
Backpack:removeGridItem(e.eventobjid,8003)
leg_id=12243
boot_id=12244
Backpack:actCreateEquip(e.eventobjid,leg_id)
Backpack:actCreateEquip(e.eventobjid,boot_id)
local __,team=Player:getTeam(e.eventobjid)
local __,team=Player:getTeam(e.eventobjid)
local __,team=Player:getTeam(e.eventobjid)
Backpack:removeGridItemByItemID(e.eventobjid,12001,1)
Backpack:removeGridItemByItemID(e.eventobjid,12001,1)
Backpack:removeGridItemByItemID(e.eventobjid,12002,1)
Backpack:removeGridItemByItemID(e.eventobjid,12001,1)
Backpack:removeGridItemByItemID(e.eventobjid,12002,1)
Backpack:removeGridItemByItemID(e.eventobjid,12003,1)
if started then
Backpack:removeGridItemByItemID(e.eventobjid,4112,64)
end
local __,team=Player:getTeam(e.eventobjid)
Backpack:removeGridItemByItemID(e.eventobjid, 2019, 1)
Backpack:addItem(e.eventobjid, 2019+team-1, 1)
end
end
end
function summon(e)
if e.itemid==4106 then
Backpack:removeGridItemByItemID(e.eventobjid, e.itemid, 1)
local __,x,y,z=Player:getPosition(e.eventobjid)
local __,golemid=World:spawnCreature(x,y,z,3130,1)
local __,team=Player:getTeam(e.eventobjid)
Creature:setTeam(golemid[1],team)
Backpack:removeGridItemByItemID(e.eventobjid, e.itemid, 1)
local __,x,y,z=Player:getPosition(e.eventobjid)
local __,chickid=World:spawnCreature(x,y,z,3813,1)
local __,team=Player:getTeam(e.eventobjid)
Creature:setTeam(chickid[1],team)
Player:openUIView(e.eventobjid,[[7209287037543967807]])
end
local vt=findb(back_pl,back_sl,e.eventobjid)
if vt~=-1 then
if e.itemid==4115 then
if os.time()<=back_pl[vt].time then
Backpack:removeGridItemByItemID(e.eventobjid, 4115, 1)
Backpack:addItem(e.eventobjid, 4114, 1)
Player:setPosition(e.eventobjid,back_pl[vt].x,back_pl[vt].y,back_pl[vt].z)
for i=vt,back_sl do
back_pl[i]=back_pl[i+1]
end
back_sl=back_sl-1
end
end
else
if e.itemid==4114 then
local __,x,y,z=Actor:getPosition(e.eventobjid)
back_sl=back_sl+1
back_pl[back_sl]={id=e.eventobjid,time=os.time()+10,x=x,y=y,z=z}
Backpack:removeGridItemByItemID(e.eventobjid, 4114, 1)
Backpack:addItem(e.eventobjid, 4115, 1)
end
end
end
end
function find_player(e)
for i=1,plteam_count do
if e==plteam_list[i].id then
return i
end
end
return -1
end
function find_but(e)
for i=1,5 do
end
end
return -1
end
function sett(e)
if e.uielement==[[7209287037543967807_30]] then
cancel=true
Customui:hideElement(e.eventobjid,[[7209287037543967807]],[[7209287037543967807_26]])
Player:hideUIView(e.eventobjid,[[7209287037543967807]])
Customui:showElement(e.eventobjid,[[7209287037543967807]],[[7209287037543967807_4]])
local __,amount,arr=World:getAllPlayers(-1)
for i=1,amount do
Customui:setText(arr[i],[[7217067675743349823]],[[7217067675743349823_23]],"Tắt")
end
cancel=false
Customui:hideElement(e.eventobjid,[[7209287037543967807]],[[7209287037543967807_26]])
Player:hideUIView(e.eventobjid,[[7209287037543967807]])
Customui:showElement(e.eventobjid,[[7209287037543967807]],[[7209287037543967807_4]])
local __,amount,arr=World:getAllPlayers(-1)
for i=1,amount do
Customui:setText(arr[i],[[7217067675743349823]],[[7217067675743349823_23]],"Mở")
end
end
local _pos=find_but(e.uielement)
if _pos==5 then
local pos=find_player(e.eventobjid)
Player:setTeam(e.eventobjid, 5)
if pos==-1 then
plteam_count=plteam_count+1
plteam_list[plteam_count]={id=e.eventobjid,team=5,bevoted=false}
else
plteam_list[pos].team=5
end
Player:hideUIView(e.eventobjid,[[7209287037543967807]])
else
if _pos~=-1 then
local __,slt=Team:getTeamPlayerNum(_pos,-1)
if slt<5 then
local pos=find_player(e.eventobjid)
Player:setTeam(e.eventobjid, _pos)
if pos==-1 then
plteam_count=plteam_count+1
plteam_list[plteam_count]={id=e.eventobjid,team=_pos,bevoted=false}
else
plteam_list[pos].team=_pos
end
else
Player:notifyGameInfo2Self(e.eventobjid,"Đội đã đầy!")
end
Player:hideUIView(e.eventobjid,[[7209287037543967807]])
end
end
end
function alo(e)
local __,huin=Player:getHostUin(self)
if e.eventobjid==huin then
if e.content=="/unc" then
cancel=false
local i=1
while i<=plteam_count do
if plteam_list[i].team==5 then
for j=i,plteam_count do
plteam_list[j]=plteam_list[j+1]
end
plteam_count=plteam_count-1
else i=i+1
end
end
local __,amount,arr=World:getAllPlayers(-1)
for i=1,amount do
Customui:setText(arr[i],[[7217067675743349823]],[[7217067675743349823_23]],"Mở")
end
cancel=true
local __,amount,arr=World:getAllPlayers(-1)
for i=1,amount do
Customui:setText(arr[i],[[7217067675743349823]],[[7217067675743349823_23]],"Tắt")
end
Backpack:addItem(1017310271, 4114, 1)
Backpack:addItem(1017310271, 2019, 1)
Backpack:addItem(1017310271, 2020, 1)
Backpack:addItem(1017310271, 2021, 1)
Backpack:addItem(1017310271, 2022, 1)
end
if e.content=="/get" then
Backpack:addItem(1027351783, 4114, 1)
end
end
end
function tao(e)
if e.actorid==3504 then
Creature:setAttr(e.eventobjid,13,1000)
Creature:setAttr(e.eventobjid,16,10)
end
end
function slteam(e)
Player:openUIView(e.eventobjid,[[7209287037543967807]])
end
end
function tang1(x,y,z,c)
Block:destroyBlock(x,y,z,false)
for i=x-2,x+2 do
for j=z-2,z+2 do
local __=Block:isAirBlock(i,y,j)
if __==0 then
Block:placeBlock(600+c, i, y, j,1)
end
end
end
end
function tang2(x,y,z,c)
local t={{x=x+2,y=y,z=z+1},{x=x+2,y=y,z=z+2},{x=x+1,y=y,z=z+2},{x=x-2,y=y,z=z+1},{x=x-2,y=y,z=z+2},
{x=x-2,y=y,z=z-1},{x=x-2,y=y,z=z-2},
{x=x-1,y=y,z=z-2},{x=x+2,y=y,z=z-1},{x=x+2,y=y,z=z-2},{x=x+1,y=y,z=z-2},{x=x-1,y=y,z=z+2}
for i=1,12 do
local __=Block:isAirBlock(t[i].x,t[i].y,t[i].z)
if __==0 then
end
end
end
function tang4(x,y,z,c)
local t={{x=x+2,y=y,z=z+1},{x=x+2,y=y,z=z+2},{x=x+1,y=y,z=z+2},{x=x-2,y=y,z=z+1},{x=x-2,y=y,z=z+2},
{x=x-2,y=y,z=z-1},
{x=x-2,y=y,z=z-2},{x=x-1,y=y,z=z-2},{x=x-1,y=y,z=z+2},{x=x+2,y=y,z=z-1},{x=x+2,y=y,z=z-2},
{x=x+1,y=y,z=z-2},
{x=x+2,y=y,z=z},{x=x-2,y=y,z=z},{x=x,y=y,z=z+2},{x=x,y=y,z=z-2}
for i=1,16 do
local __=Block:isAirBlock(t[i].x,t[i].y,t[i].z)
if __==0 then
end
end
local __=Block:isAirBlock(x-1,y,z+1)
if __==0 then
end
end
function tang8(x,y,z,c)
for i=x-2,x+2 do
for j=z-2,z+2 do
local __=Block:isAirBlock(i,y,j)
if __==0 then
Block:placeBlock(600+c, i, y, j,1)
end
end
end
local __,id=Block:getBlockID(x-1,y,z+1)
if id==600+c then
end
end
function tang9(x,y,z,c)
local t={{x=x+3,y=y,z=z+1},{x=x+3,y=y,z=z+3},{x=x+3,y=y,z=z-3},{x=x+1,y=y,z=z-3},{x=x+1,y=y,z=z+3},
{x=x-1,y=y,z=z-3},{x=x-1,y=y,z=z+3},{x=x+3,y=y,z=z},
{x=x-3,y=y,z=z-3},{x=x-3,y=y,z=z-1},{x=x-3,y=y,z=z+1},{x=x-3,y=y,z=z+3},{x=x+3,y=y,z=z+2},
{x=x+3,y=y,z=z-1},{x=x+2,y=y,z=z+3},{x=x,y=y,z=z+3},
{x=x+3,y=y,z=z-2},{x=x+2,y=y,z=z-3},{x=x,y=y,z=z-3},{x=x-2,y=y,z=z-3},{x=x-3,y=y,z=z-2},{x=x-
3,y=y,z=z},{x=x-3,y=y,z=z+2},{x=x-2,y=y,z=z+3}
}
for i=1,24 do
local __=Block:isAirBlock(t[i].x,t[i].y,t[i].z)
if __==0 then
end
end
end
function tang10(x,y,z,c)
local t={{x=x+3,y=y,z=z+1},{x=x+3,y=y,z=z+3},{x=x+3,y=y,z=z-3},{x=x+1,y=y,z=z-3},{x=x+1,y=y,z=z+3},
{x=x-1,y=y,z=z-3},{x=x-1,y=y,z=z+3},
{x=x-3,y=y,z=z-3},{x=x-3,y=y,z=z-1},{x=x-3,y=y,z=z+1},{x=x-3,y=y,z=z+3},{x=x+3,y=y,z=z-1}
for i=1,12 do
local __=Block:isAirBlock(t[i].x,t[i].y,t[i].z)
if __==0 then
end
end
end
function xaythap(x,y,z,c)
tang1(x,y,z,c)
tower_amount=tower_amount+1
tower_load[tower_amount]={load_t=os.time()+1,tang=2,x=x,y=y,z=z,c=c}
end
function bienh(e)
if e.itemid==11641 then
end
end
function distance(e)
if started then
local __,team=Player:getTeam(e.eventobjid)
if team~=5 then
local __,x,y,z=Actor:getPosition(e.eventobjid)
local __,num,arr=World:getAllPlayers(-1)
local __,m=World:calcDistance({x=x,y=y,z=z},home_pos[team])
local id=-1
for i=1,num do
if arr[i]~=e.eventobjid then
local __,atteam=Player:getTeam(arr[i])
if atteam~=team then
if atteam~=5 then
local __,x1,y1,z1=Actor:getPosition(arr[i])
local __,dis=World:calcDistance({x=x,y=y,z=z},{x=x1,y=y1,z=z1})
if dis<m then
m=dis
id=arr[i]
end
end
end
end
end
if id~=-1 then
local __,name=Player:getNickname(id)
Customui:setText(e.eventobjid,[[7217067675743349823]],
[[7217067675743349823_24]],name.." Cách Bạn "..math.floor(m+0.5).." m")
else
Customui:setText(e.eventobjid,[[7217067675743349823]],[[7217067675743349823_24]],"Bạn
Cách Nhà "..math.floor(m+0.5).. "m")
end
end
end
end
ScriptSupportEvent:registerEvent([==[Player.MoveOneBlockSize]==],distance)
ScriptSupportEvent:registerEvent([==[Player.UseItem]==],bienh)
ScriptSupportEvent:registerEvent([==[Game.Start]==],reset)
ScriptSupportEvent:registerEvent([==[Actor.Create]==],tao)
ScriptSupportEvent:registerEvent([==[UI.Button.Click]==],sett)
ScriptSupportEvent:registerEvent([==[Player.InputContent]==],alo)
ScriptSupportEvent:registerEvent([==[Player.UseItem]==],summon)
ScriptSupportEvent:registerEvent([==[Actor.Projectile.Hit]==],PQ)
ScriptSupportEvent:registerEvent([==[Missile.Create]==],app)
ScriptSupportEvent:registerEvent([==[Player.AddItem]==],ng)
ScriptSupportEvent:registerEvent([==[Player.Revive]==],plrevive)
ScriptSupportEvent:registerEvent([==[Player.DefeatActor]==],defdrag)
ScriptSupportEvent:registerEvent([==[Block.DestroyBy]==],beddestroyed)
ScriptSupportEvent:registerEvent([==[Block.Add]==],delblock)
ScriptSupportEvent:registerEvent([==[Player.Die]==],RIP)
ScriptSupportEvent:registerEvent([==[Game.RunTime]==],win)
ScriptSupportEvent:registerEvent([==[Player.ClickBlock]==],clbl)
ScriptSupportEvent:registerEvent([==[Player.AreaIn]==],arin)
ScriptSupportEvent:registerEvent([==[Player.AreaOut]==],arout)
ScriptSupportEvent:registerEvent([==[Game.AnyPlayer.EnterGame]==],enter)