Fruit Machine
De DigiWiki.
This was a fun script to wright. Notice how I use numbers to make a symbol, and for each symbol is assigned a value, so when added up, the machine knows what is landed on, and if it is a winner or not. This also keeps track of payin, last player and total winnings. Also has a progressive jack pot.
// 1 prim slots by Shippou Oud list null= ["OK"]; string name = "The Fruit Machine"; string f1 = " banana "; string f2 = " cherry "; string f3 = " apple "; integer cha; integer f1a = 50; integer f2a = 60; integer f3a = 70; string LP; integer JP; integer ttpi; integer po; vector col = <1.0, 1.0, 1.0>; default { on_rez(integer x) { llResetScript(); } state_entry() { llSetObjectName(name); cha = (integer) llFrand(999999998) + 1; llRequestPermissions(llGetOwner(), PERMISSION_DEBIT); llSetPayPrice(PAY_HIDE, [10, PAY_HIDE, PAY_HIDE, PAY_HIDE]); JP = 1000; llSetText(name +" \n Last Player: " + LP + "\n Jack Pot $L" + (string) JP + "\n Total Pay Out $L" + (string) po,col,1); } touch_start(integer x) { llInstantMessage(llDetectedKey(0),"Current Pay outs are 3 " + f1 + "$L" + (string) f1a + " , 3 " + f2 + "$L" + (string) f2a + " , 3 " + f3 + "$L" + (string) f3a + " . Only $L10 to play"); if (llDetectedKey(0) == llGetOwner()) { llInstantMessage(llGetOwner(),"---- $L" + (string) ttpi); } } money(key play, integer mon) { ttpi = ttpi + mon; JP = JP + 1; string w1; string w2; string w3; integer win1; integer win2; integer win3; integer a1 = (integer) llFrand(3) + 1; if (a1 == 1) { w1 = f1; win1 = win1 + 1; } else if (a1 == 2) { w1 = f2; win2 = win2 + 1; } else if (a1 == 3) { w1 = f3; win3 = win3 + 1; } integer a2 = (integer) llFrand(3) + 1; if (a2 == 1) { w2 = f1; win1 = win1 + 1; } else if (a2 == 2) { w2 = f2; win2 = win2 + 1; } else if (a2 == 3) { w2 = f3; win3 = win3 + 1; } integer a3 = (integer) llFrand(3) + 1; if (a3 == 1) { w3 = f1; win1 = win1 + 1; } else if (a3 == 2) { w3 = f2; win2 = win2 + 1; } else if (a3 == 3) { w3 = f3; win3 = win3 + 1; } integer ww = (integer) llFrand(4) + 1; integer ww1 = (integer) llFrand(4) + 1; integer wmu = (integer) llFrand(25) + 1; integer wmu1 = (integer) llFrand(25) + 1; LP = llKey2Name(play); llInstantMessage(play,"Thank you " + LP + " . Good luck !"); llDialog( play , " " + w1 + w2 + w3, null ,cha); if (ww == ww1) { llDialog( play ,"You Won $L5", null ,cha); llGiveMoney(play,5); po = po + 5; } if (win1 == 3) { llDialog( play ,"You Won $L" + (string) f1a, null ,cha); llGiveMoney(play, f1a); po = po + f1a; } else if (win2 == 3) { llDialog( play ,"You Won $L" + (string) f2a, null ,cha); llGiveMoney(play, f2a); po = po + f2a; } else if (win3 == 3) { llDialog( play ,"You Won $L" + (string) f3a, null ,cha); llGiveMoney(play, f3a); po = po + f3a; } integer Jack1 = (integer) llFrand(3000) + 1; integer Jack2 = (integer) llFrand(3000) + 1; { if (Jack1 == Jack2) { llDialog( play ,"You Won The Jackpot of $L" + (string) JP, null ,cha); llGiveMoney(play, JP); po = po + JP; JP = 1000; } win1 = 0; win2 = 0; win3 = 0; llSetText(name +" \n Last Player: " + LP + "\n Jack Pot $L" + (string) JP + "\n Total Pay Out $L" + (string) po,col,1); } } run_time_permissions(integer perm) { if (PERMISSION_DEBIT & perm) {;} else { llInstantMessage(llGetOwner(),"Sorry, you must click 'yes' to operate this. "); llRequestPermissions(llGetOwner(), PERMISSION_DEBIT); } } }