0% found this document useful (0 votes)
2 views68 pages

Main Code Bedwar

Uploaded by

phuquang207
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views68 pages

Main Code Bedwar

Uploaded by

phuquang207
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 68

started=false

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"

elseif level<20 then

return "#B"

elseif level<40 then

return "#G"
elseif level<50 then

return "#Y"

elseif level<70 then

return "#R"

elseif level<80 then

return "#K"

elseif level<100 then

return "#b#R"

end

end

function get_gradientcl(cs)

if cs==1 then

return "#K"

elseif cs==2 then

return "#R"

elseif cs==3 then

return "#Y"

elseif cs==4 then

return "#G"

elseif cs==5 then

return "#B"

else

return "#b"

end

end

function test(__,k,v,ix)

local pldata

if ix<4 then

pldata=Graphics:makeGraphicsText("#RTop "..ix..":["..get_color(v)..v.."#R]"..", ID:"..k,12,1,1)


elseif ix<6 then

pldata=Graphics:makeGraphicsText("#YTop "..ix..":["..get_color(v)..v.."#Y]"..", ID:"..k,12,1,1)

else

pldata=Graphics:makeGraphicsText("#GTop "..ix..":["..get_color(v)..v.."#G]"..", ID:"..k,12,1,1)

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

elseif a.lv==b.lv then

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

while ss(mid,A[i]) do i=i+1 end

while ss(A[j],mid) do j=j-1 end

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

while ss(mid,A[i]) do i=i+1 end


while ss(A[j],mid) do j=j-1 end

if i<=j then

local x=A[i]

A[i]=A[j]

A[j]=x

i=i+1

j=j-1

end

end

if i<h then QS(A,i,h) end

if l<j then QS(A,l,j) 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

Player:setPosition(pl[i].pl, e.x, e.y+1, e.z)

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

if array[i]==0 then dem=dem+1

end

end

if dem==3 then

for i=1,4 do

if array[i]~=0 then return i

end

end

elseif dem==4 then


return lst_pldie_team

else

return -1

end

end

function get_limit_xp(level)

if level<10 then

return 400+level*100

elseif level<20 then

return 900+level*100

elseif level<40 then

return 3900+level*100

elseif level<50 then

return 6900+level*200

elseif level<70 then

return 9900+level*500

elseif level<80 then

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)

Chat:sendSystemMsg("#GLÊN CẤP!!! #YLv "..(dat.lv).."!",tonumber(id))

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)

Chat:sendSystemMsg("#GLÊN CẤP!!! #YLv "..dat.lv.."!",tonumber(id))

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)

Chat:sendSystemMsg("#GLÊN CẤP!!! #YLv "..dat.lv.."!",tonumber(id))

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

if not antiafk_pl[i].isafk then

antiafk_pl[i].isafk=true

local __,name=Player:getNickname(antiafk_pl[i].id)

for j=1,num do

Chat:sendSystemMsg(name.."#W đang afk...zzz",arr[j])

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

local __,x=Team:getTeamPlayers(i, -1)

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

if not bed_gone[i] 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 __,num,objids=World:getActorsByBox(3, x+3, y+3, z+3, x-3, y-3, z-3)

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)

if n<1 then n=1 end

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 __,num,objids=World:getActorsByBox(3, x+3, y+3, z+3, x-3, y-3, z-3)

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)

World:spawnItem(x,y,z, 11207, math.floor(n/2)+1)

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 __,num,objids=World:getActorsByBox(3, x+3, y+3, z+3, x-3, y-3, z-3)

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

if x==hspawnir_pos[i].x and y==hspawnir_pos[i].y and z==hspawnir_pos[i].z then

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

thongtin.title="Vàng Đen sẽ xuất hiện sau "..(tspdi-os.time()).."s"

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

thongtin.title="Hổ Phách sẽ xuất hiện sau "..(tspe-os.time()).."s"

