Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Discussion: Pay 2 Teleport by Haplo Voss

Haplo Voss
Registered User
Join date: 18 Nov 2006
Posts: 137
06-18-2007 04:44
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!!

-------------------------

CODE

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,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.

<destination vector>;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,2,3>
price = 100
text =
WELCOME!
Right Click And
Pay L$100 to
Teleport to Island!

(note the two spaces, we didn't use them, but we still need to have them to keep the format of the notecard. just put blank spaces if you don't need a spot, or to space out stuff)

charge people = 0 (0=yes / 1=no or public access)

That's IT!!!

Enjoy!

- Haplo
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Original Thread
06-29-2007 00:19
/15/cf/191600/1.html
_____________________
i've got nothing. ;)
RJ Source
Green Sky Labs
Join date: 10 Jan 2007
Posts: 272
06-29-2007 05:40
Wouldn't this allow a person (perhaps a griefer) to hang around nearby, and as soon as someone pays the object, the griefer quick sits on the object and takes their teleport?

A couple ways around that would be not to notify the area when the object is paid (don't do a say on channel 0), or even only allowing the payer to be the next sitter (keeping track of their key).
Haplo Voss
Registered User
Join date: 18 Nov 2006
Posts: 137
07-01-2007 11:04
Script update:

A couple of bugfixes and an added feature:

feature update... rather than manually resetting the script... just hold down your mouse button a few seconds on the object, it notifies you the info has changed and the script is resetting. then just click the object for any text changes you made to take place.

Bug Fix
Immediate shutdown of teleport after someone pays. Once they've paid and teleported the teleporter reverts immediately back to a "0" state and clears the "sit" text field in the menu oval.



PLEASE SEE ORIGINAL SCRIPT-POST ABOVE -- I HAVE EDITED IT WITH THE CURRENT UPDATES.
Haplo Voss
Registered User
Join date: 18 Nov 2006
Posts: 137
07-01-2007 11:16
From: RJ Source
Wouldn't this allow a person (perhaps a griefer) to hang around nearby, and as soon as someone pays the object, the griefer quick sits on the object and takes their teleport?

A couple ways around that would be not to notify the area when the object is paid (don't do a say on channel 0), or even only allowing the payer to be the next sitter (keeping track of their key).


Well I can see your point, but that would assume the payer would be the only person using that teleporter once paid. In this case, the reason I wrote the script in the first place was so multiple people would be teleported to "classes" once they paid... once there they can teleport elsewhere or back to a main landing... therefore, never tracking back to that TP again. (unless they want to pay to take the class all over again ;)

Not sure what to do about notification though... can't I just reject any ID other than the avatar who paid?

thanks for the point out!
Haplo Voss
Registered User
Join date: 18 Nov 2006
Posts: 137
07-01-2007 11:58
THIS JUST IN ;)

I took your advice and installed a security bridge.

basically the script grabds the avatar's key during the transaction, then queries whether or not it is the purchaser during the change / teleport event. If not, then all you do is end up sitting on it. No frills or "HEY! you didn't pay for it!" Just nothing doing until the purchaser teleports.

EDIT: I thought I might need a timer to timeout the teleporter in case someone crashed after a purshace, yet never teleported.

This is not the case. Once a TP is purchased, only that person can use it... until another TP is purchased. So although it may be 'locked' for non-paying customers, as soon as the next person pays for a teleport... it resets to their id and things continue as always... SO no need for a timer reset on the TP :D

-Haplo
Zypher Crash
Charter Member
Join date: 17 May 2003
Posts: 55
07-24-2007 17:15
with X flight and feather flyers this is still obsolete, people can simply fly to the class. And or they can have a friend teleport them in, I'm sure the host is not going to pay 100% who all came on the teleporter and who did not. For things such as this, just use pass on land, for a fee to enter.

But yet again, how many people actually even go to the free classes?
_____________________
Anything I'v posted was not posted to soley point someone out nore discredit any persons mentioned. The Above is soley my own oppinion that witch I am entitled to. Any flame or comments welcome But will be ignored. Unless specified other.