I made this script earlier sometime and now I decided to open the code here. though it still needs improvements.
it is basically note card configured, menu driven, multi item, multi price, split proceeds vendor
Bear in mind that;
1. I am still considering myself as novice in scripting
2. it wasn't tested enough
3. it really needs improvements
here is the code
Vendor script:
//1prim vendor script, written by ilayda Reina in November 01, 2008.
//This script is released for free use by anyone.
key id;
string mess ;
list menu = ["<< PREV","CANCEL","NEXT >>"];
integer chan;
integer h;
integer index;
string notecardName;
key notecardQuery;
integer notecardIndex;
list notecardList;
integer price;
string itemName;
key partner=""; //place the AV key of your partner
integer split;
//=======================================================
dialog()
{
id = llDetectedKey(0);
chan = llFloor(llFrand(100000.0)) + 1000;
llListenRemove
;h = llListen(chan, "",id, ""
;llDialog(id,"Current item ;\n" + mess,menu,chan);
}
//======================================================================================
displayItem()
{
string textureName = llList2String(notecardList,index*4);
itemName = llList2String(notecardList,(index*4)+1);
string p = llList2String(notecardList,(index*4)+2);
mess = llList2String(notecardList,(index*4)+3);
price = (integer)p;
string display = itemName + "\nL$" + p;
llSetText(display, <1,1,1>, 1);
llMessageLinked(LINK_THIS , 0, ":"+display, NULL_KEY);
llSetLinkPrimitiveParams(0,[PRIM_TEXTURE, 1, textureName, <1,1,1>, <0,0,0>, 0 ]);
llSetPayPrice(PAY_HIDE, [price, PAY_HIDE, PAY_HIDE, PAY_HIDE]);
}
//======================================================================================
default
{
state_entry()
{
if( llGetListLength(notecardList)==0 )
{
notecardName = "Config";
state loading;
}
else
{
index = 0;
displayItem();
}
}
touch_start(integer total_number)
{
dialog();
}
listen( integer channel, string name, key id, string message )
{
if (message == "<< PREV"

{
index--;
llDialog(id,"Current item ;\n" + mess,menu,chan);
}
if (message == "NEXT >>"

{
index++;
llDialog(id,"Current item ;\n" + mess,menu,chan);
}
if (message == "CANCEL"

{
llListenRemove
; }
if(index>=(llGetListLength(notecardList)/4) )
index = 0;
if(index<0 )
{
index = (llGetListLength(notecardList)/4);
index--;
}
displayItem();
}
money(key id, integer amount)
{
if( amount>=price )
{
split = (integer)llGetObjectDesc();
llGiveInventory(id,itemName);
llSay(0,"Thanks for your purchase!"
;integer splitted=(price*split)/100;
llGiveMoney(partner,splitted);
llInstantMessage(partner,"You have been payed L$ " + ((string)splitted) + " by " + llGetObjectName());
}
}
}
//================================================================================
state loading
{
state_entry()
{
llSay(0,"Hold on, loading product data..."
;notecardIndex = 0;
notecardQuery = llGetNotecardLine(notecardName,notecardIndex++);
}
dataserver(key query_id, string data)
{
if ( notecardQuery == query_id)
{
if (data == EOF)
{
llSay(0,"Products loaded..."
;state default;
}
else
{
notecardList += [data];
notecardQuery = llGetNotecardLine(notecardName,notecardIndex++);
}
}
}
}
Notecard format
texture1
product1
500
Description for product 1
texture2
product2
300
Description for product 2
