Join us in Outworldz at www.outworldz.com:9000 or follow us:

Search dozens of selected web sites for OpenSim and LSL script

New! Script Meta-Search will search thousands of scripts here and at other sites for LSL or Opensim scripts.
Loading

Want to add a script or a project? Upload it and a half million people will see it and your name here this year.

Home   Show All
Category: Contributor: Creator
Gambling Gambling_State_Example  

Gambling_State_Example

Gambling State Example.lsl

Category: Gambling
By : Hank Ramos
Created: 2010-01-10 Edited: 2010-01-10
Worlds: Second Life

the Zip file

Download all files for Gambling_State_Example
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Gambling_State_Example_1.lsl
1
2 1//============================================================================
3 //Gambling Machine
4 //State Example
5 //by Hank Ramos
6 //============================================================================
7 //Copyright 2006 by Hank Ramos, All Rights Reserved
8 //You may use this script freely in your projects, but you are not licensed to
9 //distribute or redistribute this script in a free or sold pack of example LSL
10 //scripts or on it's own. This script is "open source" in that you are able to
11 //view and learn from it. It is still copyrighted and is not in the public
12 //domain, therefore it may not be redistributed in it's current form. Use it
13 //as a learning example or as a template for your own scripting project.
14 //I sell these example scripts as a business, so please do not give these
15 //scripts away or sell them.
16 //============================================================================
17
18 //Variables
19 key playerID;
20 integer amountPaid;
21 integer winningAmount;
22
23 default
24 {
26 {
27 //Do some initialization here
29 }
30 run_time_permissions(integer permissions)
31 {
32 //Only wait for payment if the owner agreed to pay out money
33 if(permissions & PERMISSION_DEBIT)
34 {
35 llSay(0, "Initailized Successfully...");
36 state waiting;
37 }
38 }
39 }
40
41 state waiting
42 {
44 {
45 llSay(0, "Idle...");
46 }
47 money(key id, integer amount)
48 {
49 playerID = id;
50 amountPaid = amount;
51 state playing;
52 }
53 }
54
55 state playing
56 {
58 {
59 //Do the gambling bit in this state
60
61 //Determine if they are a winner or a loser
62 //Half the time pay twice the bet
63 //The other half, pay nothing.
64 if(llFrand(1) >= 0.5)
65 {
66 winningAmount = amountPaid * 2;
67 state winner;
68 }
69 else
70 {
71 state loser;
72 }
73 }
74 }
75
76 state winner
77 {
79 {
80
81 llSay(0, "You won L$" + (string)winningAmount + "!");
82 llGiveMoney(playerID, winningAmount);
83 state waiting;
84 }
85 }
86
87 state loser
88 {
90 {
91 llSay(0, "Sorry, you lose.");
92 state waiting;
93 }
94 }
95 // END //

Back to the Best Free Tools in Second Life and OpenSim.