用户:
ABS寄予清风NotFound查看:155 回复:6 评论:35 创建时间:2020-02-24T17:52:21
function isAdmin(playerName) {if (['送寒声'].indexOf(playerName) !== -1) {return true;} else {return false;}}
world.onPlayerJoin(({entity}) => {
world.say(entity.player.name + '\n欢迎来到~')
entity.player.enableDamage = true
entity.player.showHealthBar = true
entity.player.dam = 7.5
entity.player.maxHp = 200
entity.player.hp = 175
entity.player.enableActionA = true
if (isAdmin(entity.player.name)) {
entity.player.canFly = true
}
world.onPress(({button, raycast:{hitEntity, direction}}) =>{
if (!button !== 'action0' && !action0Button || !hitEntity || isAdmin(hitEntity.player.name)) {
return;
}
hitEntity.player.velocity.x += direction.x
hitEntity.player.velocity.y += 0.5
hitEntity.player.velocity.z += direction.z
hitEntity.hurt(entity.dam, {
attacker: entity,
})
})
})
world.onChat(({entity, message}) => {
if(entity.isPlayer) {
if (isAdmin(entity.player.name)) {
if (message === 'cq1') {
entity.player.spectator = true
} else if (message === 'cq0') {
entity.player.spectator = false
}
}
}
})
world.onDie(({entity, attacker}) => {
(async function() {
if (attacker) {
world.say(attacker.player.name + ' 击杀了 ' + entity.player.name)
}
await sleep(75000)
entity.player.forceRespawn()
})()
})
world.querySelectorAll('.test').enableDamage = true;
哪个大神检查一下错误?
检查不出······
沙发(不要让我自己占好不好~)
点赞0
评论
the last line try to use foreach
maybe jquery returns a list
按照这个改了。
?!
Yeah to follow my idea do you try?if you can't understand,you can translate!
foreach(x){}
it will return a list so we are going to ergodic it with foreach
uh maybe you can understand this 翻译
我按这个改了啊,在置顶。jQuery怎么了?我按照你的forEach啦
o....ok.....I mean this is like a jQuery function it will return a list
在置顶啊,are you American or English?
ok ok we can stop talk about this LOL
I'm from Hyrule
ok,我在置顶修改了forEach,但是问题出在world.onChat里的entity.isPlayer
Ok
See you
Can you correct the mistake
I'll try
thanks
umm.......try if(entity.isPlayer === true){}
oh,console output: TypeError:Cannot read property 'isPlayer' of undefined at world.onChat (index.js:26:14)
芜湖咸鱼没有检查出语法错误
点赞0
评论
TypeError:Cannot read property 'isPlayer' of undefined at world.onChat (index.js:26:14)
怎么回事?
置顶代码的控制台输出
Maybe.......
what
因为系统会说话,但是系统不是实体,所以没有isplayer属性
你应该在那里加上一句if(!entity){return}
好的 谢谢
要不要我地图编辑?
能不能帮我做一下地图
感谢shyfcka!
代码已经没有错误了!
function isAdmin(playerName) {if (['送寒声'].indexOf(playerName) !== -1) {return true;} else {return false;}}
world.onPlayerJoin(({entity}) => {
world.say(entity.player.name + '\n欢迎来到~')
entity.player.enableDamage = true
entity.player.showHealthBar = true
entity.player.dam = 7.5
entity.player.maxHp = 200
entity.player.hp = 175
entity.player.enableActionA = true
if (isAdmin(entity.player.name)) {
entity.player.canFly = true
}
world.onPress(({button, raycast:{hitEntity, direction}}) =>{
if (!button !== 'action0Button' || !hitEntity || isAdmin(hitEntity.player.name)) {
return;
}
hitEntity.player.velocity.x += direction.x
hitEntity.player.velocity.y += 0.5
hitEntity.player.velocity.z += direction.z
hitEntity.hurt(entity.dam, {
attacker: entity,
})
})
})
world.onChat(({entity, message}) => {
if(entity && entity.isPlayer) {
if (isAdmin(entity.player.name)) {
if (message === 'cq1') {
entity.player.spectator = true
} else if (message === 'cq0') {
entity.player.spectator = false
}
}
}
})
world.onDie(({entity, attacker}) => {
(async function() {
if (attacker) {
world.say(attacker.player.name + ' 击杀了 ' + entity.player.name)
}
await sleep(75000)
entity.player.forceRespawn()
})()
})
world.querySelectorAll('.test').forEach((e) => e.enableDamage = true)点赞0
评论