Allow me to clarify exactly what I'm doing.
When the player presses 'a', the player creates an NPC that I'm using as a damage block. The NPC is functional through joining a class.
Perhaps it'd be easier to explain if I did step by step what I'm doing, so I can get some better, more specific advice.
1. Player presses 'A' and creates the "damage block" NPC.
This is the code from the Weapon
PHP Code:
function onActionServerSide(){
if (params[0] == "dmgblock"){
temp.npc = this.level.putNPC2(player.x, player.y, "");
temp.npc.join("damageblock");
}
}
//#CLIENTSIDE
function onKeyPressed(code, key){
if (key == "c"){
player.chat = "Placed!";
triggerserver("weapon", this.name, "dmgblock");
}
}
I realize the placement with the x and y is off and the player will collide instantly within placing. Ignore that.
2. The NPC preforms it's function, then deletes
This is where I'm Having issues. I need the block to destroy serverside.
This is the script from the CLASS it joined
PHP Code:
function onActionServerside(){
if (params[0] == "destroy"){
destroy();
}
}
//#CLIENTSIDE
function onCreated(){
dontblock();
setImg("block.png");
onTimeOut();
scheduleEvent(1, "onDestroy");
}
function onTimeOut(){
if (player.x in |this.x, this.x + 2| && player.y in |this.y, this.y + 2|) {
player.chat = "HIT";}
//Trigger Actions in the player to make him lose HP and Whatever else
setTimer(0.05);
}
function onDestroy(){
triggerAction("npc", this.name, "destroy");
}