Graphics:createGraphicsTxtByPos(x,y,z,thongtin)

end

tghienthi=os.time()+1

end
if os.time()>=up_time then

if luot==1 then diarl_time=15

luot=2

local __,apn,aplayer=World:getAllPlayers(-1)

for i=1,apn do

Chat:sendSystemMsg("#cD4DDFFVàng Đen Đã Lên LV II", aplayer[i])

end

local __,la,player_e=World:getAllPlayers(-1)

content="#YHổ Phách #c00FFFFII: #W"

MiniTimer:showTimerTips(player_e, tmid,content, true)

MiniTimer:startBackwardTimer(tmid,360,false)

elseif luot==2 then

erl_time=30

luot=3

local __,apn,aplayer=World:getAllPlayers(-1)

for i=1,apn do

Chat:sendSystemMsg("#Y Hổ Phách Đã Lên LV II", aplayer[i])

end

local __,la,player_e=World:getAllPlayers(-1)

content="#cD4DDFFVàng Đen #c00FFFFIII:#W "

MiniTimer:deleteTimer(tmid)

___,tmid=MiniTimer:createTimer("test",nil,true)

MiniTimer:showTimerTips(player_e, tmid,content, true)

MiniTimer:startBackwardTimer(tmid,360,false)

elseif luot==3 then

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

Chat:sendSystemMsg("#cD4DDFF Vàng Đen Đã Lên LV III", aplayer[i])

end

local __,la,player_e=World:getAllPlayers(-1)

content="#YHổ Phách #c00FFFFIII: #W"

MiniTimer:deleteTimer(tmid)

___,tmid=MiniTimer:createTimer("test",nil,true)

MiniTimer:showTimerTips(player_e, tmid,content, true)

MiniTimer:startBackwardTimer(tmid,360,false)

elseif luot==4 then

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

Chat:sendSystemMsg("#YHổ Phách Đã Lên LV III", aplayer[i])

end

local __,la,player_e=World:getAllPlayers(-1)

content="#c90EDF9Giường tự hủy: "

MiniTimer:deleteTimer(tmid)

___,tmid=MiniTimer:createTimer("test",nil,true)

MiniTimer:showTimerTips(player_e, tmid,content, true)

MiniTimer:startBackwardTimer(tmid,360,false)

elseif luot==5 then

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

Chat:sendSystemMsg("#R Giường Tự Hủy", aplayer[i])

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)

content="Kết thúc "

MiniTimer:deleteTimer(tmid)

___,tmid=MiniTimer:createTimer("test",nil,true)

MiniTimer:showTimerTips(aplayer, tmid,content, true)


World:playSoundEffectOnPos({x=9,y=67,z=8},10487, 3000, 1, false)

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

elseif tower_load[i].tang==3 then

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

elseif tower_load[i].tang>3 and tower_load[i].tang<8 then

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

elseif tower_load[i].tang==8 then

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

elseif tower_load[i].tang==9 then

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)

Backpack:addItem(e.eventobjid, itid, 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)

Backpack:addItem(e.eventobjid, itid, val)


end

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

Chat:sendSystemMsg("#c880000[KẾT THÚC RỒI]#R"..name1..":#W Tạm biệt các bạn!",


players[i])

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

elseif pl_team==2 then

if bed_gone[2] then

local __,name1=Player:getNickname(e.eventobjid)

local __,amount,players=World:getAllPlayers(-1)

for i=1,amount do

Chat:sendSystemMsg("#c880000[KẾT THÚC RỒI]#B"..name1..":#W Tạm biệt các bạn!",


players[i])

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

elseif pl_team==3 then

if bed_gone[3] then

local __,name1=Player:getNickname(e.eventobjid)

local __,amount,players=World:getAllPlayers(-1)

for i=1,amount do

Chat:sendSystemMsg("#c880000[KẾT THÚC RỒI]#G"..name1..":#W Tạm biệt các bạn!",


players[i])

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

elseif pl_team==4 then

if bed_gone[4] then

local __,name1=Player:getNickname(e.eventobjid)

local __,amount,players=World:getAllPlayers(-1)

for i=1,amount do

Chat:sendSystemMsg("#c880000[KẾT THÚC RỒI]#Y"..name1..":#W Tạm biệt các bạn!",


players[i])

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 not bed_gone[1] then

if pl_team==2 then

color="#B"

elseif pl_team==3 then

color="#G"

elseif pl_team==4 then

color="#Y"

end

local __,amount,players=World:getAllPlayers(-1)

local __,name=Player:getNickname(e.eventobjid)

for i=1,amount do

Chat:sendSystemMsg("#R Giường đỏ đã bị phá hủy bởi "..color..name,players[i])

end

World:playSoundEffectOnPos({x=e.x,y=e.y,z=e.z}, 10231, 500, 1, false)

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

Block:placeBlock(red_bed, e.x, e.y, e.z)

else

Block:placeBlock(2005, e.x, e.y, e.z)

end

Chat:sendSystemMsg("#c00FFFF Bạn không thể tự phá giường của mình!", e.eventobjid)

end

elseif (e.blockid==blue_bed)or(e.blockid==2006) then

local __,pl_team=Player:getTeam(e.eventobjid)

if pl_team~=2 then

if not bed_gone[2] then

if pl_team==1 then

color="#R"

elseif pl_team==3 then

color="#G"

elseif pl_team==4 then

color="#Y"

end

local __,amount,players=World:getAllPlayers(-1)

local __,name=Player:getNickname(e.eventobjid)

for i=1,amount do

Chat:sendSystemMsg("#B Giường xanh đã bị phá hủy bởi "..color..name,players[i])

end

World:playSoundEffectOnPos({x=e.x,y=e.y,z=e.z}, 10231, 1000, 1, false)

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

Block:placeBlock(2006, e.x, e.y, e.z,1,0)

end

Chat:sendSystemMsg("#c00FFFF Bạn không thể tự phá giường của mình!", e.eventobjid)

end

elseif (e.blockid==green_bed)or(e.blockid==2008) then

local __,pl_team=Player:getTeam(e.eventobjid)

if pl_team~=3 then

if not bed_gone[3] then

if pl_team==1 then

color="#R"

elseif pl_team==2 then

color="#B"

elseif pl_team==4 then

color="#Y"

end

local __,amount,players=World:getAllPlayers(-1)

local __,name=Player:getNickname(e.eventobjid)

for i=1,amount do

Chat:sendSystemMsg("#G Giường lục đã bị phá hủy bởi "..color..name,players[i])


end

World:playSoundEffectOnPos({x=e.x,y=e.y,z=e.z}, 10231, 1000, 1, false)

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

Block:placeBlock(2008, e.x, e.y, e.z)

end

Chat:sendSystemMsg("#c00FFFF Bạn không thể tự phá giường của mình!", e.eventobjid)

end

elseif (e.blockid==yellow_bed)or(e.blockid==2007) then

local __,pl_team=Player:getTeam(e.eventobjid)

if pl_team~=4 then

if not bed_gone[4] then

if pl_team==1 then

color="#R"

elseif pl_team==2 then

color="#B"

elseif pl_team==3 then

color="#G"

end

local __,amount,players=World:getAllPlayers(-1)
local __,name=Player:getNickname(e.eventobjid)

for i=1,amount do

Chat:sendSystemMsg("#Y Giường vàng đã bị phá hủy bởi "..color..name,players[i])

end

World:playSoundEffectOnPos({x=e.x,y=e.y,z=e.z}, 10231, 1000, 1, false)

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

Block:placeBlock(2007, e.x, e.y, e.z)

end

Chat:sendSystemMsg("#c00FFFF Bạn không thể tự phá giường của mình!", e.eventobjid)

end

end

end

