Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Script Help/Wanted

Keaira Skytower
Registered User
Join date: 23 May 2008
Posts: 9
08-16-2008 19:35
Hello, I'd like a donation script that will randomly play sound file when someone donates money to it.

So, I'd like the hovertext to show how much has been donated total and who was the last donor.

Then I'd like to be able to put four sound files in, and the sound files only played when donations made.

Is there one that already does this?

I'm completely script-handicapped.... :)

Thank you ever so much!

Keaira Skytower
Kaluura Boa
Polygon Project
Join date: 27 Mar 2007
Posts: 194
08-17-2008 05:37
Contact me in-world if you still haven't found what you wanted, I'll do that for almost nothing. Anything more would be robbery...
Beverly Ultsch
Registered User
Join date: 6 Sep 2007
Posts: 229
08-17-2008 05:50
Try this

CODE


integer total = 0;
integer max_sounds = 0;
float sound_volume = 1.0;
key topay = NULL_KEY;
integer handle;
integer chan;

integer randInt(integer n)
{
return (integer)llFrand(n + 1);
}

integer randIntBetween(integer min, integer max)
{
return min + randInt(max - min);
}

update_text(key giver)
{
llSetText("Last Donation by " + llKey2Name(giver)+ "\nTotal Donations L$" + (string)total, <1.0,1.0,1.0>, 1.0);
}

integer get_sounds()
{
return llGetInventoryNumber(INVENTORY_SOUND) -1;

}

play_sound()
{
if(max_sounds >= 0)
{
string sound = llGetInventoryName(INVENTORY_SOUND, randIntBetween(0, max_sounds));
llPlaySound( sound, sound_volume );
}

}
default
{
state_entry()
{
chan = randIntBetween( -10000, -20000);
topay = llGetOwner();
llSetText("", <0.0,0.0,0.0>, 0.0);
max_sounds = get_sounds();


}

touch_start(integer total_number)
{
if(llDetectedKey(0) == topay)
{
handle = llListen(chan, "", topay,"");
llSetTimerEvent(30.0);
llDialog(topay, "Reset", ["Reset"], chan);
}

}

listen(integer channel, string name, key id, string message)
{
if(message == "Reset")
{
llResetScript();
}

}

timer()
{
llSetTimerEvent(0.0);
llListenRemove(handle);

}


money(key giver, integer amount)
{
total += amount;
play_sound();
update_text(giver);
}

changed(integer change)
{
if(change & CHANGED_INVENTORY)
{
max_sounds = get_sounds();
}
else if(change & CHANGED_OWNER)
{
llResetScript();
}
}
}