Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Discussion: camping chair

Ante Flan
'yote
Join date: 14 Sep 2005
Posts: 46
12-05-2005 14:58
Let me start with saying that I'm not a very good scripter. You may notice a few shortcuts and stuff here that could have probably been handled more easily if I knew how. Also, this is edited from an example on the wiki and the comments are still in there. I made this because the only free camping chair I could find wasn't open source and sitting on it didn't quite work right (it works a bit better on this, but not well, for some reason. It seems to right itself a bit every timer event). But hey, it works, sorta, and I haven't seen an open-source camping chair anywhere out there, so yeah. Have it, edit it, do whatever with it.

CODE
integer campmoney = 0;
integer campadd = 2;
integer camptime = 300;
string reciever;
default {
state_entry() {
llRequestPermissions(llGetOwner(),PERMISSION_DEBIT);
llSetText("sit here for free money,\nL$"+(string)campadd+" every 5 minutes",<0,1,0>,1);
llSitTarget(<0.4, 0, 0.6>, ZERO_ROTATION); // needed for llAvatarOnSitTarget to work
// Note that if both the vector and the rotation are zero,
// the SitTarget is removed instead of set and the following will not work:
}

changed(integer change) { // something changed
if (change & CHANGED_LINK) { // and it was a link change
//llSleep(0.5); // llUnSit works better with this delay
if (llAvatarOnSitTarget() != NULL_KEY) { // somebody is sitting on me
reciever = llAvatarOnSitTarget();
llSetText("Money:"+(string)campmoney,<0,1,0>,1);
llSetTimerEvent(camptime);
//llSay(0, "Get off!");
//llUnSit(llAvatarOnSitTarget()); // unsit him
}
else{
llGiveMoney(reciever,campmoney);
reciever="";
campmoney=0;
llSetText("sit here for free money,\nL$"+(string)campadd+" every 5 minutes",<0,1,0>,1);
llSetTimerEvent(100000000);
}
}
}
timer()
{
campmoney = campmoney+campadd;
llSetText("Money:"+(string)campmoney,<0,1,0>,1);
if (llAvatarOnSitTarget() != NULL_KEY)
{
}
else
{
reciever="";
campmoney=0;
llSetText("sit here for free money,\nL$"+(string)campadd+" every 5 minutes",<0,1,0>,1);
llSetTimerEvent(100000000);
}
}
}
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Original Thread
12-06-2005 22:17
/15/60/75612/1.html
_____________________
i've got nothing. ;)
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
12-07-2005 06:50
You forgot the lines to unsit the guy and llDie() the camping chair.

What's next, people sharing spamming scripts on slashdot?
Issarlk Chatnoir
Cross L. apologist.
Join date: 3 Oct 2004
Posts: 424
12-14-2005 06:53
what happens if someone is seated on the chair, and another person sits down on it too ?
_____________________
Vincit omnia Chaos
From: Flugelhorn McHenry
Anyway, ignore me, just listen to the cow
Synergy Belvedere
Prim Reaper
Join date: 7 Jul 2004
Posts: 253
12-14-2005 07:52
I'm curious why you're setting the timer event to 100000000 when the chair is empty instead of just to zero? :confused:
_____________________
----------------------------------------------------------
--The mind's eye is limited only by its focus--
Ante Flan
'yote
Join date: 14 Sep 2005
Posts: 46
12-14-2005 10:28
I didn't know that 0 turned it off and I'm not sure how to keep more than 1 person off. I thought setting the sit position did it, but now I remember sitting on poles when people were already dancing on them, so I guess not. Again, as I said, I am not a scripter.
Kage Seraph
I Dig Giant Mecha
Join date: 3 Nov 2004
Posts: 513
12-14-2005 17:40
Ante, you can prevent additional avs from sitting on the object:

autounseater

This is a technique common to vehicles especially. Pop that script into any prim with a higher linknumber than the one with the proper money chair sittarget (probably the root prim (linknumber = 1) anyway).
Kamilion Schnook
Registered User
Join date: 26 Jan 2006
Posts: 18
Updated Version
03-21-2006 03:39
Since this thread hasn't seen an update in a while, I figured I'd stick in my fixed up version of this code. Don't laugh at my coding, I'm still a newb, but this one's commented to the gills for anyone to look at and hopefully understand.

Thanks to the original author, whomever they are -- I've hacked up this code every which way for several projects (none of them camping chairs) that just needed to handle money without a whole buttload of code.

CODE