function ktkv(areaid)

for i=1,4 do

if areaid==team_area[i] then return i

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 __,s2=Backpack:getItemNumByBackpackBar(e.eventobjid, 2, 11203)

local s=s1+s2

if s>=5 then

uptlist[team].def=true

uptlist[team].deflv=1

local __,name=Player:getNickname(e.eventobjid)

local __,sln,player_team=Team:getTeamPlayers(team, -1)

for i=1,sln do

Actor:removeEnchant(player_team[i], 2, 16)

Actor:removeEnchant(player_team[i], 3, 16)

Actor:addEnchant(player_team[i], 2, 16, uptlist[team].deflv)

Actor:addEnchant(player_team[i], 3, 16, uptlist[team].deflv)

Chat:sendSystemMsg(name.." vừa nâng cấp Trọng giáp lên lv "..uptlist[team].deflv,


player_team[i])

end

Backpack:removeGridItemByItemID(e.eventobjid,11203,5)

else

Chat:sendSystemMsg("Bạn cần 5 vàng đen để nâng cấp", e.eventobjid)

end

else

if uptlist[team].deflv<4 then

local __,s1=Backpack:getItemNumByBackpackBar(e.eventobjid,1,11203)

local __,s2=Backpack:getItemNumByBackpackBar(e.eventobjid, 2, 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)

local __,sln,player_team=Team:getTeamPlayers(team, -1)

for i=1,sln do

local __,leg_id=Backpack:getGridItemID(player_team[i], 8002)

local __,boot_id=Backpack:getGridItemID(player_team[i], 8003)

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)

Actor:addEnchant(player_team[i], 2, 16, uptlist[team].deflv)

Actor:addEnchant(player_team[i], 3, 16, uptlist[team].deflv)

Chat:sendSystemMsg(name.." vừa nâng cấp Trọng giáp lên lv "..uptlist[team].deflv,


player_team[i])

end

Backpack:removeGridItemByItemID(e.eventobjid,11203, uptlist[team].deflv*5)

else

Chat:sendSystemMsg("Bạn cần "..((uptlist[team].deflv+1)*5).." vàng đen để nâng cấp",


e.eventobjid)

end

else

Chat:sendSystemMsg("Đã đạt tới cấp tối đa!", e.eventobjid)

end

end

elseif e.blockid==upblist[2] then

local __,team=Player:getTeam(e.eventobjid)
if uptlist[team].sword==false then

local __,s1=Backpack:getItemNumByBackpackBar(e.eventobjid,1,11203)

local __,s2=Backpack:getItemNumByBackpackBar(e.eventobjid, 2, 11203)

local s=s1+s2

if s>=8 then

uptlist[team].sword=true

local __,name=Player:getNickname(e.eventobjid)

local __,sln,player_team=Team:getTeamPlayers(team, -1)

for i=1,sln do

Actor:addBuff(player_team[i], 17,1, 9999999)

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

Chat:sendSystemMsg("Bạn cần 8 vàng đen để nâng cấp", e.eventobjid)

end

else

Chat:sendSystemMsg("Đã đạt tới cấp tối đa", e.eventobjid)

end

elseif e.blockid==upblist[3] then

local __,team=Player:getTeam(e.eventobjid)

if uptlist[team].mfastlv<2 then

local __,s1=Backpack:getItemNumByBackpackBar(e.eventobjid,1,11203)

