View Single Post
  #11  
Old 11-29-2009, 11:16 PM
OiRodgar OiRodgar is offline
Registered User
OiRodgar's Avatar
Join Date: Jan 2005
Posts: 23
OiRodgar is on a distinguished road
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 unless you know the npc name which is a little more complicated.

PHP Code:
function onCreated() {
  
// Allows triggers sent from the client-side able to be received on the server-side.
  
setshape(1, 32, 32);
}

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; 
    } 
  } 
} 

//#CLIENTSIDE  

function onPlayertouchsme() {  

  new 
GuiWindowCtrl("Shop_Window4") {  
    
profile = GuiBlueWindowProfile;  
    
clientrelative = true;  
    
clientextent = "544,447";  
    
visible = true;  
    
canmove = true;  
    
canresize = false;  
    
canmaximize = false;  
    
closequery = false;  
    
destroyonhide = true;  
    
text = "Willkommen im Waffenshop";  
    
x = 29;  
    
y = 115;  

    new 
GuiScrollCtrl("Shop_TextList1_Scroll") {  
      
profile = GuiBlueScrollProfile;  
      
height = 426;  
      
hscrollbar = "alwaysOff";  
      
vscrollbar = "dynamic";  
      
width = 120;  
      
x = 9;  
      
y = 15;  

      new 
GuiTextListCtrl("Shop_TextList1") {  
        
profile = GuiBlueTextListProfile;  
        
height = 426;  
        
horizsizing = "width";  
        
width = 99;  

        
clearrows();  
        
addrow(0,"Jeep");  
      }  
    }  
    new 
GuiScrollCtrl("Shop_MultiLine1_Scroll") {  
      
profile = GuiBlueScrollProfile;  
      
height = 426;  
      
hscrollbar = "dynamic";  
      
vscrollbar = "dynamic";  
      
width = 403;  
      
x = 138;  
      
y = 14;  

      new 
GuiMLTextCtrl("Shop_MultiLine1") {  
        
profile = GuiBlueMLTextProfile;  
        
height = 16;  
        
horizsizing = "width";  
        
text = "<center><h1>Willkommen im Waffenshop!</h1><br> Hier erhalten sie eine Vielzahl an Mitteln um Ihre Gegner auszulöschen</center>";  
        
width = 378;  
      }  
    }  
    new 
GuiButtonCtrl("Shop_Button1") {  
      
profile = GuiBlueButtonProfile;  
      
text = "Kaufen";  
      
width = 80;  
      
x = 286;  
      
y = 380;  
    }  
  }  
}  

function 
Shop_TextList1.onSelect( entryid, entrytext, entryindex ) {  
  switch ( 
entrytext ) {  
    case 
"Jeep":  
    
this.item = "Jeep";  
    
temp.description = "<center><h1>Bombe</h1><br> Sprenge deine Gegner in die Luft!</center> Preis: 15g";  
    break;  
  }  

  
Shop_MultiLine1.setText( temp.description );  
}  

function 
Shop_Button1.onAction() {  
  
// Button "Kaufen" has been pressed 
  // Triggers onActionServerside (on the server-side of course) 
  // sending "buy" and this.item as parameters. 
  
if (checkCost(this.item)) { 
    
// Display Item Purchased 
    
Shop_MultiLine1.setText("Danke für den Einkauf"); 
    
// Trigger the NPC and get it to add the weapon   
    
triggeraction(this.x + 1, this.y + 1, "serverside", "buy", this.item); 
  } 
  else 
Shop_MultiLine1.setText("Nich genug Geld");  
} 

// This function returns true or false depending on whether they 
// have enough rupees for the certain item. 
function checkCost(temp.item) { 
  switch (
temp.item) { 
     case 
"jeep": 
       
temp.cost = 15; 
       break; 
     default: 
       return 
false; 
       break; 
  } 
  if (
player.rupees >= temp.cost) return true; 
  else return 
false; 
} 

I see.. But it still won't work xD

@cbk1994

I gonna try that after I got the level NPC working.
Reply With Quote