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
)