View Single Post
  #9  
Old 11-29-2009, 11:10 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by fowlplay4 View Post
If you're using it in a level npc, you'll have to make a few modifications. Assuming that's the problem, you'll need to give a few more details to clear that up.

The npc needs a blocking shape on the server-side, and you have to use triggeraction instead
I hope I'm not confusing anyone here, but I've always found it better to use DB NPCs for something like this

PHP Code:

function Shop_Button1.onAction() {  
  if (
checkCost(this.item)) { 
    
Shop_MultiLine1.setText("Danke für den Einkauf");

    
// trigger a DB NPC:
    
triggerServer("npc""ShopControl""buy"this.item);
  } 
  else 
Shop_MultiLine1.setText("Nich genug Geld");  

then have a DB NPC named "ShopControl"

PHP Code:
function onActionServerSide() {
  
// The parameters are received from the client-side 
  // in an array like so: {"buy", "jeep"} 
  // Assuming "jeep" was in this.item when it was triggered 
  
if (params[0] == "buy") { 
    switch (
params[1]) { 
      case 
"jeep"
        
// Check to see if they enough rupees 
        
temp.cost 15
        if (
player.rupees >= temp.cost) { 
          
// Add weapon and deduct rupees from player  
          
addweapon("Jeep2"); 
          
player.rupees -= temp.cost
        } 
      break; 
    } 
  }  

It doesn't really make a difference I guess, just another way to do it. It's probably more reliable than using setShape and triggerAction(x, y) since other NPCs can get in the way, etc.

Quote:
unless you know the npc name which is a little more complicated.
You can't trigger level NPCs from clientside anyway (by name); it has to be a DB NPC (or putnpc2, same thing).
__________________
Reply With Quote