Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Spoder? Can't get it to work

Noah Aero
Registered User
Join date: 15 May 2007
Posts: 11
05-15-2007 20:19
I don't understand how to get the script to work. I am trying to make a sploder, but get stuck at where it randomly distributes the money. Does anyone know how to get a sploder to work? Any help appreciated.

(A sploder waits for a certain amount of people to put in money, it then pays them random amounts of money from the pot...its not a particle system :p)
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
05-16-2007 00:23
From: Noah Aero
I don't understand how to get the script to work. I am trying to make a sploder, but get stuck at where it randomly distributes the money. Does anyone know how to get a sploder to work? Any help appreciated.

(A sploder waits for a certain amount of people to put in money, it then pays them random amounts of money from the pot...its not a particle system :p)


A more precise question would be helpful, i.e. what bit of "randomly distributes the money" are you having trouble with?

The basic idea is to generate a list of winners (llSensor) and then calculate an amount to be paid to each winner from the paid in total. This can either be fixed, i.e. 1$ each, 10% each or random (value or percentage). Finally use llGiveMoney to pay each winner.
_____________________
I'm back......
Noah Aero
Registered User
Join date: 15 May 2007
Posts: 11
05-16-2007 06:34
Sorry. :D. I am having trouble getting it to get a random number for each entry. I get numbers lower than whats in the pot meaning that no one ever wins. I want it to be random...
RJ Source
Green Sky Labs
Join date: 10 Jan 2007
Posts: 272
05-16-2007 06:39
Could you post some code? Might be easier to help.
Milambus Oh
Registered User
Join date: 6 Apr 2007
Posts: 224
05-16-2007 06:45
From: Noah Aero
Sorry. :D. I am having trouble getting it to get a random number for each entry. I get numbers lower than whats in the pot meaning that no one ever wins. I want it to be random...


llFrand() is what you seek.

Before picking the winner(s) you need:
The number of entries
The amount in the pot

Steps to follow:
1. Randomly pick a winner from the entries
2. Randomly select an amount from the pot
3. Reduce that amount from the pot
4. Pay the winner.
5. Remove the winner from the list of entries, so that can only be paid out once per run.
6. Repeat until all money is given out, or there is only 1 entry left.
7. If there is an entry remaining, pay them the remainder of the pot.
Speon Beerbaum
Registered User
Join date: 29 Mar 2007
Posts: 11
05-16-2007 07:38
...and be aware, that llFrand gives you a float, where you need an integer.

f.e. if the pot size is 200L$, use (integer)llFrand(201); to get a number ranging from 0 - 200.

Details on llFrand
Noah Aero
Registered User
Join date: 15 May 2007
Posts: 11
05-16-2007 09:12
From: Milambus Oh
llFrand() is what you seek.

Before picking the winner(s) you need:
The number of entries
The amount in the pot

Steps to follow:
1. Randomly pick a winner from the entries
2. Randomly select an amount from the pot
3. Reduce that amount from the pot
4. Pay the winner.
5. Remove the winner from the list of entries, so that can only be paid out once per run.
6. Repeat until all money is given out, or there is only 1 entry left.
7. If there is an entry remaining, pay them the remainder of the pot.



I have tried all but the last 2 steps. I will try those, but my problem is no one wins...everyone gets less money than they entered.
Milambus Oh
Registered User
Join date: 6 Apr 2007
Posts: 224
05-16-2007 09:26
Most people should get less than they entered, unless you are increasing the pot in some way.

Make sure you are using the whole value of the pot for the upper limit on the llFrand call.. or 1/2 the pot or whatever.
Noah Aero
Registered User
Join date: 15 May 2007
Posts: 11
05-16-2007 15:23
I am..but no one ever gets more than they entered...which means everyone always loses....
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
05-17-2007 00:07
From: Noah Aero
I am..but no one ever gets more than they entered...which means everyone always loses....


well unless you are keeping a large proportion for yourself then some one must come out ahead somewhere along the line.

Calculate a minimum payout, i.e. 5% and add that to a randomly generated amount.
_____________________
I'm back......
Milambus Oh
Registered User
Join date: 6 Apr 2007
Posts: 224
05-17-2007 06:07
Post your code so we can pick it apart... er I mean so we can make helpful suggestions.

More than likely you are calling the llFran function with the amount the player put into the pot (so the most hey will ever get is how much they added) and not the total amount remaining in the pot.