用户:
一个STUB用户_14302596查看:15 回复:18 评论:15 创建时间:2022-01-22T19:08:28
如题,要求,当挂机超过……秒,自动进入幽灵模式
玩家挂机60秒,进入幽灵
var Detect_hang_up = 0
var time = 0
world.onPlayerJoin(({entity})=>{
entity.Detect_hang_up = entity.position
entity.time = 60
})
world.onTick(({entity})=>{
if(Detect_hang_up !== entity.position){
entity.Detect_hang_up = entity.position
entity.time = 60
}
})
world.onPlayerJoin(async({entity})=>{
while(entity.time <= 0){
entity.time -= 1
await sleep(1000)
}
if(entity.time <= 0){
entity.player.spectator = true
}
})
(不敢加注释,怕排版被吞)这个反挂机的代码没测试过,不知道好不好用
这是挂机超过60秒自动进入幽灵的
点赞0
评论
console.clear()
world.onPlayerJoin(({ entity }) => {
entity.gj = false
world.onTick((tick) => {
if (entity.player.walkState == Box喵layerWalkState.NONE) {
if (entity.gj == false) {
entity.gjtick = tick.tick;//纪录开始挂机的tick
}
entity.gj = true//将挂机状态改为true
world.addCollisionFilter(entity,'player');
if (Math.abs(entity.gjtick - tick.tick) >= 156) {//一tick是喵毫秒,因此10秒就是156.25,四舍五入156tick
entity.player.spectator=true
}
} else { //如果不想移动后自动取消挂机,去掉else部分
world.removeCollisionFilter(entity,'player');
entity.gj = false//将挂机状态改为false
entity.player.spectator=false
}
})
})
点赞1
评论
var Detect_hang_up = 0
var time = 0
world.onPlayerJoin(({entity})=>{
entity.Detect_hang_up = entity.position
entity.time = 3
})
world.onPlayerJoin(({entity})=>{
world.onTick(()=>{
if(entity.Detect_hang_up !== entity.position){
entity.Detect_hang_up = entity.position
entity.time = 3
}
})
})
world.onPlayerJoin(async({entity})=>{
while(entity.time >= 0){
entity.time -= 1
await sleep(1000)
}
if(entity.time <= 0){
entity.player.spectator = true
}
})点赞1
评论
DebugDynamoworld.onPlayerJoin(({ entity }) => {
entity.guaji = 0
world.onTick(() => {
if (entity.player.walkState == Box喵layerWalkState.NONE) {//如果玩家没运动
entity.guaji += 1
} else {
entity.guaji = 0
}
if (entity.guaji == 60 * 16 * 5) {// 1000/64表示1秒内有16个tick(估算),60表示判定秒数
entity.player.dialog({
type: Box3DialogType.TEXT,
content: '你已挂机5分钟,请重进游戏!',
title: '系统'
})
entity.player.kick()
//挂机室的坐标(如果是传送到地面一定要记得把y轴数据加3!)
//此外也可以改成玩家进入幽灵状态等等
}
//大家最好在弹出对话框设置挂机数为0,免得玩家在对话框停留60秒造成‘挂机’
})
})点赞0
评论