I'm a pretty simple ModPE scripter, and some functions I could never understand how to return the value and or string. This one script I have been working on, I could never figure out how to produce the function on my liking. Please explain on what I am doing wrong.
The script is suppose to tell where the player has died, plus summon lightning in which destroys their items. (I am working on a hardcore modscript pack)
Here's my code: (Please don't steal)
function newLevel() {
clientMessage("§3[AquaPack] §6Death Post Installed Successfully!");
}
function modTick() {
var hp = Entity.getHealth(Player.getEntity)
if (hp == 0);
Level.spawnMob(getPlayerX(), getPlayerY(), getPlayerZ(),EntityType.LIGHTNING_BOLT);
clientMessage("§6Player Died at:");
clientMessage("X: " + Math.round(Player.getX()))
clientMessage("Y: " + Math.round(Player.getY()))
clientMessage("Z: " + Math.round(Player.getX()))
}
@Aqil787 After changing the code so that it suits your format, it still for some reason doesn't spawn lightning when your health is 0. Also, for some weird reason it spams, "Player Died at:" even when the health isn't at 0. Is there a function for getting the player health rather than a variable?
@Aqil787 After changing the code so that it suits your format, it still for some reason doesn't spawn lightning when your health is 0. Also, for some weird reason it spams, "Player Died at:" even when the health isn't at 0. Is there a function for getting the player health rather than a variable?
Okay so it is not my bad coding skills? What about this attempt as in it spawns in a minecart with the rendertype of a lightning bolt?
var mctolt = Level.spawnMob(getPlayerX(),getPlayerY()-2,getPlayerZ(),EntityType.MINECART);
var dead = null
function deathHook(attacker, victim) {
if(victim == Player.getEntity()) {
dead = true;
}
}
function modTick() {
if (dead == true) {
Entity.setRenderType(mctolt,EntityRenderType.lightningBolt);
clientMessage("§6Player Died at:");
clientMessage("X: " + Math.round(Player.getX()))
clientMessage("Y: " + Math.round(Player.getY()))
clientMessage("Z: " + Math.round(Player.getX()))
dead = false;
} else {
}
}
To make it kill the player. Change it to:
var mctolt = Level.spawnMob(getPlayerX(),getPlayerY()-2,getPlayerZ(),EntityType.MINECART);
var dead = null; //Forgot ';' On the end.
//Maybe this here:
Player.setHealth(0); //Kills Player.
function deathHook(attacker, victim) {
if(victim == Player.getEntity()) {
dead = true;
}
}
function modTick() {
if (dead == true) {
Entity.setRenderType(mctolt,EntityRenderType.lightningBolt);
clientMessage("§6Player Died at:");
clientMessage("X: " + Math.round(Player.getX()))
clientMessage("Y: " + Math.round(Player.getY()))
clientMessage("Z: " + Math.round(Player.getX()))
dead = false;
} else {
}
}
Rollback Post to RevisionRollBack
Here to help.
Minecraft: Pocket Edition Modder, Web Developer. Plugin creator!
After Trying it out, it appears that the lightning bolt only appears when I first join the world, and re-install the script. So as neither does the client message. Why does it seem that it doesn't spawn when a function modTick() { is present?
The Meaning of Life, the Universe, and Everything.
Location:
Malaysia
Join Date:
10/13/2012
Posts:
47
Minecraft:
Aqil787
Member Details
It's whether mcpe or blocklauncher problem that lightning bolt not spawning if we not rejoin the world. I suggest you to use other than lightning bolt to destroy the item like explosion maybe?
I'm a pretty simple ModPE scripter, and some functions I could never understand how to return the value and or string. This one script I have been working on, I could never figure out how to produce the function on my liking. Please explain on what I am doing wrong.
The script is suppose to tell where the player has died, plus summon lightning in which destroys their items. (I am working on a hardcore modscript pack)
Here's my code: (Please don't steal)
This:
Should be like this:
@Aqil787 After changing the code so that it suits your format, it still for some reason doesn't spawn lightning when your health is 0. Also, for some weird reason it spams, "Player Died at:" even when the health isn't at 0. Is there a function for getting the player health rather than a variable?
@Aqil787 After changing the code so that it suits your format, it still for some reason doesn't spawn lightning when your health is 0. Also, for some weird reason it spams, "Player Died at:" even when the health isn't at 0. Is there a function for getting the player health rather than a variable?
actually, for now lightning somehow doesn't spawn when we use that EntityType.LIGHTNING_BOLT. But it will spawn if you rejoin the world.
About the code , you can try:
Okay so it is not my bad coding skills? What about this attempt as in it spawns in a minecart with the rendertype of a lightning bolt?
i think that will spawn but will not hurt or destroy player stuff.
Yes, it will set the Minecraft as Lightning Bolt, but will not hurt/kill the Player.
Here to help.
Minecraft: Pocket Edition Modder, Web Developer. Plugin creator!
Cheers!
To make it kill the player. Change it to:
Here to help.
Minecraft: Pocket Edition Modder, Web Developer. Plugin creator!
Cheers!
Thanks! I will try it out!
After Trying it out, it appears that the lightning bolt only appears when I first join the world, and re-install the script. So as neither does the client message. Why does it seem that it doesn't spawn when a function modTick() { is present?
It's whether mcpe or blocklauncher problem that lightning bolt not spawning if we not rejoin the world. I suggest you to use other than lightning bolt to destroy the item like explosion maybe?
Ok!
Here to help.
Minecraft: Pocket Edition Modder, Web Developer. Plugin creator!
Cheers!