integer campmoney = 0; // Initial amount to grant someone upon the VERY first sit after first rez. (Think, Special bonus)
integer campadd = 2; // Payout amount
integer camptime = 600; // Payout time in seconds (Script USES this)
string camptimeM = "10"; // Payout time in minutes (Attract SAYS this)
string reciever; // key of Sitter
default {
state_entry() {
llRequestPermissions(llGetOwner(),PERMISSION_DEBIT ); //Ask my owner for permission to give money and assume it suceeds
llSetText("sit here for free money,\nL$"+(string)campadd+" every "+camptimeM+" minutes",<0,1,0>,1); // Set the hovertext to attract mode
llSitTarget(<0.4, 0, 0.6>, ZERO_ROTATION); // needed for llAvatarOnSitTarget to work
// Note that if both the vector and the rotation are zero,
// the SitTarget is removed instead of set and the following will not work:
}

changed(integer change) { // something changed
if (change & CHANGED_LINK) { // and it was a link change
if (llAvatarOnSitTarget() != NULL_KEY) { // if Avatar key isn't empty, somebody is sitting on me
reciever = llAvatarOnSitTarget(); // store sitting avatar's key
llSetText("Money: L$"+(string)campmoney,<0,1,0>,1); // Setting hovertext to current amount earned
llSetTimerEvent(camptime); // amount of time between payments in seconds
//llSay(0, "Get off!");
//llUnSit(llAvatarOnSitTarget()); // unsit him
}
else{ // if the avatar has gotten up
llGiveMoney(reciever,campmoney); // give the avatar the amount of money he has earned.
reciever=""; // forget who the receiver was
campmoney=0; // reset earning count to 0
llSetText("sit here for free money,\nL$"+(string)campadd+" every "+camptimeM+" minutes",<0,1,0>,1); // change the hovertext back to attract mode
llSetTimerEvent(0); // Nobody is sitting on me, so no need to call timer(). Disable timer.
}
}
}
timer()
{
campmoney = campmoney+campadd; // current amount + xL$ per camptime
llSetText("Money: L$"+(string)campmoney,<0,1,0>,1); // update hovertext with currently earned amount
if (llAvatarOnSitTarget() != NULL_KEY) {} // If there's someone sitting on me, Do Nothing, ELSE

else { // Noone's sitting on me, reset the vars
reciever=""; // forget who the receiver was
campmoney=0; // reset earning count to 0
llSetText("sit here for free money,\nL$" + (string)campadd + " every "+camptimeM+" minutes",<0,1,0>,1); // change hovertext back to attract mode
llSetTimerEvent(0); // Nobody is sitting on me, so no need to call myself anymore. Disable timer.
}
}
}
InuYasha Meiji
Half Demon
Join date: 14 Mar 2005
Posts: 127
Error..
07-24-2006 03:41
Seems I don't understand the functions of getting and giving money, well enough to fix the problem with your code. but something appears wrong here.

Everytime My wife and I try this script on a seat of a chair, it appears to work until we get up. Yes, one at a time, but I wanted to have both of us test it. I thought it was possible that only I would get the error, since I am the owner and it was trying to both take and give money to the owner.

I get the erro ,";(money chair): Invalid parameter in llGiveMoney()." What could be wrong, there are only two parameters.

Could someone explain, is anyone else having this problem?

I FOUND MY OWN ANSWER:

I have to add an if statement that says something about if campmoney is less then 1 then don't attempt to give money. Because, once either of us stayed on long enough to actually make any money, then it worked great. But if we had a zero amount to pay out, then it generated the error.

At least this solves the trouble for anyone else who might have wondered about this.

-InuYasha Meiji

Thanks for listening
Tyler Polano
Registered User
Join date: 10 Jul 2006
Posts: 3
08-21-2006 18:48
so how would i go about setting this script to my name, so that it takes the money out of my account when someone gets up...?
Norman Desmoulins
Grand Poohba
Join date: 10 Nov 2005
Posts: 194
08-21-2006 19:33
Create a new script, copy that code into it, and then place the script into a chair/object that you own. It will prompt you for permission to take money from you.
Allatu Augustus
Allatu Agustus
Join date: 19 Nov 2005
Posts: 32
how to add
10-03-2006 07:25
what would i add to make this chair pay out to only group members please tell me what to add and where to add it at :D ty
Taffy Brannan
Registered User
Join date: 4 Sep 2006
Posts: 2
quick question
10-07-2006 15:56
how do i start a script?
Bree Giffen
♥♣♦♠ Furrtune Hunter ♠♦♣♥
Join date: 22 Jun 2006
Posts: 2,715
10-07-2006 17:48
Scripts usually start running as soon as you save them or as soon as you rez an object containing the script. You can also edit your script and make sure the 'running' box is checked.
_____________________
Smoke Clifton
Registered User
Join date: 6 Jun 2006
Posts: 3
10-16-2006 19:07
i'm a tad thick

