Second Life Copybot
Simple paysplit vendor - Printable Version

+- Second Life Copybot (https://secondlifecopybot.com)
+-- Forum: SECOND LIFE PRODUCTS (https://secondlifecopybot.com/forum-1.html)
+--- Forum: SCRIPTS (https://secondlifecopybot.com/forum-1022.html)
+---- Forum: SCRIPTS (https://secondlifecopybot.com/forum-8.html)
+----- Forum: Business Scripts (https://secondlifecopybot.com/forum-44.html)
+----- Thread: Simple paysplit vendor (/thread-13355.html)



Simple paysplit vendor - wootwoot - 06-28-2016

Code:
// PUT HERE THE PRICE OF THE PRODUCT
integer PRICE = 10;

// PUT HERE THE PERCENTAGE TO PAY THE OTHER AVATAR ON SALE
integer RECEIVER_PERCENT = 25;

// PUT HERE THE KEY OF THE AVATAR INSIDE OF THE QUOTES
key RECEIVER = "00000000-0000-0000-0000-000000000000";

////-----------------------------------------------------------------------------------------------------------------
////-----------------------------------------------------------------------------------------------------------------
////-----------------------------------------------------------------------------------------------------------------
////---------------------------------- DO NOT CHANGE BELOW ----------------------------------------------------------
////-----------------------------------------------------------------------------------------------------------------
////-----------------------------------------------------------------------------------------------------------------
////-----------------------------------------------------------------------------------------------------------------

integer have_perms() {
    return ((llGetPermissions() & PERMISSION_DEBIT) == PERMISSION_DEBIT) && llGetPermissionsKey() == llGetOwner();
}

get_perms() {
    if(PRICE != 0) {
        if(!have_perms()) {
            llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);            
        } else {
            set_price();
        }
    }
}

set_price() {
    if(PRICE != 0) {
        llSetPayPrice(PAY_HIDE, [PRICE, PAY_HIDE, PAY_HIDE, PAY_HIDE]);
    }
}

init() {
    llSetPayPrice(PAY_HIDE, [PAY_HIDE, PAY_HIDE, PAY_HIDE, PAY_HIDE]);
    get_perms();
}

default {
    state_entry() {
        init();
    }

    run_time_permissions(integer perm) {
        if(perm & PERMISSION_DEBIT) {
            set_price();
        }
    }

    on_rez(integer start_param) {
        init();
    }

    changed(integer change) {
        if(change & (CHANGED_REGION_START|CHANGED_TELEPORT|CHANGED_OWNER|CHANGED_REGION)) {
            init();
        }
    }

    money(key id, integer amount) {
        if(amount == PRICE) {
            if(RECEIVER != NULL_KEY && RECEIVER_PERCENT > 0) {
                integer fee = llRound(((float)PRICE * (float)RECEIVER_PERCENT) / (float)100);
                if(have_perms()) {
                    llGiveMoney(RECEIVER, fee);
                } else {
                    llInstantMessage(llGetOwner(), "Missing payment permissions you need to pay secondlife:///app/agent/" + (string)RECEIVER  + "/about $"+ (string) fee);
                }
            }

            integer i = 0;
            integer count = llGetInventoryNumber(INVENTORY_ALL);
            list items = [];
            string self = llGetScriptName();
            for(;i < count; ++i) {
                string n = llGetInventoryName(INVENTORY_ALL, i);
                if(n != self) {
                    items += [n];
                }
            }
            if(llGetListLength(items) > 0) {
                if(llGetListLength(items) > 1) {
                    llGiveInventoryList(id, llGetObjectName(), items);
                } else {
                    llGiveInventory(id, llList2String(items, 0));
                }
            }
        }
    }
}



RE: Simple paysplit vendor - Summer - 06-28-2016

Thanks:ThumbsUp: