Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Permissions gone awry! What's going on?

Haplo Voss
Registered User
Join date: 18 Nov 2006
Posts: 137
05-30-2007 18:12
Hi all, I'll try to be brief so as not to complicate matters worse...

I wrote this script myself (yeah, sorry for the clumsiness and clutter)
I was all proud of myself with it working great just the way I wanted.

HOWEVER!: when someone buys the object / takes ownership, it no longer functions properly.
I get the following script error:

" Unable to find specified agent to request permissions."

I've never had this happen before, but I've never written a script this large before either. And, as long as I (creator and owner) run it in my own object... it's fine. But once you sell it, give it, deed it off... it simply won't process return moneys and gives the script error above.

Ok.. here it is. Try not to be too harsh, although I'm willing to accept a few bumps and bruises ;) (and dang, sorry for the mess with php not working :( )

CODE


integer gAmount;
vector gTargetPos;
vector gStartPos;
key gAvatarID=NULL_KEY;
integer costofclass;
string NoteName;
string target;
string targeter;
string destination;
string cost;

Targeting()
{
NoteName = llGetInventoryName( INVENTORY_NOTECARD, 1 );
targeter = llGetNotecardLine( NoteName, 0 );
cost = llGetInventoryName (INVENTORY_NOTECARD, 0);

}

Access()
{
llSetSitText("Teleport");
llSay(0,"Teleport is open!");
}

warpPos( vector destpos)
{ //R&D by Keknehv Psaltery, 05/25/2006
//Additions by Strife, Talarus Luan
//and final cleanup by Keknehv Psaltery

// Compute the number of jumps necessary
integer jumps = (integer)(llVecDist(destpos, llGetPos()) / 10.0) + 1;
// Try and avoid stack/heap collisions
if (jumps > 100 )
jumps = 100;
//1km should be plenty
list rules = [ PRIM_POSITION, destpos ];
//The start for the rules list
integer count = 1;
while ( ( count = count << 1 ) < jumps)
rules = (rules=[]) + rules + rules; //should tighten memory use.
llSetPrimitiveParams( rules + llList2List( rules, (count - jumps) << 1, count) );
}

default
{


dataserver(key query_id, string target)
{
gTargetPos = (vector)target;
costofclass = (integer)cost;
}


money (key id, integer amount)
{

gAmount = amount;


if (gAmount < costofclass){
llSay(0,"Sorry but you must pay L$" + (string)costofclass + " before taking this class");
llUnSit(llAvatarOnSitTarget());
llGiveMoney(id,gAmount);
}

else if (gAmount == costofclass){
llSay(0,"Thank you for your payment!");
Access();
}

else if (gAmount > costofclass){
llSay(0,"You Paid: " + (string)gAmount);
llSay(0,"This class only costs: " + (string)costofclass);
integer refund = gAmount - costofclass;
llSay(0,"Refunding you: " + (string)refund);
llGiveMoney(id,refund);
Access();
}

}



state_entry()
{
llRequestPermissions(llGetOwner(),PERMISSION_DEBIT );
///////////////////////////////I have also tried llDtectedKey(0) here... no difference)/////////
Targeting();
if ((integer)cost == 0){
llSay(0,"Public Access");
Access();
}
else if ((integer)cost != 0){
llSetSitText("`");
}
llSitTarget(<0,0,1>,ZERO_ROTATION);
gStartPos = llGetPos();


}

on_rez(integer startup_param)
{
llResetScript();
}

changed(integer change){
if(change & CHANGED_LINK) {
gAvatarID = llAvatarOnSitTarget();
if(gAvatarID != NULL_KEY & gAmount > costofclass - 1) {
warpPos(gTargetPos);
llSleep(1);
llUnSit(gAvatarID);
llSleep(1);
warpPos(gStartPos);
gAmount = -1
}


else{
llSleep(1);
llUnSit(gAvatarID);
}

}
}
}



Thanks for any advice / restructuring you could offer. I need this to work for an island opening up soon.

-Hap
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
05-30-2007 20:17
Dunno if this will help, but I don't see the run_time_permissions event, where you would verify whether or not the owner gave the script the DEBIT permission.

Also, you don't need to unsit someone in the money() event. They aren't sitting on it when they pay it, so that won't do anything. The changed event will take care of them sitting on it without paying.

Also, I note that you don't clear the paid amount variable after a successful transport, which means more people can sit on the transporter and get a free ride after the first person pays.

