Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Mini Lotto (https://forums.graalonline.com/forums/showthread.php?t=65490)

excaliber7388 04-19-2006 12:24 AM

Mini Lotto
 
I'm making a mini lotto game for DR. The script works for 1 NPC, but put more than one in a level, and ALL of them trigger the test action. Why??
PHP Code:


// NPC made by Excaliber
function onCreated()
{
  
setshape(1,32,32);
}
function 
onActiontest()
{
  
playerrupees-=1;
  
this.minilotto_num1=int(random(0,9));
  
this.minilotto_num2=int(random(0,9));
  
this.minilotto_num1*=10;
  
this.minilotto_num=this.minilotto_num1+this.minilotto_num2;
  if(
client.minilotto_num==this.minilotto_num)
  {
    
chat="JACKPOT!";
    
with(findplayer(player.account))
    {
      
play extra.wav//doesn't work
      
playerrupees+=51//does work
    
}
  }
  else
  {
    
chat="Nothing this time... Last number: "@this.minilotto_num;
  }
}
//#CLIENTSIDE
function onPlayertouchsme()
{
  if(
playerrupees>0)
  {
    
chat="Playing";
    
client.minilotto_num=0;
    
mini_lotto.showtop();
    new 
GuiWindowCtrl("mini_lotto")
    {
      
//gui window stuff

        
new GuiButtonCtrl("roll")
        {
          
//roll button stuff
        
}
        new 
GuiTextEditCtrl("p1num")
        {
         
//text stuff
        
}
      new 
GuiTextEditCtrl("p2num")
        {
          
//text stuff
        
}
      }
    }
  }
  function 
roll.onAction()
  {
    
//var setup
    
triggeraction(x,y,"test","test");
  } 


Skyld 04-19-2006 12:29 AM

GUI control names are shared across NPCs. Likely, each NPC is receiving roll.onAction().

jake13jake 04-19-2006 04:00 AM

also, I believe play only works clientside
also it would be play(file);

ApothiX 04-19-2006 02:29 PM

Yeah, the GUI control names are probably conflicting with eachother. Try using something like "roll_" @ this.id or whatever.

also, findplayer(player.account) is the most redundant function call in GraalScript x_x

jake13jake 04-19-2006 07:04 PM

Quote:

Originally Posted by ApothiX
Yeah, the GUI control names are probably conflicting with eachother. Try using something like "roll_" @ this.id or whatever.

also, findplayer(player.account) is the most redundant function call in GraalScript x_x

After all, player == findplayer(player.account) is a tautology.

I really can't express how much I want with statements to be deprecated.

Yen 04-19-2006 11:47 PM

Quote:

Originally Posted by jake13jake
I really can't express how much I want with statements to be deprecated.

'with()' lets you modify multiple aspects of a foreign object, without having to repeat the object reference.

PHP Code:

with (findimg(300)) {
  
30;
  
30;
  
text "Hi!";
  
font "Times New Roman";
  
style "cb";
  
red 1;
  
green 0;
  
blue 1;



jake13jake 04-20-2006 05:34 AM

Quote:

Originally Posted by Yen
'with()' lets you modify multiple aspects of a foreign object, without having to repeat the object reference.

Yes, I know, but I prefer using the object reference.


All times are GMT +2. The time now is 04:17 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.