summaryrefslogtreecommitdiff
path: root/app.js
diff options
context:
space:
mode:
Diffstat (limited to 'app.js')
-rw-r--r--app.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/app.js b/app.js
index efee026..2252fb0 100644
--- a/app.js
+++ b/app.js
@@ -181,6 +181,47 @@ io.sockets.on('connection', function(socket){
socket.emit('addToChat', {ctimestamp: getTimeStamp(0), content: servermsg + "Player not found", tab: "any"});
break;
+ // @warp/@tele/@teleport (args:[map] [<x> <y>])
+ case "warp":
+ case "tele":
+ case "teleport":
+ hasPermission(socket.playerName, 60, function(res)
+ {
+ if(res)
+ {
+ if(command.length < 2 || command.length > 4){
+ socket.emit('addToChat', {ctimestamp: getTimeStamp(0), content: servermsg + escapeHTML("Wrong syntax: @warp [map] [<x> <y>]"), tab: "any"});
+ return;
+ }
+ else if(command.length == 2){
+ Player.Player.list[socket.id].map = command[1];
+ var new_x = Math.random()*500; // TODO: map size?!
+ var new_y = Math.random()*500;
+ Player.Player.list[socket.id].x = new_x;
+ Player.Player.list[socket.id].y = new_y;
+ socket.emit('addToChat', {ctimestamp: getTimeStamp(0), content: servermsg + "Warped to map:" + command[1] + " x:" + new_x + " y:" + new_y, tab: "any"});
+ }
+ else if(command.length == 3){ // only cords
+ // TODO: check if map exists
+ Player.Player.list[socket.id].x = parseInt(command[1]);
+ Player.Player.list[socket.id].y = parseInt(command[2]);
+ socket.emit('addToChat', {ctimestamp: getTimeStamp(0), content: servermsg + "Warped to x:" + command[1] + " y:" + command[2], tab: "any"});
+ }
+ else if(command.length == 4){ // map x y
+ // TODO: check if map exists
+ Player.Player.list[socket.id].map = command[1];
+ Player.Player.list[socket.id].x = parseInt(command[2]);
+ Player.Player.list[socket.id].y = parseInt(command[3]);
+ socket.emit('addToChat', {ctimestamp: getTimeStamp(0), content: servermsg + "Warped to map:" + command[1] + " x:" + command[2] + " y:" + command[3], tab: "any"});
+ }
+ }
+ else
+ {
+ socket.emit('addToChat', {ctimestamp: getTimeStamp(0), content: servermsg + "you dont have permission to use this command!", tab: "any"});
+ }
+ });
+ break;
+
// @setgm (args:<playername> <lvl>)
case "setgm":
hasPermission(socket.playerName, 99, function(res){