View Single Post
  #25  
Old 01-08-2014, 05:04 PM
callimuc callimuc is offline
ジ
callimuc's Avatar
Join Date: Nov 2010
Location: Germany
Posts: 1,015
callimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to behold
Weapon script:
changed your this.level.putNPC2(...) to player.level.putNPC2(...), this. would refer to the weapon while player. refers to the player)

PHP Code:
function onActionServerSide(){
  if (
params[0] == "dmgblock"){
    
temp.npc = player.level.putNPC2(player.x, player.y, ""); //should be player.level instead of this.level
    
temp.npc.join("damageblock");
  }
}

//#CLIENTSIDE
function onKeyPressed(code, key){
  if (
key == "c"){
    
player.chat = "Placed!";
    
triggerserver("weapon", this.name, "dmgblock");
  }
} 

Class script:
removed your dontBlock() as it needs to be a blocking NPC I believe
fixed your triggerAction()
and other stuff
PHP Code:
function onCreated() {
    
//1=blocking, 32=width in pixel, 32=height in pixel
  
setshape(1, 32, 32);
}

function 
onActionDestroyBlock() {
  
this.destroy();
}

//#CLIENTSIDE
function onCreated() {
  
setshape(1, 32, 32);
  
this.setImg("block.png");
  
onTimeOut();
}


function 
onTimeOut(){
    
//if player is within the square, trigger the actions
  
if (player.x in |this.x, this.x + 2| && player.y in |this.y, this.y + 2|) { 
    
player.chat = "HIT";
      
//stop the script and call the 'onDestroyObject()' function
    
return onDestroyObject();
  }
    
//keep running the script as the player hasnt been inside the block range yet
  
setTimer(0.05);
}

function 
onDestroyObject() {
    
//x, y, onAction...., parameters
  
triggerAction(this.x, this.y, "DestroyBlock", NULL);
} 
__________________
MEEP!
Reply With Quote