Do either of these scripts have the mentioned auto kicking function implemented in them and if so what do i change to set it to a different amount of time?

thanks

oh if they dont, can someone tell me how to add it to these scripts please :))
Jason Hashimoto
Resident Pancake Expert
Join date: 30 Aug 2006
Posts: 11
Updated Script, Still Needs Help!
12-04-2006 00:01
CODE
integer campadd = 2; // Amount to pay each cycle.
integer camptime = 1; // Payout time in minutes.
integer maxtime = 2; //Maximum amount of cycles camper can sit without being kicked.


//DO NOT Edit below this line unless you know what your doing. You have been warned.
//If you don't know what your doing, and are gunna edit this anyway, make sure to back up the original.
integer x;
integer campmoney = 0;
integer camptimeMin;
string camptimeM;
string reciever;
vector deg = < 90 , 0 , -90 >;
vector offset = < 0.0, -0.5 , -0.5>;
integer totaltime;




default {
state_entry()
{
camptimeM = (string)camptime;
x = camptime*60;
camptime = x;
deg *= DEG_TO_RAD;
rotation quat = llEuler2Rot( deg );
llRequestPermissions(llGetOwner(),PERMISSION_DEBIT);
llSetText("Sit here to earn free money,\nL$" + (string)campadd + " every "+camptimeM+" minutes!!",<0,1,0>,1);
llSitTarget(offset, quat);

}

changed(integer change)
{ // something changed
if (change & CHANGED_LINK) { // and it was a link change
if (llAvatarOnSitTarget() != NULL_KEY)
{
reciever = llAvatarOnSitTarget();
llSetText("Money: L$"+(string)campmoney,<0,1,0>,1);
llSetTimerEvent(camptime);
}
else if (llAvatarOnSitTarget() == NULL_KEY)
{ // if the avatar has gotten up

if (campmoney<0)
{
llGiveMoney(reciever,campmoney); // give the avatar the amount of money he has earned.
reciever=""; // forget who the receiver was
campmoney=0; // reset earning count to 0
llSetText("Sit here to earn free money,\nL$" + (string)campadd + " every "+camptimeM+" minutes!!",<0,1,0>,1);
llSetTimerEvent(0); // Nobody is sitting on me, so no need to call timer(). Disable timer.
}
else if (campmoney<0)
{
llSay(0, "Sorry, you where not sitting here long enough to earn any money :(");
}
}
}
}
timer()
{
totaltime = totaltime+1;
if (totaltime < maxtime)
{
campmoney = campmoney+campadd; // current amount + xL$ per camptime
llSetText("Money: L$"+(string)campmoney,<0,1,0>,1); // update hovertext with currently earned amount
if (llAvatarOnSitTarget() != NULL_KEY) {} // If there's someone sitting on me, Do Nothing, ELSE
else if(llAvatarOnSitTarget() == NULL_KEY)
{ // Noone's sitting on me, reset the vars
reciever=""; // forget who the receiver was
campmoney=0; // reset earning count to 0
llSetText("Sit here to earn free money,\nL$" + (string)campadd + " every "+camptimeM+" minutes!!",<0,1,0>,1); // change hovertext back to attract mode
llSetTimerEvent(0); // Nobody is sitting on me, so no need to call myself anymore. Disable timer.
}
else if (totaltime > maxtime)
{
llUnSit(reciever);
reciever=""; // forget who the receiver was
campmoney=0; // reset earning count to 0
llSetText("Sit here to earn free money,\nL$" + (string)campadd + " every "+camptimeM+" minutes!!",<0,1,0>,1); // change hovertext back to attract mode
llSetTimerEvent(0); // Nobody is sitting on me, so no need to call myself anymore. Disable timer.
}
}

}
}
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
12-04-2006 10:18
Isnt this just a rehash of what we previosuly covered in Camping Chair help ????
Jason Hashimoto
Resident Pancake Expert
Join date: 30 Aug 2006
Posts: 11
12-04-2006 14:44
I don't think so, I looked on all those scripts and didn't see anything diffrent as in it would refresh as soon as somebody stands up, and this is what I am trying to figure out how to do. I might have missed something though.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
12-04-2006 15:14
From: Jason Hashimoto
I don't think so, I looked on all those scripts and didn't see anything diffrent as in it would refresh as soon as somebody stands up, and this is what I am trying to figure out how to do. I might have missed something though.


May be my heads a bit fuzzy today, what feature(s) is it taht you are trying to implement?
Jason Hashimoto
Resident Pancake Expert
Join date: 30 Aug 2006
Posts: 11
12-17-2006 10:34
I made a mistake and accidentally deleted part of the script lol. I fixed it now.
Thaleenin Sydney
Registered User
Join date: 20 Nov 2006
Posts: 10
this works now
12-23-2006 16:03
// Camping Chair (working verion)
// found in the forums at /54/07/75897/1.html
// fixed problem of it not paying out by Delion Leroux

