Jump to content

LSL_Help_Post_10


You are about to reply to a thread that has been inactive for 1266 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Buttons are not showing on payment

 

string UserName = "childhoodbestfriend489"; // change this to your main avatar's name
 
list dialogAmounts = ["1","5","10","20"];
integer balance = 0;
integer total;
integer opChannel;
integer listenHandle;
 
presentDialog()
{
    opChannel = llFloor((llFrand(1000000) * -1)-1000000);   // creates random operation channel to
                                                            // prevent spying on withdrawal amounts
    listenHandle = llListen(opChannel, "", llName2Key(UserName), "");
    llSetTimerEvent(60);
    llTextBox(llName2Key(UserName), "Balance: L$"+(string)balance+"\n \nType amount to withdraw.",opChannel);
}
  
removeListens()
{
    llListenRemove(listenHandle);
    llSetTimerEvent(0);
}
 
updateText()
{
    string str = UserName + "'s Tip Jar\n";
    if( total>0 )
        str+= (string)total + " donated so far.";
    else
        str+= "Empty";
    
    llSetText(str, <0,1,0>, 1);
}
default
{
    on_rez(integer omitted)
    { 
    llResetScript(); 
    }
 
    state_entry()
    {
        llSetPayPrice(0,dialogAmounts);
        updateText();
        opChannel = llFloor((llFrand(1000000) * -1)-1000000);
        llRequestPermissions(llGetOwner(),PERMISSION_DEBIT);
    }
 
    touch_start(integer number_detected)
    {
        integer n;
        for(;n<number_detected;++n)
        {
            if(llDetectedKey(n)==llName2Key(UserName))
            {
                if(balance==0)llDialog(llName2Key(UserName), "Balance: L$0", [], opChannel);
                else
                {
                    presentDialog();
                }
            }
        }
    }
 
    listen( integer channel, string name, key id, string message )
    {
        removeListens();
        integer amountToGive = (integer)message;
        llGiveMoney(llName2Key(UserName), amountToGive);
        balance -= amountToGive;
        llInstantMessage(llName2Key(UserName), "New balance = L$"+(string)balance);
    }
 
    money(key id, integer amount)
    {
        if(id == llName2Key(UserName)) // only display balance if money came from you
        {
            balance += amount;
            llInstantMessage(llName2Key(UserName), "New balance = L$"+(string)balance);
        }
        else    // remove this else block if you want to allow other people
                // to put money into your safe
        {
            balance += amount;
            llSay(0, "Thanks for the "+(string)amount+llKey2Name(id));
            total+=amount;
            updateText();
        }
    }
 
    timer()
    {
        llInstantMessage(llName2Key(UserName), "timed out");
        removeListens();
    }
}

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1266 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...