mirror of
https://github.com/danbulant/flying-squid
synced 2026-06-23 16:52:05 +00:00
Add teleport ( aka. tp ) command.
This commit is contained in:
parent
843fdfb6fe
commit
01e0162d59
1 changed files with 52 additions and 0 deletions
52
src/lib/plugins/tp.js
Normal file
52
src/lib/plugins/tp.js
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
module.exports.player = (player, serv) => {
|
||||
player.commands.add({
|
||||
base: 'teleport',
|
||||
aliases: ['tp'],
|
||||
info: 'to teleport a player',
|
||||
usage: '/teleport [target player] <destination player or x> [x] [y]',
|
||||
parse(str) {
|
||||
return str.match(/^(((\w* )?\d* \d* \d*)|(\w* \w*))$/) ? str.split(' ') : false;
|
||||
},
|
||||
action(args) {
|
||||
if(args.length === 2 && args[0] !== args[1]) {
|
||||
let player_from;
|
||||
let player_to;
|
||||
|
||||
if(!(player_from = serv.getPlayer(args[0])) || !(player_to = serv.getPlayer(args[1])))
|
||||
return false;
|
||||
|
||||
player_from._client.write('position', {
|
||||
x: player_to.position.x/32,
|
||||
y: player_to.position.x/32,
|
||||
z: player_to.position.x/32,
|
||||
yaw: player_to.yaw,
|
||||
pitch: player_to.pitch,
|
||||
flags: 0x00
|
||||
});
|
||||
} else if(args.length === 3) {
|
||||
player._client.write('position', {
|
||||
x: args[0],
|
||||
y: args[1],
|
||||
z: args[2],
|
||||
yaw: player.yaw,
|
||||
pitch: player.pitch,
|
||||
flags: 0x00
|
||||
});
|
||||
} else if(args.length === 4) {
|
||||
let player_from;
|
||||
|
||||
if(!(player_from = serv.getPlayer(args[0])))
|
||||
return false;
|
||||
|
||||
player_from._client.write('position', {
|
||||
x: args[1],
|
||||
y: args[2],
|
||||
z: args[3],
|
||||
yaw: player_from.yaw,
|
||||
pitch: player_from.pitch,
|
||||
flags: 0x00
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
Loading…
Reference in a new issue