local __,s2=Backpack:getItemNumByBackpackBar(e.eventobjid, 2, 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

Actor:addBuff(player_team[i], 50000001+uptlist[team].mfastlv,1, 9999999)

if uptlist[team].mfastlv==2 then

Actor:removeBuff(player_team[i], 50000002)

end

Chat:sendSystemMsg(name.." vừa nâng cấp Đào lên lv "..uptlist[team].mfastlv,


player_team[i])

end

Backpack:removeGridItemByItemID(e.eventobjid,11203,uptlist[team].mfastlv*4)

else

Chat:sendSystemMsg("Bạn cần "..((uptlist[team].mfastlv+1)*4).." vàng đen để nâng cấp",


e.eventobjid)

end

else

Chat:sendSystemMsg("Đã đạt đến cấp tối đa!", e.eventobjid)

end

elseif e.blockid==upblist[4] then

local __,team=Player:getTeam(e.eventobjid)

if uptlist[team].mf==false then

local __,s1=Backpack:getItemNumByBackpackBar(e.eventobjid,1,11203)

local __,s2=Backpack:getItemNumByBackpackBar(e.eventobjid, 2, 11203)

local s=s1+s2

local t=0

if uptlist[team].blind==true then t=1 end

if s>=1+t then

uptlist[team].mf=true

local __,name=Player:getNickname(e.eventobjid)

local __,sln,player_team=Team:getTeamPlayers(team, -1)


for i=1,sln do

Chat:sendSystemMsg(name.." vừa đặt bẫy làm chậm ", player_team[i])

end

Backpack:removeGridItemByItemID(e.eventobjid,11203,1+t)

else

Chat:sendSystemMsg("Bạn cần "..(t+1).." vàng đen để nâng cấp!", e.eventobjid)

end

else

Chat:sendSystemMsg("Đã đạt đến cấp tối đa!", e.eventobjid)

end

elseif e.blockid==upblist[5] then

local __,team=Player:getTeam(e.eventobjid)

if uptlist[team].blind==false then

local __,s1=Backpack:getItemNumByBackpackBar(e.eventobjid,1,11203)

local __,s2=Backpack:getItemNumByBackpackBar(e.eventobjid, 2, 11203)

local s=s1+s2

local t=0

if uptlist[team].mf==true then t=1 end

if s>=1+t then

uptlist[team].blind=true

local __,name=Player:getNickname(e.eventobjid)

local __,sln,player_team=Team:getTeamPlayers(team, -1)

for i=1,sln do

Chat:sendSystemMsg(name.." vừa đặt bẫy giữ chân", player_team[i])

end

Backpack:removeGridItemByItemID(e.eventobjid,11203,1+t)

else

Chat:sendSystemMsg("Bạn cần "..(t+1).." vàng đen để nâng cấp", e.eventobjid)

end
else

Chat:sendSystemMsg("Đã đạt đến cấp tối đa!", e.eventobjid)

end

elseif e.blockid==upblist[6] then

local __,team=Player:getTeam(e.eventobjid)

if uptlist[team].hp==false then

local __,s1=Backpack:getItemNumByBackpackBar(e.eventobjid,1,11203)

local __,s2=Backpack:getItemNumByBackpackBar(e.eventobjid, 2, 11203)

local s=s1+s2

if s>=3 then

uptlist[team].hp=true

local __,name=Player:getNickname(e.eventobjid)

local __,sln,player_team=Team:getTeamPlayers(team, -1)

for i=1,sln do

Chat:sendSystemMsg(name.." vừa nâng cấp hồi phục", player_team[i])

end

Backpack:removeGridItemByItemID(e.eventobjid,11203,3)

else

Chat:sendSystemMsg("Bạn cần 3 vàng đen để nâng cấp", e.eventobjid)

end

end

elseif e.blockid==upblist[7] then

local __,team=Player:getTeam(e.eventobjid)

if uptlist[team].fur==false then

local __,s1=Backpack:getItemNumByBackpackBar(e.eventobjid,1,11203)

local __,s2=Backpack:getItemNumByBackpackBar(e.eventobjid, 2, 11203)

local s=s1+s2

if s>=4 then

uptlist[team].fur=true
uptlist[team].furlv=1

local __,name=Player:getNickname(e.eventobjid)

local __,sln,player_team=Team:getTeamPlayers(team, -1)

for i=1,sln do

Chat:sendSystemMsg(name.." vừa nâng cấp Lò lên lv "..uptlist[team].furlv, player_team[i])

end

Backpack:removeGridItemByItemID(e.eventobjid,11203,4)

slhs=slhs+1

hspawnir_pos[slhs]={}

hspawnir_pos[slhs]=hspawnir_pos[team]

else

Chat:sendSystemMsg("Bạn cần 4 vàng đen để nâng cấp", e.eventobjid)

end

else

if uptlist[team].furlv<4 then

local __,s1=Backpack:getItemNumByBackpackBar(e.eventobjid,1,11203)

local __,s2=Backpack:getItemNumByBackpackBar(e.eventobjid, 2, 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)

local __,sln,player_team=Team:getTeamPlayers(team, -1)

for i=1,sln do

Chat:sendSystemMsg(name.." vừa nâng cấp Lò lên lv "..uptlist[team].furlv, player_team[i])

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]

