Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- integer sell_type = INVENTORY_OBJECT;
- vector text_color = <1,1,1>;
- float text_alpha = 1;
- list items;
- list descriptions;
- list prices;
- integer notecardline;
- integer current_item;
- Next_Item()
- {
- current_item++;
- if(current_item >= llGetListLength(items))
- {
- current_item = 0;
- }
- llSetText(llList2String(descriptions,current_item) + "\n$L" + llList2String(prices,current_item),text_color,text_alpha);
- llSetTexture(llList2String(items,current_item) + "PIC",2);
- }
- default
- {
- state_entry()
- {
- llSetTexture("d2665d83-d5f5-d0a8-7fb7-89656f2d3f7a",ALL_SIDES);
- llSetText("Offline Mode, Nows the time to add/remove items, then click to start.",text_color,text_alpha);
- }
- touch(integer number)
- {
- if(llDetectedKey(0) == llGetOwner())
- {
- state check_items;
- }
- }
- }
- state check_items
- {
- state_entry()
- {
- llSetText("Checking inventory",text_color,text_alpha);
- if(llGetInventoryNumber(sell_type) == 0)
- {
- llOwnerSay("Nothing found in inventory. Reseting.");
- llResetScript();
- }
- if(llGetInventoryKey("_LIST") == NULL_KEY)
- {
- llOwnerSay("Could not find the _LIST notecard. Remeber the name of the notecard is important and CaSe sensitive.");
- llResetScript();
- }
- else
- {
- llGetNumberOfNotecardLines("_LIST");
- }
- }
- dataserver(key queryid, string data)
- {
- state setup_items;
- }
- on_rez(integer start_param)
- {
- llResetScript();
- }
- }
- state setup_items
- {
- state_entry()
- {
- llSetText("Please Wait, Loading Items List.",text_color,text_alpha);
- current_item = 0;
- notecardline = 0;
- llGetNotecardLine("_LIST",notecardline);
- }
- dataserver(key query_id, string data)
- {
- if (data != EOF)
- {
- integer item_mode = (notecardline - 0) % 2;
- if(item_mode == 0)
- {
- if(llGetInventoryKey(data) == NULL_KEY)
- {
- llOwnerSay("Item: " + data + " couldn't be found in inventory. Reseting");
- llResetScript();
- }
- else
- {
- if(llGetInventoryKey(data + "PIC") == NULL_KEY)
- {
- llOwnerSay("Couldn't find the picture for " + data + " named " + data + "PIC. Reseting.");
- llResetScript();
- }
- descriptions += [data];
- items += [data];
- }
- }
- else if(item_mode == 1)
- {
- prices += [data];
- }
- notecardline++;
- llGetNotecardLine("_LIST",notecardline);
- }
- else
- {
- state run_store;
- }
- }
- on_rez(integer start_param)
- {
- llResetScript();
- }
- }
- state run_store
- {
- state_entry()
- {
- llRequestPermissions(llGetOwner(),PERMISSION_DEBIT);
- current_item = 0;
- llSetText(llList2String(descriptions,0) + "\n$L" + llList2String(prices,0),text_color,text_alpha);
- llSetTexture(llList2String(items,0) + "PIC",ALL_SIDES);
- }
- on_rez(integer start_param)
- {
- llResetScript();
- }
- changed(integer type)
- {
- if(type & CHANGED_INVENTORY)
- {
- llResetScript();
- }
- }
- run_time_permissions(integer type)
- {
- if(type & PERMISSION_DEBIT)
- {
- }
- else
- {
- llOwnerSay("Permissions must be granted for refund setup incomplete. Reseting");
- llResetScript();
- }
- }
- touch(integer number)
- {
- Next_Item();
- }
- money(key giver, integer amount)
- {
- integer cost = (integer)llList2String(prices,current_item);
- if (amount == cost)
- {
- llInstantMessage(giver,"Thank you for your purchase!");
- llGiveInventory(giver,llList2String(items,current_item));
- }
- if (amount > cost)
- {
- integer change =0;
- llInstantMessage(giver,"Here is your change. Thank you for your purchase!");
- llGiveInventory(giver,llList2String(items,current_item));
- change = amount - cost;
- llGiveMoney(giver,change);
- }
- if (amount < cost)
- {
- llInstantMessage(giver, "Sorry, That's not enough to buy this item. It costs L$" + llList2String(prices,current_item));
- llGiveMoney(giver, amount);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement