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