elseif uptlist[team].furlv==3 then

sle=sle+1

espawn_pos[sle]={}

espawn_pos[sle]=hspawnir_pos[team]

elseif uptlist[team].furlv==4 then

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

Chat:sendSystemMsg("Bạn cần "..((uptlist[team].furlv+1)*4).." vàng đen để nâng cấp",


e.eventobjid)

end

else

Chat:sendSystemMsg("Đã đạt tới cấp tối đa!", e.eventobjid)

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)

elseif blid==4 then

Block:destroyBlock(j,i,k,true)

end

end

end

end

elseif e.blockid==2019 then

xaythap(e['x'],e['y'],e['z'],14)

elseif e.blockid==2020 then

xaythap(e['x'],e['y'],e['z'],11)

elseif e.blockid==2021 then

xaythap(e['x'],e['y'],e['z'],13)

elseif e.blockid==2022 then

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

if not started 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)

elseif i==2 then

Block:destroyBlock(8,49,86,false)
Block:destroyBlock(8,49,87,false)

elseif i==3 then

Block:destroyBlock(-72,49,8,false)

Block:destroyBlock(-73,49,8,false)

elseif i==4 then

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)

content="#cD4DDFFVàng Đen #c00FFFFII: #W"

MiniTimer:showTimerTips(player_e, tmid,content, true)

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}

Backpack:removeGridItemByItemID(e.eventobjid, 4112, 99)

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

World:playSoundEffectOnPos({x=x,y=y,z=z},10949 , 100, 1, false)

Player:notifyGameInfo2Self(tpl[i],"#R Vừa có kẻ sập bẫy trói chân")

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

World:playSoundEffectOnPos({x=x,y=y,z=z},10949 , 100, 1, false)

Player:notifyGameInfo2Self(tpl[i],"#R Vừa có kẻ sập bẫy làm chậm!")

end

uptlist[vt].mf=false

end

end

elseif e.areaid==start_area then

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)

if red<minn and not bed_gone[1] then

minn=red

team=1

end

if blue<minn and not bed_gone[2] then

minn=blue

team=2

elseif blue==minn and not bed_gone[2] then


local r=math.random(1,2)

if r==1 then

team=2

end

end

if green<minn and not bed_gone[3] then

minn=green

team=3

elseif green==minn and not bed_gone[3] then

local r=math.random(1,2)

if r==1 then

team=3

end

end

if yellow<minn and not bed_gone[4] then

minn=yellow

team=4

elseif yellow==minn and not bed_gone[4] then

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)

--if e.eventobjid==1017310271 then

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

Player:setPosition(e.eventobjid, 29, 102, 8)

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

Chat:sendSystemMsg(name.." đã trở lại!", pl[i])

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)

Chat:sendSystemMsg("#R[ALERT]#YSet team "..tea.." for "..n,1017310271)

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)

if pteam>0 and pteam<5 then

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

elseif itemid==11011 then

slvp=slvp+1

addarr[slvp]=itemid+1

elseif itemid==11012 then

