Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Discussion: 5 different gaming scripts (for learning)

Shippou Oud
The Fox Within
Join date: 11 Jul 2005
Posts: 141
04-23-2007 23:55
These scripts are 100% paw written by Shippou oud (me).
Since the ban on advertising casino related items, I can no longer sell the items these were in, so I'm releasing the scripts here on the forums so folks can learn how certain items work.
My theorie on scripting, is keep it simple, and understandable. No need to over complicate it.
1 prim slots
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.
CODE

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 = <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);


}
}
}



$L Picker
This game is unique. I came up with the idea a while ago, and developed this as one of my first sucessfull games. It works liek this. pay from 1 to 10. that becomes your number the script randomly generates a number from 1 to 10..if it matched win 4x bet. if it is 1 off, win 2x bet.
CODE

integer ttp;
integer payin;
default
{

on_rez(integer x)
{


llResetScript();
}

state_entry()
{
llSetTimerEvent(1);
llSetText("$L Picker \n Click for info \n Pay $L1 to $L10 to play" + "\n" + "Total Payout $L" + (string) ttp,<.5,1,1>,1);
llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);
}
touch_start(integer x)
{
if (llDetectedKey(0) == llGetOwner())
{
llInstantMessage(llGetOwner(),"$L" + (string) payin + " has been bet.");
}
if (llDetectedKey(0) != llGetOwner())
{
llInstantMessage(llDetectedKey(0),"This game is simple. Bet from $L1 to $L10 if the computer picks your bet you win 4x the amount. if the computer is off by 1, you win 2x bet. \n Lets say you bet $L5 and the computer randomly picks 5, you'll win $L20. Now lets say you bet $L8 and the computer picks 7, you win $L16. \n 10 is considered to be the number below below 1, and 1 the number above 10, so if you bet $L10 and the computer picks 1, you'll win $L20.");
}
}
money(key giver, integer amount)
{

payin = payin + amount;
if (amount > 10)
{

llInstantMessage(giver,"Sorry, but I can only bet up to $L10 at a time, here is $L" + (string) amount + " back. ");
llGiveMoney(giver,amount);
payin = payin - amount;
return;

}
float Winnum = llFrand(10);
integer W2 = (integer) Winnum + 1;
integer w2x = amount * 2;
integer w4x = amount * 4;

llInstantMessage(giver,"You bet " + (string) amount + " !");
llInstantMessage(giver,"The computer picks " + (string) W2 + " !" + "\n ");


if (amount == W2)
{
llGiveMoney(giver,amount * 4);
llSay(0,"Won $L" + (string) w4x + " !");
ttp = ttp + w4x;


}
if (amount == W2 + 1)
{
llGiveMoney(giver,amount * 2);
llSay(0,"Won $L" + (string) w2x + " !");
ttp = ttp + w2x;

}
if (amount == W2 - 1)
{
llGiveMoney(giver,amount * 2);
llSay(0,"Won $L"+ (string) w2x + " !");
ttp = ttp + w2x;
}
if (W2 - 9 == amount)
{
llGiveMoney(giver,amount * 2);
llSay(0,"Won $L" + (string) w2x + " !");
ttp = ttp + w2x;

}
if (W2 + 9 == amount)
{
llGiveMoney(giver,amount * 2);
llSay(0,"Won $L" + (string) w2x + " !");
ttp = ttp + w2x;

}


}
timer()
{
llSetText("$L Picker \n Click for info \n Pay $L1 to $L10 to play" + "\n" + "Total Payout $L" + (string) ttp,<.5,1,1>,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);


}
}



}




Lucky Orb
This script let the palyer to bet from 1 to 100. If the 2 numebrs from 1 to 3 matches that are generated, they win bet x 2.
CODE

integer pi;
integer po;
string wnnr;
integer pyo;

default
{
on_rez(integer x)
{
llResetScript();
}

state_entry()
{
pi = 0;
po = 0;

llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);
llSetTextureAnim(SMOOTH | LOOP | ANIM_ON, ALL_SIDES,0,0,0,0,.25);
llSetText("Double your $L \n Bet from $L1 to $L100 \n " + wnnr + " has won $L" + (string) pyo + " \n Total Payout $L" + (string) po,<0,1,.5>,1);
}

touch_start(integer total_number)
{
if (llDetectedKey(0) == llGetOwner())
{
llInstantMessage(llGetOwner(),"Total Pay In $L" + (string) pi);
}
}
money(key player, integer mon)
{
if (mon > 100)
{
integer df = mon - 100;
llGiveMoney(player,df);
llInstantMessage(player,"Sorry that was too much, here is $L" + (string) df + " in change.");
mon = 100;
}
pi = pi + mon;
llInstantMessage(player,"Good Luck!");
integer wn1 = (integer) llFrand(3) + 1;
integer wn2 = (integer) llFrand(3) + 1;
if (wn1 == wn2)
{
pyo = mon * 2;
llGiveMoney(player, pyo);
llInstantMessage(player,"You Won $L" + (string) pyo);
po = po + pyo;
wnnr = llKey2Name(player);

}
llSetText("Double your $L \n Bet from $L1 to $L100 \n " + wnnr + " has won $L" + (string) pyo + " \n Total Payout $L" + (string) po,<0,1,.5>,1);
llInstantMessage(player,"Thank you for playing.");
}
run_time_permissions(integer perm)
{
if (PERMISSION_DEBIT & perm)
{

}
else
{
llInstantMessage(llGetOwner(),"Sorry, you must click 'yes' to operate this. ");
llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);


}
}
}




