View Single Post
  #4  
Old 07-09-2011, 04:47 PM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
Quote:
Originally Posted by Gunderak View Post
could you show me an example of it as a trigger so i can study it and figure out exactly how itd work?
Well actually, if you're going to do it entirely by chat it would be better to just have the entire thing serverside rather than use a trigger, the main reason you'd want it clientside is to have something like a GUI prompt.

Otherwise the most basic thing to do would be:

PHP Code:
function onCreated(){
  
//define area inwhich to receive the triggeraction
  
this.setshape(1, 32, 32);
  
this.dontblock();
}

function 
onActionPurchase(){
  if (
player.rupees >= 1000){
    
//ensure you have not already purchased the hat
    
if(player.findweapon("Hats/Dino Hat") == NULL){
      
player.addweapon("Hats/Dino Hat");
      
player.rupees -= 1000;
    }
  }
}

//#CLIENTSIDE
function onPlayerChats() {
  if (
player.chat == "/Buy Gund Dino Hat"){
    if (
player.rupees >= 1000){
      
//ensure you have not already purchased the hat
      
if(findweapon("Hats/Dino Hat") == NULL){
        
triggeraction(this.x + 1, this.y + 1, "Purchase", NULL);
      }
    }
  }
} 
The conditions being serverside is important for the sake of security but I personally have it clientside too for the sake of preventing un-necessary triggers.
Reply With Quote