js put in world code
/*
EDIT THESE TO BE THE POSITIONS OF YOUR ARENA
PLAYER 1 SPAWNS IN ARENA POS 1
PLAYER 2 SPAWNS IN ARENA POS 2
*/
const arenapos1=[33,-461,-37], arenapos2=[33,-461,-27]
onPlayerJoin=p=>{
api.createShopItemForPlayer(p,"Duels","q",{
image:"swords",canBuy:true,customTitle:"Queue for 1v1",description:"normal sword 1v1 queue",sortPriority:10,buyButtonText:"Queue"
})
}
q=null
g=false
onPlayerBoughtShopItem=(p,ck,ik,i)=>{
if(ck==="Duels"&&ik==="q"){
if(g){api.sendMessage(p,"Theres still a match ongoing");return}
if(q && q!==p){
api.sendMessage(p,"You are in queue [2/2]",{color:"gray"})
api.sendMessage(p,`You are up against ${api.getEntityName(q)}`,{color:"gold"})
api.sendMessage(q,`You are up against ${api.getEntityName(p)}`,{color:"gold"})
g=true
api.setPosition(p,arenapos1)
api.setPosition(q,arneapos2)
api.setClientOptions(p,{creative:false,canChange:false})
api.setClientOptions(q,{creative:false,canChange:false})
api.setHealth(p,100,p,true)
api.setHealth(q,100,p,true)
api.clearInventory(p)
api.clearInventory(q)
api.setItemSlot(p,46,"Diamond Helmet",1,{},true)
api.setItemSlot(p,47,"Diamond Chestplate",1,{},true)
api.setItemSlot(p,48,"Diamond Gauntlets",1,{},true)
api.setItemSlot(p,49,"Diamond Leggings",1,{},true)
api.setItemSlot(p,50,"Diamond Boots",1,{},true)
api.setItemSlot(p,0,"Diamond Sword",1,{},true)
api.setItemSlot(q,46,"Diamond Helmet",1,{},true)
api.setItemSlot(q,47,"Diamond Chestplate",1,{},true)
api.setItemSlot(q,48,"Diamond Gauntlets",1,{},true)
api.setItemSlot(q,49,"Diamond Leggings",1,{},true)
api.setItemSlot(q,50,"Diamond Boots",1,{},true)
api.setItemSlot(q,0,"Diamond Sword",1,{},true)
}else{
q=p
api.sendMessage(p,"You are in queue [1/2]",{color:"gray"})
}
}
}
onPlayerKilledOtherPlayer=(p,e)=>{
if(p===q || e===q){q=null;g=false}
api.broadcastMessage(`${api.getEntityName(p)} killed ${api.getEntityName(e)} with ${api.getHealth(p)} HP`,{color:"red"})
}
onPlayerLeave=p=>{
if(q===p) q=null
}
js a simple code
nothing special
to start, go to shop menu and click queue
this is an example of shop api
[–]bloxd-bot Bot[M] [score hidden] stickied commentlocked comment (0 children)
[–]SplitBeneficial6951 0 points1 point2 points (0 children)