randon $L giver
For this script, pay in 10-100, and get something back every time.
The script picks a number , and determins the pay scale. 1.8 x bet is the max.
CODE

integer pi;
integer po;
string wnnr;
integer pyo;

default
{
on_rez(integer x)
{
llResetScript();
}

state_entry()
{
pi = 0;
po = 0;

llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);
llSetTextureAnim(SMOOTH | LOOP | ANIM_ON, ALL_SIDES,0,0,0,0,.25);
llSetText("Win Random $L \n Bet from $L10 to $L100 \n " + wnnr + " has won $L" + (string) pyo + " \n Total Payout $L" + (string) po,<.1,1,.5>,1);
}

touch_start(integer x)
{
if (llDetectedKey(0) == llGetOwner())
{
llInstantMessage(llGetOwner(),"Total Pay In $L" + (string) pi);
}
}
money(key player, integer mon)
{
if (mon > 100)
{
llInstantMessage(player,"Sorry this is too much, here is your refund");
llGiveMoney(player,mon);
}
else if (mon < 10)
{
llInstantMessage(player,"Sorry this is not enough. Please bet $L10 or more, here is your refund");
llGiveMoney(player,mon);
}
else
{
pi = pi + mon;
llInstantMessage(player,"Good Luck");
integer wun = mon * 2 - 2;
integer wun1 = (integer)llFrand(wun) + 1;
llGiveMoney(player,wun1);
wnnr = llKey2Name(player);
pyo = wun1;
po = po + wun1;
llInstantMessage(player, "Congradulations, you won $L" + (string) wun1);

llSetText("Win Random $L \n Bet from $L10 to $L100 \n " + wnnr + " has won $L" + (string) pyo + " \n Total Payout $L" + (string) po,<.1,1,.5>,1);
llInstantMessage(player,"Thank you for playing.");
}
}
run_time_permissions(integer perm)
{
if (PERMISSION_DEBIT & perm)
{

}
else
{
llInstantMessage(llGetOwner(),"Sorry, you must click 'yes' to operate this. ");
llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);


}
}
}



betting orbs
this is one of my more feature laden gaming scripts. I put it to change the object name, due to the fact I made a lot of different dominations of orbs, and was getting them confused. Made it very eayy to tell which one was which.
CODE

integer p1 = 10;
integer p2;
string lpl;
integer tpi;
integer tpo;
integer tpp;
default
{
on_rez(integer x)
{
llResetScript();
}
state_entry()
{
p2 = p1 * 10;
tpi = 0;
tpo = 0;
tpp = 0;
lpl = "";
llSetObjectName("Betting Orb $L" + (string) p1);
llSetText("Bet $L" + (string) p1+ " - Win $L" + (string) p2 + "\n Last Player: " + lpl,<1,0,.2>,1);
llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);
llSetPayPrice(PAY_HIDE, [p1, PAY_HIDE, PAY_HIDE, PAY_HIDE]);
}
touch_start(integer x)
{
if (llDetectedKey(0) != llGetOwner())
{
llInstantMessage(llDetectedKey(0),"Please pay $L" + (string) p1 + " to play. \n You can win $L" + (string) p2);
}
if (llDetectedKey(0) == llGetOwner())
{
llInstantMessage(llGetOwner()," \n Total pay in - $L" + (string) tpi + "\n Total pay out - $L" + (string) tpo + " \n Total times played - " + (string) tpp);
}
}
money(key pla, integer mon)
{
tpp = tpp + 1;
tpi = tpi + mon;
lpl = llKey2Name(pla);
llInstantMessage(pla,"Good luck, " + lpl + ".");
integer num1 = (integer) llFrand(14) + 1;
integer num2 = (integer) llFrand(14) + 1;
if (num1 == num2)
{
llInstantMessage(pla,"You won $L" + (string) p2 + " !");
llGiveMoney(pla,p2);
tpo = tpo + p2;
}
llInstantMessage(pla,"Thank you for playing.");
llSetText("Bet $L" + (string) p1+ " - Win $L" + (string) p2 + "\n Last Player: " + lpl,<1,0,.2>,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);


}
}
}
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Original Thread
04-29-2007 15:31
/15/f6/179249/1.html
_____________________
i've got nothing. ;)
Shippou Oud
The Fox Within
Join date: 11 Jul 2005
Posts: 141
03-27-2008 18:30
I've been asked some questions regarding this topic recently. Bringing this post back up for new readers.
Tyken Hightower
Automagical
Join date: 15 Feb 2006
Posts: 472
03-27-2008 20:15
From: Shippou Oud
I've been asked some questions regarding this topic recently. Bringing this post back up for new readers.

Considering these are pretty much illegal (wagering!), I'd bring up something else.
_____________________
Chipley Chippewa
Googlemonger
Join date: 25 Aug 2007
Posts: 56
03-28-2008 13:19
From: someone
Considering these are pretty much illegal (wagering!), I'd bring up something else.

Very true Tyken, but Shippou already pointed this out ... like ... a year ago.

From: someone
04-24-2007, 06:55 AM - These scripts are 100% paw written by Shippou oud (me).
Since the ban on advertising casino related items, I can no longer sell the items these were in, so I'm releasing the scripts here on the forums so folks can learn how certain items work.


Still an interesting thread. Cheers Shippou.
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
03-28-2008 16:52
I was off for quite a while about the time you had released this Shippou and missed it.

Just wanted to say a a very belated thanks, pretty cool contribution to the community. Easily readable code for people to learn from and play with.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum