Jump to content

Tip Jar Script with payment split and Must Be Present


pfctjoy
 Share

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

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

Recommended Posts

Hi,  a while back, I purchased a tip jar script that allows me to update it with the avatar names for payment splitting but also ensures that they have to be on the SIM in order to be paid.  Now I need another one and that person is not around or available.  Can anyone tell me or know where I could possibly find one similar.  Again I need to split the payment between the dancers/avi's, but they only get paid if they are working on sim. 

Link to comment
Share on other sites

What you need to do is to write a small script with http://wiki.secondlife.com/wiki/LlGetAgentSize - check if every avatar from the list is present, get the amount of avatars that are around and split the amount accordingly. Something like this, perhaps, may be a good base for further modifications.

string gThankYouMessage = "Thank you for your tip!";

string gNotecardName = "participants";
key gNotecardQueryId;
integer gNotecardLine;

list gParticipants;
integer gParticipantsLength;
integer gDebitPermns;

default
{

    on_rez(integer sp)
    {
        llResetScript();
    }

    state_entry()
    {
        llSetClickAction(CLICK_ACTION_PAY);
        llSetPayPrice(50, [PAY_DEFAULT, PAY_DEFAULT, PAY_DEFAULT, PAY_DEFAULT]);
        if (llGetInventoryKey(gNotecardName) == NULL_KEY)
        {
            llOwnerSay("Notecard '" + gNotecardName + "' missing or unwritten.");
            llSetMemoryLimit(llGetUsedMemory() + 2048);
        }
        else
        {
            gNotecardQueryId = llGetNotecardLine(gNotecardName, 0);
        }
        
    }

    dataserver(key query_id, string data)
    {
        if (query_id == gNotecardQueryId)
        {
            if (data == EOF)
            {
                gParticipantsLength = llGetListLength(gParticipants);
                llOwnerSay("Participants: " + (string)gParticipantsLength);
                if (gParticipantsLength)
                {
                    llOwnerSay("Accept debit perms for money splitting.");
                    llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);
                }
                llSetMemoryLimit(llGetUsedMemory() + 10240);
            }
            else
            {
                data = llStringTrim(data, STRING_TRIM);
                key uuid = (key)data;
                if (uuid)
                {
                    gParticipants += uuid;
                }
                ++gNotecardLine;
                gNotecardQueryId = llGetNotecardLine(gNotecardName, gNotecardLine);
            }
        }
    }

    run_time_permissions(integer perm)
    {
        if (perm & PERMISSION_DEBIT)
        {
            gDebitPermns = TRUE;
        }
    }

    changed(integer change)
    {
        if (change & (CHANGED_OWNER | CHANGED_INVENTORY))
        {
            llResetScript();
        }
    }

    money(key id, integer amount)
    {

        llRegionSayTo(id, 0, gThankYouMessage);

        if (!gDebitPermns || !gParticipantsLength)
        {
            return;
        }

        integer index;
        list present;
        while (index < gParticipantsLength)
        {
            key person = llList2Key(gParticipants, index);
            if (llGetAgentSize(person))
            {
                present += person;
            }
            ++index;
        }

        integer presentAmount = llGetListLength(present);
        if (presentAmount < 1)
        {
            return;
        }

        integer finalAmount;
        integer moduloTest = amount % presentAmount;
        if (moduloTest > 0)
        {
            finalAmount = (amount - moduloTest) / presentAmount;
        }
        else
        {
            finalAmount = amount / presentAmount;
        }

        if (finalAmount < 1)
        {
            return;
        }

        index = 0;
        while (index < presentAmount)
        {
            llGiveMoney(llList2Key(present, index), finalAmount);
            ++index;
        }

    }

}

 

Edited by panterapolnocy
  • Like 2
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1080 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...