Build, Learn, Shop, Hangout
Posts tagged script
How to: Make an Online/Offline Indicator
Mar 5th
Learn how to script an online/offline indicator that accepts inventory from people. The information about the different commands is embedded directly in the code.
This begining level scrip will cover some basics of the following commands
- llSetTimerEvent
- llAllowInventoryDrop
- llListen
- llOwnerSay
- llResetScript
- llRequestAgentData
- llGetOwner
- llKey2Name
- llSetText
- llSetColor
and the following event handlers
- listen
- timer
- on_rez
- dataserver
Information will primarly pertain to the specifics needed for this event.
Give items in world from a web page!
Dec 7th
With SLX now charging for freebies (d-bags) I was thinking it would be nice to give items right from the web. The first problem was many web pages limit the code you can put in to a page. Next issue was keeping it simple so anyone can use it, and this is what I came up with the Web Freebie Giver. This is licensed under GPLv3, please click the link for the details, but basically you are free to use it as you wish, any changes need to be given back to the project. The code is available at google code, or in world at Fermi Sandbox. If you wish to contribute to this project please contact Arthur Fermi. More >
Fermi Single Item Vendor Code
Dec 7th
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();
}
}