Help fixing short code?

Status
This thread has been locked.

Kraezler

|Artist|Bot Dev|Animator|
Supreme
Feedback score
43
Posts
798
Reactions
246
Resources
0
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
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 ));
}
}
 
PebbleHost
High performance, consistent uptime and fast support. Minecraft hosting that just works.

Kraezler

|Artist|Bot Dev|Animator|
Supreme
Feedback score
43
Posts
798
Reactions
246
Resources
0

Kraezler

|Artist|Bot Dev|Animator|
Supreme
Feedback score
43
Posts
798
Reactions
246
Resources
0

Hoknee

Minecraft Server Owner
Premium
Feedback score
5
Posts
156
Reactions
36
Resources
0
This is some very messy code, like some of this code is actually useless.
 

Kraezler

|Artist|Bot Dev|Animator|
Supreme
Feedback score
43
Posts
798
Reactions
246
Resources
0

sores

MineBOI
Premium
Feedback score
5
Posts
305
Reactions
210
Resources
0
So much extra code not needed. Could have been so much simpler.
 

WristzPvP

Feedback score
1
Posts
138
Reactions
49
Resources
0
This is written in another programming language by the looks of it. To be honest I can't really tell as I didn't take a good look and it isn't formatted.
 

Marisa

that one nivia owner
Premium
Feedback score
16
Posts
170
Reactions
366
Resources
0
Thought Minecraft plugins had to be java?
 

Kraezler

|Artist|Bot Dev|Animator|
Supreme
Feedback score
43
Posts
798
Reactions
246
Resources
0
Got the code rewritten so closing thread
 
Status
This thread has been locked.
Top