Then i use that command i type /survivalflyon then its worked the i type /survivalflyoff then it use the function of /survivalflyon it still make we can fly in survival! how to fix it?
//You have to use arrays with numbers inside, to basically set were the word has to typed. Plus I'm sure a boolean is needed and not numbers inside the canFly(). Additionaly you will need the getGamemode so Blocklauncher doesn't crash. For the commands use, /survival fly on and /survival fly off.
//You have to use arrays with numbers inside, to basically set were the word has to typed. Plus I'm sure a boolean is needed and not numbers inside the canFly(). Additionaly you will need the getGamemode so Blocklauncher doesn't crash. For the commands use, /survival fly on and /survival fly off.
Thank you for answer it btw i had know how to fix it >< wilco375 said i must add == to cmd==("") or cmd=="" now i know what i'm doing wrong ><
You're using a modTick inside of another function, don't do that, instead set a global variable that is a Boolean which is changed using a command and then add a while statement in a modTick
Also don't use,
getPlayerX/Y/Z(); use Player.getX/Y/Z();
setTile(); use Level.setTile();
And having the cmd = cmd.toLowerCase(); is kind of pointless, so is var cmd = command.Split(" ");
var activated = false;
function procCmd(c){
if(c == "on"){
activated = true;
} else if (c == "off"){
activated = false;
}
}
function modTick(){
while(activated == true){
//code for setting the fire here
}
}
Happy to help but... yes they can, just not the way you are doing it
if you make a function then you can run it inside of another function like this
//this is a function
function msg(message){
clientMessage(message);
}
//and so is this
function newLevel(){
//and here we can run the msg function inside of this one
msg("Hello World");
}
//as you can see though, we don't need to put the word function before it, feel free to run this and see for yourself
also, you may not know it but, everything like ModPE.setItem(); are called object orientated functions (anything that has a dot like this: word.blahBlah(); is called an object), but we don't put function before them because that is all built in to block launcher so it recognises it
I don't think there is anything wrong with my code, it's just mc can't handle running the code, instead of using a while statement use an if statement
var activated = false;
function procCmd(c){
if(c == "on"){
activated = true;
} else if (c == "off"){
activated = false;
}
}
function modTick(){
if(activated == true){
//code for setting the fire here
}
}
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
example:
function procCmd(command) {
var cmd=command.split
if(cmd("survivalflyon")) {
Player.setCanFly(1);
}
if(cmd("survivalflyoff")) {
Player.setCanFly(0);
}
}
Then i use that command i type /survivalflyon then its worked the i type /survivalflyoff then it use the function of /survivalflyon it still make we can fly in survival! how to fix it?
Hope this helps! If it did press that like button
~MattDaveMatt
var survival = false;
function newLevel()
{
if(Level.getGameMode()==0)
{
survival = true;
}
}
function procCmd(command)
{
var cmd = command.split(" ");
if(cmd[0]=="survival"&&cmd[1]=="fly" & & cmd[2]=="on"&&survival)
{
Player.canFly(true);
}
if(cmd[0]=="survival"&&cmd[1]=="fly"&&cmd[2]=="off")
{
Player.canFly(false);
}
}
//Use this as well
function leaveGame()
{
if(survival)
{
survival = false;
}
}
//You have to use arrays with numbers inside, to basically set were the word has to typed. Plus I'm sure a boolean is needed and not numbers inside the canFly(). Additionaly you will need the getGamemode so Blocklauncher doesn't crash. For the commands use, /survival fly on and /survival fly off.
Thank you for answer it btw i had know how to fix it >< wilco375 said i must add == to cmd==("") or cmd=="" now i know what i'm doing wrong ><
Cool but I have code something too:
/*FireWalk*/
function procCmd(cmd){
cmd = cmd.toLowerCase();
if(cmd == "on"){
clientMessage("PowerEnabled!");
function modTick(){
setTile(getPlayerX(), getPlgyerY() -1, getPlayerZ(), 51);
}
}
}
function procCmd(cmd){
cmd = cmd.toLowerCase();
if(cmd == "off"){
clientMessage("PowerDisabled!");
function modTick(){
setTile(getPlayerX(), getPlayerY()-1, getPlayerZ(), 0);
}
}
}
//I have imported this is to block launcher and the block launcher didn't say it have problems.However when I type /on , /off .
It is not working and even crashed!!!
Can you help me please?
You're using a modTick inside of another function, don't do that, instead set a global variable that is a Boolean which is changed using a command and then add a while statement in a modTick
Also don't use,
getPlayerX/Y/Z(); use Player.getX/Y/Z();
setTile(); use Level.setTile();
And having the cmd = cmd.toLowerCase(); is kind of pointless, so is var cmd = command.Split(" ");
var activated = false; function procCmd(c){ if(c == "on"){ activated = true; } else if (c == "off"){ activated = false; } } function modTick(){ while(activated == true){ //code for setting the fire here } }Thank you so much =)
So function can't be used inside a function right?
lol
Happy to help but... yes they can, just not the way you are doing it
if you make a function then you can run it inside of another function like this
//this is a function function msg(message){ clientMessage(message); } //and so is this function newLevel(){ //and here we can run the msg function inside of this one msg("Hello World"); } //as you can see though, we don't need to put the word function before it, feel free to run this and see for yourself
also, you may not know it but, everything like ModPE.setItem(); are called object orientated functions (anything that has a dot like this: word.blahBlah(); is called an object), but we don't put function before them because that is all built in to block launcher so it recognises it
Wow thx so much dude you like a pro
But your code doesn't work :'(
I just add a few code at the last part
clientMessage("I am WORKING!");
//And then I type /on in block launcher.It crashed :'(
I change the above code to this:
setTile(getPlayerX(),getPlayerY(),getPlayer Z(), 50);
//when I type /on it still crashed.I think the var have some problems
I don't think there is anything wrong with my code, it's just mc can't handle running the code, instead of using a while statement use an if statement
var activated = false; function procCmd(c){ if(c == "on"){ activated = true; } else if (c == "off"){ activated = false; } } function modTick(){ if(activated == true){ //code for setting the fire here } }