Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

i cant do this :(

Cheery Chippewa
Registered User
Join date: 8 Nov 2006
Posts: 4
06-16-2007 18:46
hello, ok i have this script for a prize giving chair, i wanted one for my mall but i really wanna make it myself, since i gave up with the money camping one i thought a prize one might be more fun, anyway, i got this script, but you gotta edit the script its self to set it up, ive been trying to make it so you can set it by note card but id really like a menu if its possible, mind you you have to put in the name of the prize so how you would do that by menu is beyond me, ive looked at other scripts with menues and omg, complicated or what?


so any advice of help would be cool, heres what i have, the first bit about the note card is what i added, but as far as i know i messed it up, though it compiles ok so i dunno, im new at this hehe




string gNotecard = "Prize Chair Configuration";
integer gLine = 0;

integer timeToGive1 = 300; // Time required for campers to camp (in seconds)
string prize1 = ""; // The name of the prize (must be in the camp chair's inventory)
integer ctlChannel = 12; // Control channel, default is 12321, MUST CHANGE THIS!!!
// Type /12 kick in chat to kick the camper off
// Remember to setup difference channels or all camp chairs nearby will kick their campers


// Internal Veriables
integer sitTime = 0;
key sitter;
string sitterName;

default
{
state_entry()
{
if (prize1 == "";)
{
prize1 = llGetInventoryName(INVENTORY_OBJECT,0);
}
llSitTarget(<0.3,0,-0.4>,<1,0,0,0>;);
llSetText("Ready for camping\nSit here for "+(string) (timeToGive1 / 60)+"minute(s) to get "+prize1+" for free!",<1,1,1>,1);
sitTime = 0;
sitter = NULL_KEY;
sitterName = "No one";
}
changed(integer change)
{
if (change & CHANGED_LINK) {
key target = llAvatarOnSitTarget();
if (target) {
sitter = target;
sitterName = llKey2Name(target);
state sitting;
}
}
}
}

state sitting
{
state_entry()
{
llSetTimerEvent(1.0);
llListen(ctlChannel,"",NULL_KEY,"";);
}
listen(integer channel, string name, key id, string msg) {
if (channel == ctlChannel) {
if (msg == "kick";) {
llUnSit(sitter);
}
}
}
timer()
{
llSetText(" Chair in use\nOccupied by "+sitterName + "\nwill get "+prize1+" after " + (string) (timeToGive1 - sitTime) + " second(s)",<1,1,1>,1);
if (sitTime++ > timeToGive1) {
llGiveInventory(sitter,prize1);
llUnSit(sitter);
llSay(0,sitterName + ", thank you for camping, enjoy your prize!";);
state default;
}
}
changed(integer change)
{
if (change & CHANGED_LINK) {
if (llAvatarOnSitTarget() == NULL_KEY)
state default;
}
}
}
Jim Guyot
Tinkerer
Join date: 21 Apr 2007
Posts: 38
06-16-2007 19:55
If you'd like me to write you a script for this, just send me an IM in game. It will be fully documented and full perms. I'll even try to write a guide to using it.

I do have to say, however, it does look like it will work. One thing I would change is to initialize all the variables explicitly, instead of letting the script do it prior to the default state. While it doesn't happen often, sometimes it will set variables wrong.
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
06-16-2007 21:14
you need a dataserver event for the notecard data to return to

http://lslwiki.net/lslwiki/wakka.php?wakka=llGetNotecardLine
http://lslwiki.net/lslwiki/wakka.php?wakka=dataserver
Cheery Chippewa
Registered User
Join date: 8 Nov 2006
Posts: 4
06-18-2007 12:12
From: Osgeld Barmy



cool thankyou, but were do i put them? does it matter? sorry im pretty new to all this :)
Catherine Dollinger
Registered User
Join date: 11 May 2007
Posts: 26
06-19-2007 08:17
It seems as if there's a notecard intended to list different prizes, but not yet used in the script. Instead the item is hard coded in the prize1 initialization?
I'd say to put the dataserver in the initialization state and read the lines into a list, from which different prices could be selected over time - if that's what's intended.
If you just want to distribute one special item, you would not need a notecard for the setup.
Shadow Subagja
Registered User
Join date: 29 Apr 2007
Posts: 354
06-19-2007 11:01
I would skip the notecards and menus and use these features of lsl, or something similar. You could use the random number generator, or just loop through items like below (apologizes for a buggy script, I just typed it here and probably made lots of dumb typos). Obviously this isn't full featured, you'd have to put in the timers and the random name letter selection/checks etc from the other scripts.

integer prizeRotation = 0;
integer numPrizes = 0;
integer HAVE_PRIZES = FALSE;

default
{
state_entry()
{
numPrizes = llGetInventoryNumber(INVENTORY_OBJECT);
if(numPrizes >= 1)
{
prizeRotation = 0;
llSay(0, "I contain " + (string)numPrizes + " objects.";);
llSay(0, "I will start with prize" + llGetInventoryName(INVENTORY_OBJECT, 0) + " in my contents.";);
}
else
{
llSay(0, "I have no prizes, I will chill until you drop some objects in me";);
}
}


changed(integer change) { // something changed
if (change & CHANGED_LINK && (numPrizes >= 1))
{ // and it was a link change
key av = llAvatarOnSitTarget();
if (av)
{ // somebody is sitting on me
llSay(0, "I would love to give you a"+llGetInventoryName(INVENTORY_OBJECT, prizeRotation)+" from my inventory!";);
prizeRotation++;
if(prizeRotation >=numPrizes)
{
prizeRotation=0;
}
}
}
else if(changed & CHANGED_INVENTORY)
{
llResetScript(); //restart, get new counts etc.
}
}
}
Jano Debevec
Registered User
Join date: 28 May 2007
Posts: 87
Script for given the notecard to someone
06-27-2007 12:45
I would want to do the following: when someone click on my object he or she would get a notecard with specific content. What must I do?
Deanna Trollop
BZ Enterprises
Join date: 30 Jan 2006
Posts: 671
06-27-2007 13:32
Call llGiveInventory inside the touch_start event handler.

lslwiki.net/lslwiki/wakka.php?wakka=llGiveInventory
lslwiki.net/lslwiki/wakka.php?wakka=touch_start