Build, Learn, Shop, Hangout
Fermi Single Item Vendor Code
This is the code for the single item vendor its very old, probably could use some help but I’m sure someone can use it. All that is needed to make this functional is to copy the script, rez a prim, create a new script in the prim, delete everything out of the script and paste this in.
// Global Variables
string gstrDisplay; // Name of the Item to be Sold
string gstrNotecard; // Notecard to give out
integer gintPrice; // Price of Item
list glstSplitWith; // Key of the person who you are spliting the sale with
list glstPictures; // Texture you want on the box
string gstrFloatYes;
vector vecFloatColor; // Color for floating text
string gstrThankYou; // Thank you message
key gstrQueryID; // DataServer Query Info
integer gstrLine; // DataServer Line Number to get
integer intNumPics; // Number of pictures
integer gintNoteLine; // Notecard Line #
integer gintCurPic; // Current Picture
integer gintDCC; // Dialog Comm Channel
//Get Inventory
funGetImages()
{
intNumPics=llGetInventoryNumber(0);
//Setup a loop
integer x = 0;
// Get Inventory and add it to the list
for (x; x < intNumPics; ++x)
{
glstPictures += [llGetInventoryName(0, x)];
}
}
funStartup()
{
// Get Images
funGetImages();
//Get Configuration Info
gstrNotecard = "_Item Config";
gstrQueryID = llGetNotecardLine(gstrNotecard, gintNoteLine);
// Set Pay Amounts
llSetPayPrice(PAY_HIDE, [gintPrice, PAY_HIDE, PAY_HIDE, PAY_HIDE]);
// Set Offline Text
llSetText("~ Offline ~", <1,0,0>, 1);
}
funOnOff(integer status)
{
if (status == 0)
{
// Off
llResetScript();
}
else if (status == 1)
{
// Get Permissions
llRequestPermissions(llGetOwner(),PERMISSION_DEBIT);
// Set Pay Amounts
llSetPayPrice(PAY_HIDE, [gintPrice, PAY_HIDE, PAY_HIDE, PAY_HIDE]);
// Set First Picture
llSetTexture(llList2String(glstPictures,0), 1);
gintCurPic = 0;
// Set Description
llSetObjectDesc("Fermi Designs - " + gstrDisplay + " - Price: " + (string)gintPrice + "L - Right Click to Pay");
if (gstrFloatYes == "Yes")
{
llSetText("Fermi Designs\n" + gstrDisplay + "\nPrice: " + (string)gintPrice + "L\n Right Click to Pay", vecFloatColor,1);
}
else
{
llSetText("", <1,1,1>, 1);
}
}
}
funPaySplits(integer amount)
{
integer intNumSplits = llGetListLength(glstSplitWith);
string strTempData;
key keyPay;
integer intPayAmount;
float fltPayPercent;
integer x = 0;
llOwnerSay((string)glstSplitWith);
if (intNumSplits == 0)
{
// do nothing, no splits
llOwnerSay("No Splits");
}
else
{
for (x; x < intNumSplits; ++x)
{
// Clear values
keyPay = "";
strTempData = "";
intPayAmount = 0;
//Get Split person pay
strTempData = llList2String(glstSplitWith, x);
//Parse Data
//Get Key
keyPay = llGetSubString(strTempData, 0, 35);
// Get Percentage
fltPayPercent = (float)llGetSubString(strTempData, llSubStringIndex(strTempData, "(") + 1,llSubStringIndex(strTempData, "%") - 1) / 100;
// Set Amount
intPayAmount = llCeil(amount * fltPayPercent);
// Pay the split
llGiveMoney(keyPay, intPayAmount);
//llOwnerSay("\nKey: " + (string)keyPay + "\nPrecent: " + (string)fltPayPercent + "\nPayAmount: " + (string)intPayAmount);
}
}
}
default
{
state_entry()
{
// Set Random dialog channel
gintDCC = llCeil(llFrand(10000.0));
llListen(gintDCC, "", llGetOwner(), "");
funStartup();
llSay(0, "Hello, Avatar!");
}
touch_start(integer total_number)
{
list lstMenu = ["LastPic", "Info", "NextPic","On","Off","Reset"];
if(llDetectedKey(0) == llGetOwner())
{
llDialog(llDetectedKey(0), "Please select your option", lstMenu, gintDCC);
}
else
{
llDialog(llDetectedKey(0), "Please select your option", ["LastPic", "Info", "NextPic"], gintDCC);
}
}
listen( integer channel, string name, key id, string message )
{
if (message == "NextPic")
{
if (gintCurPic + 1 > intNumPics)
{
gintCurPic = 0;
}
else
{
gintCurPic ++;
}
llSetTexture(llList2String(glstPictures, gintCurPic), 1);
llDialog(id, "Please select your option", ["LastPic", "Info", "NextPic"], gintDCC);
}
else if(message == "LastPic")
{
if (gintCurPic == 0)
{
gintCurPic = intNumPics;
}
else
{
gintCurPic --;
}
llSetTexture(llList2String(glstPictures, gintCurPic), 1);
llDialog(id, "Please select your option", ["LastPic", "Info", "NextPic"], gintDCC);
}
else if(message == "Info")
{
llGiveInventory(id, llGetInventoryName(INVENTORY_NOTECARD, 1));
llDialog(id, "Please select your option", ["LastPic", "Info", "NextPic"], gintDCC);
}
else if (message == "On")
{
funOnOff(1);
}
else if (message == "Off")
{
funOnOff(0);
}
else if (message == "Reset")
{
llResetScript();
}
}
dataserver(key query_id, string data)
{
if (query_id == gstrQueryID)
{
if (data != EOF)
{
if (gintNoteLine == 11)
{
gstrDisplay = data;
}
if (gintNoteLine == 14)
{
gintPrice = (integer)data;
}
if (gintNoteLine == 17)
{
gstrFloatYes = data;
}
if (gintNoteLine == 20)
{
vecFloatColor = (vector)data;
}
if (gintNoteLine == 23)
{
gstrThankYou = data;
}
if (gintNoteLine > 38)
{
glstSplitWith += [data];
}
}
++gintNoteLine;
gstrQueryID = llGetNotecardLine(gstrNotecard, gintNoteLine);
}
}
money(key giver, integer amount)
{
if (amount == gintPrice)
{
llGiveInventory(giver,llGetInventoryName(INVENTORY_OBJECT, 0));
funPaySplits(amount);
}
else
{
llGiveMoney(giver,amount);
llWhisper(0, "I'm sorry, that was in the incorrect amount. This item sells for " + (string)gintPrice + "L.");
}
}
on_rez(integer start_param)
{
llResetScript();
}
}
| Print article | This entry was posted by Arthur Fermi on December 7, 2009 at 1:51 pm, and is filed under Arthur Fermi. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |