Hey, I was sent some code, but it doesn't work. Anyone able to help. I can leave a vouch/rep as payment if you can.
The aim of the code was to give you nightvision when you enter /light and turn it off when you enter /dark
The aim of the code was to give you nightvision when you enter /light and turn it off when you enter /dark
var nightvisionmode;
function dark() {
nightvisionmode = false;
}
function light() {
nightvisionmode = true;
}
function main() {
nightvisionmode.setdefault(false);
events.when("player.PlayerCommandPreprocessEvent", function(info) {
var args = info.getMessage().slice(1).split(" ");
var STRIP_COMMENTS = /((//.*$)|(/*[sS]*?*/))/mg;
var ARGUMENT_NAMES = /([^s,]+)/g;
function getParamNames(func) {
var fnStr = func.toString().replace(STRIP_COMMENTS, "");
var result = fnStr.slice(fnStr.indexOf("(")+1, fnStr.indexOf(")")).match(ARGUMENT_NAMES);
if(result === null)
result = [];
return result;
}
var expected_args = getParamNames(((light)));
if (args.length != expected_args.length) {
info.getPlayer().sendMessage("Expected command arguments: "+expected_args);
return;
}
if (args[0].toUpperCase() == '/light'.toUpperCase())
((light)).apply(this, [info.getPlayer(), args.slice(1)]);
}, me);
events.when("player.PlayerCommandPreprocessEvent", function(info) {
var args = info.getMessage().slice(1).split(" ");
var STRIP_COMMENTS = /((//.*$)|(/*[sS]*?*/))/mg;
var ARGUMENT_NAMES = /([^s,]+)/g;
function getParamNames(func) {
var fnStr = func.toString().replace(STRIP_COMMENTS, "");
var result = fnStr.slice(fnStr.indexOf("(")+1, fnStr.indexOf(")")).match(ARGUMENT_NAMES);
if(result === null)
result = [];
return result;
}
var expected_args = getParamNames(((dark)));
if (args.length != expected_args.length) {
info.getPlayer().sendMessage("Expected command arguments: "+expected_args);
return;
}
if (args[0].toUpperCase() == '/dark'.toUpperCase())
((dark)).apply(this, [info.getPlayer(), args.slice(1)]);
}, me);
while (nightvisionmode == true) {
(me).addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION,20,10 ));
}
}
function dark() {
nightvisionmode = false;
}
function light() {
nightvisionmode = true;
}
function main() {
nightvisionmode.setdefault(false);
events.when("player.PlayerCommandPreprocessEvent", function(info) {
var args = info.getMessage().slice(1).split(" ");
var STRIP_COMMENTS = /((//.*$)|(/*[sS]*?*/))/mg;
var ARGUMENT_NAMES = /([^s,]+)/g;
function getParamNames(func) {
var fnStr = func.toString().replace(STRIP_COMMENTS, "");
var result = fnStr.slice(fnStr.indexOf("(")+1, fnStr.indexOf(")")).match(ARGUMENT_NAMES);
if(result === null)
result = [];
return result;
}
var expected_args = getParamNames(((light)));
if (args.length != expected_args.length) {
info.getPlayer().sendMessage("Expected command arguments: "+expected_args);
return;
}
if (args[0].toUpperCase() == '/light'.toUpperCase())
((light)).apply(this, [info.getPlayer(), args.slice(1)]);
}, me);
events.when("player.PlayerCommandPreprocessEvent", function(info) {
var args = info.getMessage().slice(1).split(" ");
var STRIP_COMMENTS = /((//.*$)|(/*[sS]*?*/))/mg;
var ARGUMENT_NAMES = /([^s,]+)/g;
function getParamNames(func) {
var fnStr = func.toString().replace(STRIP_COMMENTS, "");
var result = fnStr.slice(fnStr.indexOf("(")+1, fnStr.indexOf(")")).match(ARGUMENT_NAMES);
if(result === null)
result = [];
return result;
}
var expected_args = getParamNames(((dark)));
if (args.length != expected_args.length) {
info.getPlayer().sendMessage("Expected command arguments: "+expected_args);
return;
}
if (args[0].toUpperCase() == '/dark'.toUpperCase())
((dark)).apply(this, [info.getPlayer(), args.slice(1)]);
}, me);
while (nightvisionmode == true) {
(me).addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION,20,10 ));
}
}