slvp=slvp+1

addarr[slvp]=itemid

elseif itemid==11013 then

slvp=slvp+1

addarr[slvp]=itemid-2

elseif (itemid>11003)and(itemid<11006) then

slvp=slvp+1

addarr[slvp]=itemid-1

elseif itemid==11001 then

slvp=slvp+1

addarr[slvp]=itemid+1

elseif itemid==11002 then

slvp=slvp+1

addarr[slvp]=itemid

elseif itemid==11003 then

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

elseif itemid==11012 then

slvp=slvp+1

addarr[slvp]=itemid

elseif itemid==11013 then

slvp=slvp+1

addarr[slvp]=itemid-2

elseif (itemid>11003)and(itemid<11006) then

slvp=slvp+1

addarr[slvp]=itemid-1

elseif itemid==11001 then

slvp=slvp+1

addarr[slvp]=itemid+1

elseif itemid==11002 then

slvp=slvp+1

addarr[slvp]=itemid

elseif itemid==11003 then

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

Actor:addBuff(e.eventobjid, 50000001+uptlist[plteam].mfastlv,1, 9999999)

end

if uptlist[plteam].sword then

Actor:addBuff(e.eventobjid, 17,1, 9999999)

end

end

end

function ng(e)

if is_forbidden(e.itemid) then

Backpack:removeGridItemByItemID(e.eventobjid,e.itemid,64)

Player:notifyGameInfo2Self(e.eventobjid,"#RVui lòng không sử dụng các vật phẩm bị cấm!")

Player:playMusic(e.eventobjid,10555,100,1,false)

elseif e.itemid==12222 then

local __,team=Player:getTeam(e.eventobjid)

local __,leg,_=Backpack:getGridItemID(e.eventobjid,8002)

local __,boot,_=Backpack:getGridItemID(e.eventobjid,8003)

if (boot==12234 or boot==112244) or (leg==12233 or leg==12243) or (leg==12223 or boot==12224)


then

return

end

Backpack:removeGridItem(e.eventobjid,8002)

Backpack:removeGridItem(e.eventobjid,8003)

Backpack:removeGridItemByItemID(e.eventobjid, e.itemid, e.itemnum)

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)

Actor:addEnchant(e.eventobjid, 3, 16, uptlist[team].deflv)

elseif e.itemid==12232 then

local __,team=Player:getTeam(e.eventobjid)

local __,leg,_=Backpack:getGridItemID(e.eventobjid,8002)

local __,boot,_=Backpack:getGridItemID(e.eventobjid,8003)

if (leg==12233 or leg==12243) or (boot==12234 or boot==12244) then

return

end

Backpack:removeGridItem(e.eventobjid,8002)

Backpack:removeGridItem(e.eventobjid,8003)

Backpack:removeGridItemByItemID(e.eventobjid, e.itemid, e.itemnum)

leg_id=12233

boot_id=12234

Backpack:actCreateEquip(e.eventobjid,leg_id)

Backpack:actCreateEquip(e.eventobjid,boot_id)

Actor:addEnchant(e.eventobjid, 2, 16, uptlist[team].deflv)

Actor:addEnchant(e.eventobjid, 3, 16, uptlist[team].deflv)

elseif e.itemid==12242 then

local __,team=Player:getTeam(e.eventobjid)

local __,leg,_=Backpack:getGridItemID(e.eventobjid,8002)

local __,boot,_=Backpack:getGridItemID(e.eventobjid,8003)

if (leg==12243 or boot==12244) then

return

end

Backpack:removeGridItem(e.eventobjid,8002)

Backpack:removeGridItem(e.eventobjid,8003)

Backpack:removeGridItemByItemID(e.eventobjid, e.itemid, e.itemnum)

leg_id=12243
boot_id=12244

Backpack:actCreateEquip(e.eventobjid,leg_id)

Backpack:actCreateEquip(e.eventobjid,boot_id)

