Jump to content

help with code


Devone Carter
 Share

Recommended Posts

please help, im stuck
i wanted to make a captcha

at the moment it dont realy work because too many buttons causes the script to crash but thats alright.

 

heres the problem

 

when a person sits

i wanted to pick 9 random words from the menu_choices and display it on the menu < i dunno how

then display 1 random word as yellow floating text

 

then the user must choose the correct word otherwise they unsat

 

 

integer menu_channel;
integer menu_handler;

list menu_choices = ["SOAK","GALAXY","PAWS","FOOT","HOWL","BIKE","COMET","SUGAR","DINO","SUN","SOAK","MOON","CANDY","STAR","BIRD","DOG","CAR","CAT","BOAT","SHOE","TRUCK","BARK",
"FLOAT","BOOT","SWEET","OWL","STARS","COMET","BIKE","DINO"];

menu(key user,string title,list buttons)
{
    clean();
    menu_channel = (integer)(llFrand(99999.0) * -1);
    menu_handler = llListen(menu_channel,"",user,"");
    llDialog(user,title,buttons,menu_channel);
    llSetTimerEvent(15.0);
}
clean()
{
    llSetTimerEvent(0.0);
    llListenRemove(menu_handler);
}

default
{

    listen(integer channel, string name, key id, string message)
    {
}

    timer()
    {
        llSetTimerEvent(0.0);
        clean();
    }
    
    changed(integer change)
    {
        if(change & CHANGED_LINK)
        {
        if (llAvatarOnSitTarget() != NULL_KEY) {
        
        list randomizedList;
        randomizedList = llListRandomize(menu_choices, 0);
        
        menu(llAvatarOnSitTarget(),"\n \nTo earn you must select the word shown in\nyellow floating text from the buttons below.\n \nYou have 15 seconds to select an answer.",randomizedList);
        }
     }
}
}

Link to comment
Share on other sites

thanks i managed to do what i want,

now i got new problems

 

i have a peice of furniture with 3 poeballs linked, they all contain the same scripts

and its causing them to interfere,

 

for example im sitting on 1 poseball ive already answered the captcha successfully,

then another person sits down besides me... and its giving me the captcha question again.

 

i got this issue with multiple scripts not just the captcha one,

i beleive its to do with this line and llAvatarOnSitTarget()

 

        if ((change & CHANGED_LINK) == 2) < linknumber possibly changes when i sit down?

        if ((change & CHANGED_LINK) == CHANGED_LINK)


dont matter what i try i cant seem to make it work the way it should how do other furniture makers manage hmm

 

*EDIT* 5 hours later & i just discovered "llAvatarOnLinkSitTarget" dunno if it`ll be the answer to all my problems yet tho we`ll see

 

nope still happening :(

Link to comment
Share on other sites

i see one of the problems

 

so im sitting on linknumber2

my friends sitting on linknumber3

he stands up

im presented with the captcha menu again

 

obviusly because thiers been a link change and linknumber2 still isnt blank because im still sitting thier

which is why its happening

 

but even tho i know that what can i possibly do about it hmm ???

 

    changed(integer change)    {        if ((change & CHANGED_LINK) == CHANGED_LINK)          {        if (llAvatarOnLinkSitTarget(2) != NULL_KEY) {                 list randomizedList;        randomizedList =llList2List(llListRandomize(menu_choices,0),0,8);                menu(llAvatarOnLinkSitTarget(2),"\n \nTo earn you must select the word shown in\nyellow floating text from the buttons below.\n \nYou have 15 seconds to select an answer.",randomizedList);       randomizedList = llListRandomize(randomizedList, 0);       randomWord = llList2String(randomizedList, 0);       llSetText(randomWord, <1,1,0>, 1.0);        }       if (llAvatarOnLinkSitTarget(2) == NULL_KEY) {        {       clean();         llSetText("Camp", <1,1,1>, 0.6);       }}

 

Link to comment
Share on other sites

Try something based on this.   I've not tested it but I have used the concept before in similar circumstances:

 

list seated;//Gets the link number of a seated avatar//from http://wiki.secondlife.com/wiki/LlAvatarOnSitTargetinteger GetAgentLinkNumber(key avatar){	integer link_num = llGetNumberOfPrims();	while (link_num > 1) // Check only child prims.	{		if (llGetLinkKey(link_num) == avatar) // If it is the avatar we want		{			return link_num; // then return the link number		}		--link_num; // else go on with next child.	}	// Avatar wasn't found	return FALSE; // 0 (zero) for easy testing.}default{	state_entry()	{		//llSay(0, "Hello, Avatar!");	}	changed(integer change)	{		if (change & CHANGED_LINK){			key k = llGetLinkKey(llGetNumberOfPrims());//the last seated avatar, if people are sitting			if (llGetAgentSize(k)!=ZERO_VECTOR){//check it's an avatar and not a prim				if (!~llListFindList(seated,[k])){//and it's not an avatar on my list,so we don't spam people					seated+=[k]; //add him to the list					// do captcha stuff				}			}			//now, in case someone's got off			if (seated !=[]){//if the seated list isn't empty				integer max = llGetListLength(seated)-1;				do {					if (GetAgentLinkNumber(llList2Key(seated,max))==FALSE){ //that avatar is no longer sitting on me						seated = llDeleteSubList(seated,max,max);//so remove the avatar from the list					}				}				while(--max>-1);			}		}	}}

 

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...