Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Camping script

Storm Berjis
Registered User
Join date: 22 Sep 2006
Posts: 8
12-29-2007 20:08
I'm kinda a noob in scripting, so I got a script from a friend and i tried to twist it to suit the camping chair I was doing.
everything work fine unless I het an error message when it's time to pay.


integer campmoney = 0;
integer campadd = 0;
integer camptime = 300;
string reciever;
integer pula;
integer limit;
string gName = "Settings";
integer gLine = 0;
key gQueryID;
string anim;
default
{

dataserver(key query_id, string data)
{ if (query_id == gQueryID)
{ if (data != EOF)
{

if (gLine == 0)
{
campadd = (integer)data;
}
if (gLine == 1)
{
camptime = (integer)data;
pula = camptime/60;
}
if (gLine == 2)
{
limit = (integer)data;
}
if (gLine == 3)
{
anim = (string)data;
}
++gLine;
gQueryID = llGetNotecardLine(gName, gLine);
}
}

}

state_entry()
{
gQueryID = llGetNotecardLine(gName, gLine);


llRequestPermissions(llGetOwner(),PERMISSION_DEBIT);

llSetText("Sit here to Make Money .\nL$"+(string)campadd+" every "+(string)pula+" minutes",<0,1,0>,1);

llSitTarget(<0,0,-0.6>, <180,0,0,0>;);


}
changed(integer change)
{
if (change & CHANGED_LINK) {
if (llAvatarOnSitTarget() != NULL_KEY)

llRequestPermissions(llAvatarOnSitTarget(), PERMISSION_TRIGGER_ANIMATION);
reciever = llAvatarOnSitTarget();
llStopAnimation("sit";);
llStartAnimation(anim);
llSetText("Money Made:"+(string)campmoney,<0,1,0>,1);

llSetTimerEvent(camptime);

}
else{if (campmoney > 0) {
llGiveMoney(reciever,campmoney);}
reciever="";
campmoney=0;
llSetText("Sit here to Make Money .\nL$"+(string)campadd+" every "+(string)pula+" minutes",<0,1,0>,1);

llSetTimerEvent(100000000);
}
}

on_rez(integer start_param)
{llResetScript();

}

timer()
{ campmoney = campmoney+campadd;
llSetText("Money:"+(string)campmoney,<0,1,0>,1);
if (llAvatarOnSitTarget() != NULL_KEY)
{
if ( campmoney == limit ) {llUnSit(reciever);

llGiveMoney(reciever,campmoney);
llSetScriptState("Camping w notecard altered", FALSE);
llSetText("Money limit reached, this camping chair is now unavailabe",<0,1,0>,1);
}
}
else
{
reciever=llAvatarOnSitTarget();
campmoney=0;
llSetText("Sit here to Make Money .\nL$"+(string)campadd+" every "+(string)pula+" minutes",<0,1,0>,1);

llSetTimerEvent(100000000);
}
}
}


In fact the script refuse to pay when peoples stand from the seat.
I removed llRequestPermissions(llAvatarOnSitTarget(), PERMISSION_TRIGGER_ANIMATION);

and, in that case, the payement is done, but I got another error message.

Someone has a solution ?
Boss Spectre
Registered User
Join date: 5 Sep 2005
Posts: 229
12-29-2007 20:40
You are missing a brace "{" after:

