Home |
Add a script
|
||
|---|---|---|---|
| Category: | Contributor: | Description | |
| Gambling | Hank Ramos | Gambling State Example.lsl | |
Gambling State Example.lsl
Gambling State Example.lsl
Download this script - Please use this link to get this script. If you see all the code on one long line, please use Wordpad or another editor, such as LSLEdit.exe. The .LSL file you will download is an ordinary text file.
1 // CATEGORY:Gambling 2 // DESCRIPTION:Gambling State Example.lsl 3 // ARCHIVED BY:Ferd Frederix 4 5 1//============================================================================ 6 //Gambling Machine 7 //State Example 8 //by Hank Ramos 9 //============================================================================ 10 //Copyright 2006 by Hank Ramos, All Rights Reserved 11 //You may use this script freely in your projects, but you are not licensed to 12 //distribute or redistribute this script in a free or sold pack of example LSL 13 //scripts or on it's own. This script is "open source" in that you are able to 14 //view and learn from it. It is still copyrighted and is not in the public 15 //domain, therefore it may not be redistributed in it's current form. Use it 16 //as a learning example or as a template for your own scripting project. 17 //I sell these example scripts as a business, so please do not give these 18 //scripts away or sell them. 19 //============================================================================ 20 21 //Variables 22 key playerID; 23 integer amountPaid; 24 integer winningAmount; 25 26 default 27 { 28 state_entry() 29 { 30 //Do some initialization here 32 } 33 run_time_permissions(integer permissions) 34 { 35 //Only wait for payment if the owner agreed to pay out money 36 if (permissions & PERMISSION_DEBIT) 37 { 38 llSay(0, "Initailized Successfully..."); 39 state waiting; 40 } 41 } 42 } 43 44 state waiting 45 { 46 state_entry() 47 { 48 llSay(0, "Idle..."); 49 } 51 { 52 playerID = id; 53 amountPaid = amount; 54 state playing; 55 } 56 } 57 58 state playing 59 { 60 state_entry() 61 { 62 //Do the gambling bit in this state 63 64 //Determine if they are a winner or a loser 65 //Half the time pay twice the bet 66 //The other half, pay nothing. 67 if (llFrand(1) >= 0.5) 68 { 69 winningAmount = amountPaid * 2; 70 state winner; 71 } 72 else 73 { 74 state loser; 75 } 76 } 77 } 78 79 state winner 80 { 81 state_entry() 82 { 83 85 llGiveMoney(playerID, winningAmount); 86 state waiting; 87 } 88 } 89 90 state loser 91 { 92 state_entry() 93 { 94 llSay(0, "Sorry, you lose."); 95 state waiting; 96 } 97 } 98 // END //