right now, 1 animation can be added to the content of the object containing the script. also 1 sound file.
- I would like to be able to add as many sound files as I want and when the object is touched one of the sounds is played at random. I know that I need to use "frand". but I'm not a programmer so I don't know how to code it. any help would be much appreciated.
here's what I have so far:
string SoundFile ="slap001";
// End name of the spanker
string ObjectName="Spankme! (Wear)";
// Text color white.
vector Vector_Color = <1.00000, 1.00000, 1.00000>;
integer IHavePermission = FALSE;
integer GetAttach = FALSE;
integer lT;
list UserName;
string FirstName;
float TimeIt = 3.0;
integer Count;
integer TotalA;
list lA;
integer WHICH;
integer CheckForAnimations()
{
integer i;
TotalA = llGetInventoryNumber(INVENTORY_ANIMATION);
// clear and rebuild the animation list
lA = llDeleteSubList(lA,0,-1);
for ( i = 0; i < TotalA; i++ )
{
lA += llGetInventoryName(INVENTORY_ANIMATION,i);
}
if (TotalA < 1)
{
llInstantMessage(llGetOwner(),"Sorry no animations were found, you must add 1 animation to the content of this object.");
return TRUE;
}
return FALSE;
}
integer CheckForMaxAnimations()
{
integer i;
TotalA = llGetInventoryNumber(INVENTORY_ANIMATION);
// clear and rebuild the animation list
lA = llDeleteSubList(lA,0,-1);
for ( i = 0; i < TotalA; i++ )
{
lA += llGetInventoryName(INVENTORY_ANIMATION,i);
}
if (TotalA > 1)
{
llInstantMessage(llGetOwner(),"Sorry max animations are 1, you must remove some animations from the content of this object.");
return TRUE;
}
return FALSE;
}
LetsTimeIt()
{
lT = (integer)llGetTime() + (integer)TimeIt;
llSetTimerEvent(1);
}
PlaySoundFile()
{
float volume = 1;
llStopSound();
llPlaySound(SoundFile, volume);
}
default
{
state_entry()
{
UserName = llParseString2List(llKey2Name(llGetOwner()),[" ","| "," |"," | "],[]);
FirstName = llList2String(UserName,0);
llSetObjectName((string)FirstName+"'s "+ObjectName);
llSetText("",Vector_Color, 1);
}
attach(key id)
{
if(id == NULL_KEY)
{
GetAttach = FALSE;
llSetObjectName((string)FirstName+"'s "+ObjectName);
return;
}
else
if(CheckForMaxAnimations())
{
return;
}
else
if(CheckForAnimations())
{
return;
}
else
GetAttach = TRUE;
Count = 0;
llRequestPermissions(id,PERMISSION_TRIGGER_ANIMATION);
UserName = llParseString2List(llKey2Name(llGetOwner()),[" ","| "," |"," | "],[]);
FirstName = llList2String(UserName,0);
llSetObjectName((string)FirstName+"'s "+ObjectName);
llInstantMessage(llGetOwner(),"Ready (bytes free"+" "+(string)llGetFreeMemory()+")");
}
touch_start(integer total_number)
{
integer TouchTrack;
key person = llDetectedKey(TouchTrack);
string user;
if(!GetAttach)
{
llInstantMessage(person,"I must be attached before you can use me!");
return;
}
else
LetsTimeIt();
PlaySoundFile();
integer i;
TotalA = llGetInventoryNumber(INVENTORY_ANIMATION);
// clear and rebuild the animation list
lA = llDeleteSubList(lA,0,-1);
for ( i = 0; i < TotalA; i++ )
{
lA += llGetInventoryName(INVENTORY_ANIMATION,i);
}
// llStartAnimation(llList2String(lA, WHICH));
WHICH++;
if (WHICH >= TotalA)
{
WHICH = 0;
}
if (person == llGetOwner())
{
//llSetText("\n\n"+(string)FirstName+" has spanked their own ass!\n\n"+(string)FirstName+"'s ass has been spanked "+(string)Count+" times.",Vector_Color, 1);
return;
}
else
Count++;
user+="\n"+llKey2Name(person)+" has spanked that ass!\n\n"+(string)FirstName+"'s ass has been spanked "+(string)Count+" times.";
//llSetText("\n"+user,Vector_Color, 1);
}
run_time_permissions(integer permissions)
{
if (permissions == PERMISSION_TRIGGER_ANIMATION)
{
IHavePermission = TRUE;
}
}
timer()
{
if(llGetTime() > lT)
{
llSetText("",Vector_Color, 1);
llSetTimerEvent(0.0);
}
}
}