Could be more issues as well, but those are the most glaring ones I see.
Fa nyak
>(O.o)<
Join date: 8 Oct 2004
Posts: 342
05-30-2007 20:58
you should still be able to save a script with permissions without a run_time_permissions event, even though it may not be the best idea. i just made a default script that just requested debit perms on the first line of state_entry and it worked fine. that error message seems strange. your code looks valid, especially the first line of state entry requesting perms...there's really no room for that to screw up. sounds strange, but try copying and rezzing the prim with the script in it. mebbe there's a big with the prim and it thinks it's somewhere it's not...somewhere too far away to find you? i dunno...wierdness
Haplo Voss
Registered User
Join date: 18 Nov 2006
Posts: 137
05-31-2007 00:16
Yeah, there is supposed to be a gAmount=0 at the bottom of the changed event, just before the else statement, right after the last warpPos call. I simply have been editing this thing to no end. Sorry about that.

I've actually never used runtime permissions before... is that necessary to debit / creidt someone? My tipjars and the like have never had issues (and the tip jar was a surprise payback after 100 tips).

Thanks for the input and I will look into the runtime permissions.. maybe that will help set the correct region, etc.

Take care,
-Hap
Haplo Voss
Registered User
Join date: 18 Nov 2006
Posts: 137
05-31-2007 19:03
Well, after some experimenting... it still didn't work w/ runtime permissions either. (oh yeah, I added the gAmount = -1 to the end of it. 0 makes it public. :) )

I've run out of ideas.. the more I tinker with it, the more confused I get. It SHOULD work. And it DOES work, until someone buys it, then I can't even use it properly. I'm stumped.

Is anyone else having this sort of issue? Could I be dealing w/ a SL script break? Maybe on this particular island / region only or something? I don't kow. Going to try it on the mainland again and see if I get the same results.

If anyone has any ideas, I would be willing to offer up my script as public domain here - even though someone else may have already done this better. I haven't found it... and believe me, I've looked for it!!

There has to be an answer whether it's my faulty coding or an SL issue.

I have to have these up and working in a few more days so any help is SOOoo appreciated.

Thank you for your efforts, and if we can figure this out, I would be happy to offer my build / texturing services free of charge on any project you might be working on or need help with.

My best,
Hap
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
05-31-2007 20:14
Post the latest copy of what you have, or send me one in-world.
Milambus Oh
Registered User
Join date: 6 Apr 2007
Posts: 224
06-01-2007 06:10
1. For the future when you post script with a question explain what the script is -supposed- to do. Having to read through it to figure out what is happening a) takes time and b) is often misleading since if it were working corretly you would not be posting the script.

2. In your state_entry(), this else if is unneeded.. the value is either 0 or not 0, no need to waste CPU cycles on checking it twice.
else if ((integer)cost != 0){

3. How are you changing ownership of the object in question? Are you just placing the object in the world and setting it for sale? Or are you boxing the object up and using a vendor?

Either way, you probably want to add this to your changed event:

CODE

changed(integer change){
if(change & CHANGED_LINK) {
gAvatarID = llAvatarOnSitTarget();
if(gAvatarID != NULL_KEY & gAmount > costofclass - 1) {
warpPos(gTargetPos);
llSleep(1);
llUnSit(gAvatarID);
llSleep(1);
warpPos(gStartPos);
gAmount = -1
} else {
llSleep(1);
llUnSit(gAvatarID);
}

} else if (change & CHANGED_OWNER) {
llResetScript();
}
}


Only the code in the else if should be new, it tells your script to reset when the owner changes. You are currently only requesting PERMISSION_DEBIT when the object enters the state. If you try to pay out cash after that point, the object will no longer have the correct permission because the new owner has not given the correct permission.
Haplo Voss
Registered User
Join date: 18 Nov 2006
Posts: 137
06-01-2007 10:20
Ok thanks! I will try the CHANGED_OWNER slice when I get home tonight. I appreciate everyone's help so far and if I still can't get it to work - I will contact you in-world Talarus.

Apologies for not detailing the script beforehand, but I've also gotten scorned for giving too much detail - so it's hard to know what the correct etiquette is in here somethimes.

The object itself is for sale. a 3prim object (basically a stand, ball, and globe around the ball.
The globe is the parent prim, and contains all scripts and notecards.

In the past, my experience had been that as long as someone bought the object from me, and became the owner - there weren't any problems ... untill now that is.

It sounds to me the CHANGED_OWNER /reset combo is a good way to go... I will see what happens!

-Hap