View Single Post
  #3  
Old 07-02-2013, 12:56 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
The timeout method is really dumb, this is a much better method:

Quote:
Originally Posted by callimuc View Post
PHP Code:
function onPlayerEnters() {
  
player.client.lnpcn this.name;
  
//on clientside then this.n = player.client.lnpcn;

However the following is even better:

PHP Code:
// could use onCreated but onPlayerEnters is just to be safe
function onPlayerEnters() {
  
this.attr[4] = this.name;

Attributes are synced to clientside, so you can avoid polluting the player's flags.

Depending on your situation, a better solution can be to have an actual DB NPC which handles the actions/logic of the level NPC and simply trigger that.

Quote:
Originally Posted by cbk1994 View Post
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; 
    } 
  }  

__________________
Reply With Quote