//Pay 2 Teleport by Haplo Voss
//Greetings! Thanks be to all that helped me along the way with answers to questions!
//Without further ado... here it is!!
//Please pay attention to notes following script!!
//-------------------------
vector gTargetPos;
integer cost;
string desc;
string hovertext;
key agent;
key gAvatarID=NULL_KEY;
integer gReturnToStartPos=TRUE;
vector gStartPos;
integer paid = 1;
integer access=0;
integer public_access;
integer origin_access;
float elapsed;
key gID;
warpPos( vector destpos)
{ //R&D by Keknehv Psaltery, 05/25/2006
//Additions by Strife, Talarus Luan
//and final cleanup by Keknehv Psaltery
integer jumps = (integer)(llVecDist(destpos, llGetPos()) / 10.0) + 1;
if (jumps > 100 )
jumps = 100;
list rules = [ PRIM_POSITION, destpos ];
integer count = 1;
while ( ( count = count << 1 ) < jumps)
rules = (rules=[]) + rules + rules;
llSetPrimitiveParams( rules + llList2List( rules, (count - jumps) << 1, count) );
}
default
{
dataserver(key query_id, string desc){
list desc_list = llParseString2List(desc, [";"], []);
gTargetPos = (vector)llList2String(desc_list, 0);
cost = (integer)llList2String(desc_list, 1);
hovertext = llList2String(desc_list, 2) + "\n" +
llList2String(desc_list, 3) + "\n" +
llList2String(desc_list, 4) + "\n" +
llList2String(desc_list, 5) + "\n" +
llList2String(desc_list, 6);
public_access = (integer)llList2String(desc_list, 7);
origin_access = public_access;
}
money (key id, integer amount){
paid=amount;
if (paid < cost && public_access == 0){
llSay(0,"Sorry, but this class costs " + (string)cost + ". Full amount is required before access.");
llGiveMoney(id,paid);
llUnSit(llAvatarOnSitTarget());
}
else if (paid > cost && public_access == 0){
integer refund = paid - cost;
llSay(0,"This class only costs " + (string)cost + "! Refunding you L$" + (string)refund );
llSay(0,"Access Granted!");
llSetSitText("Teleport");
llGiveMoney(id,refund);
gID = id;
public_access = 1;
}
else if (paid != 0 && origin_access == 1){
integer refund = paid;
llSay(0,"This teleporter is public access!");
llSay(0,"Access Granted!");
llSetSitText("Teleport");
llGiveMoney(id,refund);
public_access = 1;
}
else{
llSay(0,"Access Granted!");
llSetSitText("Teleport");
gID = id;
public_access = 1;
}
}
on_rez(integer rez){
llResetScript();
}
state_entry(){
llRequestPermissions(llGetOwner(),PERMISSION_DEBIT );
desc = llGetNotecardLine("TPInfo",0);
llSitTarget(<0,0,1>,ZERO_ROTATION);
gStartPos = llGetPos();
}
touch_start(integer touched){
llSetSitText("\n");
llSetText(hovertext, 0><0,1,0>, 1);
if (public_access == 1){llSetSitText("Teleport");}
elapsed = llGetAndResetTime();
}
touch(integer num_detected) {
if (llDetectedKey(0) == llGetOwner()){
elapsed = llGetTime();
if (elapsed > 2.0) {
llOwnerSay("Description has changed - resetting script");
llSetTimerEvent(120);
llResetScript();
}
}}
touch_end(integer num_detected)
{}
timer()
{
llSetTimerEvent(0.0);
}
changed(integer change){
if(change & CHANGED_LINK)
gAvatarID = llAvatarOnSitTarget();
if(public_access == 0){llSetSitText("\n");llUnSit(gAvatarID);}
if(gAvatarID != NULL_KEY & public_access == 1 & gID == gAvatarID) {
warpPos(gTargetPos);
llSleep(.25);
llUnSit(gAvatarID);
llSleep(.25);
if (gReturnToStartPos) {
warpPos(gStartPos);
}
if(origin_access == 0){llSetSitText("\n");public_access = 0;}
if(origin_access == 1){llSetSitText("Teleport");}
}
}
}
//------------------------------
//As you can see in the script, you will need to create a notecard called "TPInfo" (no quotes). It must contain the following information, IN THE FOLLOING ORDER.
//;price to charge;text line1;line2;line3;line4;line5;public access switch
//EXAMPLE:
//<1 ,2,3>;100;WELCOME!;Right Click And;Pay L$100 to;Teleport to Island!; ; ;0
//vector = 1><1 ,2,3>
//price = 100
//text =
//WELCOME!
//Right Click And
//Pay L$100 to
//Teleport to Island!1>0>>