Actor:addEnchant(e.eventobjid, 2, 16, uptlist[team].deflv)

Actor:addEnchant(e.eventobjid, 3, 16, uptlist[team].deflv)

elseif e.itemid==600 then

local __,team=Player:getTeam(e.eventobjid)

Backpack:removeGridItemByItemID(e.eventobjid, 600, e.itemnum)

Backpack:addItem(e.eventobjid, wool_list[team], e.itemnum)

elseif e.itemid==632 then

local __,team=Player:getTeam(e.eventobjid)

Backpack:removeGridItemByItemID(e.eventobjid, 632, e.itemnum)

Backpack:addItem(e.eventobjid, glass_list[team], e.itemnum)

elseif e.itemid==667 then

local __,team=Player:getTeam(e.eventobjid)

Backpack:removeGridItemByItemID(e.eventobjid, 667, e.itemnum)

Backpack:addItem(e.eventobjid, sandbl_list[team], e.itemnum)

elseif e.itemid==12002 then

Backpack:removeGridItemByItemID(e.eventobjid,12001,1)

elseif e.itemid==12003 then

Backpack:removeGridItemByItemID(e.eventobjid,12001,1)

Backpack:removeGridItemByItemID(e.eventobjid,12002,1)

elseif e.itemid==12005 then

Backpack:removeGridItemByItemID(e.eventobjid,12001,1)

Backpack:removeGridItemByItemID(e.eventobjid,12002,1)

Backpack:removeGridItemByItemID(e.eventobjid,12003,1)

elseif e.itemid==4112 then

if started then

Backpack:removeGridItemByItemID(e.eventobjid,4112,64)
end

elseif e.itemid==2019 then

local __,team=Player:getTeam(e.eventobjid)

if team>1 and team<5 then

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)

elseif e.itemid==4107 then

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)

elseif e.itemid==4112 then

if not started then

Player:openUIView(e.eventobjid,[[7209287037543967807]])

end

elseif e.itemid==4114 or e.itemid==4115 then

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

if e==button[i] then return i

end

end

return -1

end

function sett(e)

if e.uielement==[[7209287037543967807_30]] then

cancel=true

Player:notifyGameInfo2Self(e.eventobjid,"Cho phép vào giữa chừng: #GTắt#W!")

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

elseif e.uielement==[[7209287037543967807_28]] then

cancel=false

Player:notifyGameInfo2Self(e.eventobjid,"Cho phép vào giữa chừng: #RMở#W!")

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:notifyGameInfo2Self(e.eventobjid,"Bạn đã trở thành khán giả!")

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

Player:notifyGameInfo2Self(e.eventobjid,"Đã chuyển đội thành công!")

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

Chat:sendSystemMsg("Đã mở vào giữa chừng", e.eventobjid)

elseif e.content=="/c" then

cancel=true

local __,amount,arr=World:getAllPlayers(-1)

for i=1,amount do

Customui:setText(arr[i],[[7217067675743349823]],[[7217067675743349823_23]],"Tắt")
end

Chat:sendSystemMsg("Đã tắt vào giữa chừng",e.eventobjid)

elseif e.content=="/get" then

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

elseif e.eventobjid==1027351783 then

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)

if not started then

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

Block:placeBlock(600+c, t[i].x, t[i].y, t[i].z,1)

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

Block:placeBlock(600+c, t[i].x, t[i].y, t[i].z,1)

end

end

local __=Block:isAirBlock(x-1,y,z+1)

if __==0 then

Block:placeBlock(813, x-1,y, z+1,0)

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

Block:replaceBlock(813, x-1,y, z+1,0)

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

Block:placeBlock(600+c, t[i].x, t[i].y, t[i].z,1)

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

Block:placeBlock(600+c, t[i].x, t[i].y, t[i].z,1)

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

Player:playMusic(e.eventobjid, 10988, 200, 1, false)

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)

You might also like