if (change & CHANGED_LINK) {
if (llAvatarOnSitTarget() != NULL_KEY)

so make it read like this:

if (change & CHANGED_LINK) {
if (llAvatarOnSitTarget() != NULL_KEY)
{

I have not compiled to test but that woiuld prevent it from compiling.
Storm Berjis
Registered User
Join date: 22 Sep 2006
Posts: 8
01-01-2008 20:05
mmm, I tried, but my script is working, seems I can't set two permissions though.
Deanna Trollop
BZ Enterprises
Join date: 30 Jan 2006
Posts: 671
01-01-2008 20:56
From: Storm Berjis
seems I can't set two permissions though.
This is correct, a script cannot simultaneously have permissions from two different agents at any given time. Unless you're going to be available all the time to grant debit permission each time a new camper sits, you'll need two separate scripts, one for the anim (which requests anim permission from each new camper) and one for the payout (which requests debit permission from you only once, at startup).
Storm Berjis
Registered User
Join date: 22 Sep 2006
Posts: 8
01-02-2008 18:29
Ok, I did few modifications.

Code :

integer campmoney = 0;
integer campadd = 0;
integer camptime = 300;
integer pula;
integer limit;
string gName = "Settings";
integer gLine = 0;
key gQueryID;
string anim;
default {

dataserver(key query_id, string data)
{ if (query_id == gQueryID)
{ if (data != EOF)
{

if (gLine == 0)
{
campadd = (integer)data;
}
if (gLine == 1)
{
camptime = (integer)data;
pula = camptime/60;
}
if (gLine == 2)
{
limit = (integer)data;
}

++gLine;
gQueryID = llGetNotecardLine(gName, gLine);
}
}

}

state_entry() {
gQueryID = llGetNotecardLine(gName, gLine);
llRequestPermissions(llGetOwner(),PERMISSION_DEBIT);
llSetScriptState("simple pose ball", TRUE);

}
on_rez(integer start_param)
{llResetScript();

}
}



Code end


Code :

integer hidden = FALSE; // Stores whether the object is visible
integer campmoney = 0;
integer campadd = 0;
integer camptime = 300;
string avataronsittarget;
integer pula;
integer limit;
string gName = "Settings";
integer gLine = 0;
key gQueryID;
string anim;
default {

dataserver(key query_id, string data)
{ if (query_id == gQueryID)
{ if (data != EOF)
{

if (gLine == 0)
{
campadd = (integer)data;
}
if (gLine == 1)
{
camptime = (integer)data;
pula = camptime/60;
}
if (gLine == 2)
{
limit = (integer)data;
}
if (gLine == 3)
{
anim = (string)data;
}
++gLine;
gQueryID = llGetNotecardLine(gName, gLine);
}
}

}

state_entry()
{ gQueryID = llGetNotecardLine(gName, gLine);
llSitTarget(<0,0,-0.6>, <180,0,0,0>;); ; // Set the target one meter above the ground

llSetText("Sit here to Make Money .\nL$"+(string)campadd+" every "+(string)pula+" minutes",<0,1,0>,1);

}

changed(integer change)
{
if(change & CHANGED_LINK)

{
key avataronsittarget = llAvatarOnSitTarget();
if( avataronsittarget != NULL_KEY );
{
llRequestPermissions(avataronsittarget, PERMISSION_TRIGGER_ANIMATION);
}

if ((llGetPermissions() & PERMISSION_TRIGGER_ANIMATION) && llGetPermissionsKey() == avataronsittarget)
{
llStopAnimation("sit";);
llStartAnimation(anim);
llSetText("Money Made:"+(string)campmoney,<0,1,0>,1);
llSetTimerEvent(camptime);
}
else if (campmoney > 0)
{
llGiveMoney(avataronsittarget,campmoney);
}
avataronsittarget="";
campmoney=0;
llSetText("Sit here to Make Money .\nL$"+(string)campadd+" every "+(string)pula+" minutes",<0,1,0>,1);

llSetTimerEvent(100000000);
}
else
{
// If we dont, ask for them:
llRequestPermissions(avataronsittarget, PERMISSION_TRIGGER_ANIMATION);
// We'll animate in the run_time_permissions event, which is triggered
// When the user accepts or declines the permissions request.
}
}

timer()
{
campmoney = campmoney+campadd;
llSetText("Money:"+(string)campmoney,<0,1,0>,1);

{
if ( campmoney == limit )
{
llUnSit(avataronsittarget);

llGiveMoney(avataronsittarget,campmoney);
llSetScriptState("Camping w notecard altered", FALSE);
llSetText("Money limit reached, this camping chair is now unavailabe",<0,1,0>,1);
}

else
{

campmoney=0;
llSetText("Sit here to Make Money .\nL$"+(string)campadd+" every "+(string)pula+" minutes",<0,1,0>,1);

llSetTimerEvent(100000000);
}
}
}
run_time_permissions(integer perm)
{
if(perm)
{
// Place the code here!
llStopAnimation("sit";);
llStartAnimation("stand";);
}
}


}

code end


I still get an error message about a permission.
Unable to find specified agent to request permissions.

I so hate scripting :)
Sarah Showboat
Registered User
Join date: 3 Nov 2006
Posts: 13
01-03-2008 12:10
Looks to me like you're still trying to debt perm from one person and animate another with one script. I see you put debt perms in a separate script, thats good. Now you just have to use Link Messages to tell it to pay.

llGiveMoney has to be in the same script that has recieved permission debt.

llStartAnimation in the script with permission animate
Jolly Heron
www.ideashape.cn/
Join date: 18 Apr 2007
Posts: 71
01-07-2008 00:54
Then what should be the final and correct one? Please help update. I'm a complete novice too.