integer campadd = 2; // Amount to pay each cycle.
integer camptime = 1; // Payout time in minutes.
integer maxtime = 2; //Maximum amount of cycles camper can sit without being kicked.


//DO NOT Edit below this line unless you know what your doing. You have been warned.
//If you don't know what your doing, and are gunna edit this anyway, make sure to back up the original.
integer x;
integer campmoney = 0;
integer camptimeMin;
string camptimeM;
string reciever;
vector deg = < 90 , 0 , -90 >;
vector offset = < 0.0, -0.5 , -0.5>;
integer totaltime;




default {
state_entry()
{
camptimeM = (string)camptime;
x = camptime*60;
camptime = x;
deg *= DEG_TO_RAD;
rotation quat = llEuler2Rot( deg );
llRequestPermissions(llGetOwner(),PERMISSION_DEBIT );
llSetText("Sit here to earn free money,\nL$" + (string)campadd + " every "+camptimeM+" minutes!!",<0,1,0>,1);
llSitTarget(offset, quat);

}

changed(integer change)
{ // something changed

if (change & CHANGED_LINK) { // and it was a link change

if (llAvatarOnSitTarget() != NULL_KEY)
{
reciever = llAvatarOnSitTarget();
llSetText("Money: L$"+(string)campmoney,<0,1,0>,1);
llSetTimerEvent(camptime);
}
else if (llAvatarOnSitTarget() == NULL_KEY)
{ // if the avatar has gotten up

if (campmoney>0)
{
llGiveMoney(reciever,campmoney); // give the avatar the amount of money he has earned.
reciever=""; // forget who the receiver was
campmoney=0; // reset earning count to 0
llSetText("Sit here to earn free money,\nL$" + (string)campadd + " every "+camptimeM+" minutes!!",<0,1,0>,1);
llSetTimerEvent(0); // Nobody is sitting on me, so no need to call timer(). Disable timer.
}
else if (campmoney<0)
{
llSay(0, "Sorry, you where not sitting here long enough to earn any money :(";);
}
}
}
}
timer()
{
totaltime = totaltime+1;
if (totaltime < maxtime)
{
campmoney = campmoney+campadd; // current amount + xL$ per camptime
llSetText("Money: L$"+(string)campmoney,<0,1,0>,1); // update hovertext with currently earned amount
if (llAvatarOnSitTarget() != NULL_KEY) {} // If there's someone sitting on me, Do Nothing, ELSE
else if(llAvatarOnSitTarget() == NULL_KEY)
{ // Noone's sitting on me, reset the vars
reciever=""; // forget who the receiver was
campmoney=0; // reset earning count to 0
llSetText("Sit here to earn free money,\nL$" + (string)campadd + " every "+camptimeM+" minutes!!",<0,1,0>,1); // change hovertext back to attract mode
llSetTimerEvent(0); // Nobody is sitting on me, so no need to call myself anymore. Disable timer.
}
else if (totaltime > maxtime)
{
llUnSit(reciever);
reciever=""; // forget who the receiver was
campmoney=0; // reset earning count to 0
llSetText("Sit here to earn free money,\nL$" + (string)campadd + " every "+camptimeM+" minutes!!",<0,1,0>,1); // change hovertext back to attract mode
llSetTimerEvent(0); // Nobody is sitting on me, so no need to call myself anymore. Disable timer.
}
}

}
}
Justin Slade
Registered User
Join date: 6 Feb 2007
Posts: 132
parameter
05-13-2007 17:48
did yiou fix this invalid parameter in llgivemoney and what was the solution. Thanks
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
05-14-2007 03:46
From: Justin Slade
did yiou fix this invalid parameter in llgivemoney and what was the solution. Thanks



receiver is/was being declared as a string when it should be a key.
_____________________
I'm back......
Justin Slade
Registered User
Join date: 6 Feb 2007
Posts: 132
double vision
05-14-2007 14:29
I see he took care of the llgivemoney, but he must of really been working hard on this one.

reciever=""; // forget who the receiver was
campmoney=0; // reset earning count to 0
llSetText("Sit here to earn free money,\nL$" + (string)campadd + " every "+camptimeM+" minutes!!",<0,1,0>,1); // change hovertext back to attract mode
llSetTimerEvent(0); // Nobody is sitting on me, so no need to call myself anymore. Disable timer.

listed twice..made my eyes hurt.....

But still didn't address the issue of refresh after unsitting and money given....I believe that's what he was asking and working on.