Thread: Bombs and Bows
View Single Post
  #16  
Old 05-19-2011, 06:49 PM
iBeatz iBeatz is offline
Kavan
iBeatz's Avatar
Join Date: Dec 2010
Location: Northern Ireland, UK
Posts: 154
iBeatz will become famous soon enough
Send a message via Yahoo to iBeatz
PHP Code:
function onCreated(){
  
setshape(1,32,32);   //Set the shape of the NPC serverside so the triggeractions work.
}

function 
onActionGiveBombs(bombrequest){   // Executing the GiveBombs action.
  
if((99 player.bombs) > bombrequest){
    
player.bombs += bombrequest;
    
player.chat "You received "@bombrequest SPC "bombs!";
  }
  else {
    
player.bombs += 99 player.bombs;
  }
}

function 
onActionGiveArrows(arrowrequest){   // Executing the GiveArrows action.
  
if((99-player.darts) > arrowrequest){
    
player.darts += arrowrequest;
    
player.chat "You received "@arrowrequest SPC "arrows!";
  }
  else {
    
player.darts += 99-player.darts;
  }
}

//#CLIENTSIDE

function onCreated(){
  
setshape(1,32,32);
}

function 
onPlayerChats(){
  
temp.tokens player.chat.tokenize();   // Tokenizing each word in the player's chat.
  
if(temp.tokens[0] > && temp.tokens[0] <= 99){   // Checking if the requested amount is more than 0 and less than or equal to 99.
    
if(temp.tokens[1] == "bombs"){   // Checking if the player asked for bombs or arrows.
      
triggeraction(this.x+.5,this.y+.5,"GiveBombs",temp.tokens[0]);   // Triggering the GiveBombs function on the serverside.
    
}
    else if(
temp.tokens[1] == "arrows"){
      
triggeraction(this.x+.5,this.y+.5,"GiveArrows",temp.tokens[0]);   // Triggering the GiveArrows function on the serverside.
    
}
  }

This script adds both bombs and arrows, depending on what the second word is in you chat. It works in a level NPC.
Bombs and arrows can only be added serverside, which is why the triggeractions are placed in the script.
Your welcome.
__________________

Intelligence without ambition is like a bird without wings.


Last edited by iBeatz; 05-19-2011 at 07:01 PM.. Reason: Error in script.
Reply With Quote