Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Pay to Rez?

Rocky Rutabaga
isn't wearing underwearâ„¢
Join date: 14 Apr 2006
Posts: 291
09-08-2008 11:28
I want to be able to rez a car that someone rents from me. I have the car set to temporary and in a box that rezzes the car when touched. If I set the box to pay, and someone pays the correct rental fee, does the car then rez or do I need to include some type of pay to rez script or addendum to the rez script? Thanks!
_____________________
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
09-08-2008 12:15
From: Rocky Rutabaga
I want to be able to rez a car that someone rents from me. I have the car set to temporary and in a box that rezzes the car when touched. If I set the box to pay, and someone pays the correct rental fee, does the car then rez or do I need to include some type of pay to rez script or addendum to the rez script? Thanks!


it probably wouldn't be too hard to turn the touch into a pay event. you can probably look at a few tip jar scripts to get the idea. they all have an event triggered when someone pays it. i assume the "rental" is used as a demo? if so you could have the demo set to no copy, and drop a script in it to kill the car after a set amount of time. that way they can try it out anywhere they are allowed until the time is up
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
09-08-2008 19:28
How about something on the lines of,
CODE


integer gCorrectAmount = 10;

default
{
state_entry()
{
llSetClickAction(CLICK_ACTION_PAY);
llSetPayPrice(PAY_HIDE, [gCorrectAmount]);

}

money(key id, integer amount)
{

if (amount == gCorrectAmount)
{

llSay(0,"Thank you, " + llKey2Name(id) + ".");
llRezObject("Rental Car", llGetPos() + <1, 0, 0>, ZERO_VECTOR, ZERO_ROTATION, 42);
}


}
}
Rocky Rutabaga
isn't wearing underwearâ„¢
Join date: 14 Apr 2006
Posts: 291
09-09-2008 06:26
I will try that. Bless you. I had found a freebie Pay to Teleport script that was about 4 gazillion lines long and had no idea where I could replace the TP function with the rez.
_____________________
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
09-09-2008 08:35
If you have access to the car scripts, you might want to make it so that it can only be driven by the person who paid for it.

Easiest way to do that would probably to take the first bit of the key that charged you, cast that to an integer and use that instead of 42 in llRezObject. This value will show up in the on_rez event in the car script. When somebody sits in the car, check their key and llUnSit them if it doesn't start with this number..

You might also want to do a bit of work on that payment script. The pay price is set to L$10. If somebody doesn't pay it _exactly_ L$10, nothing at all will happen.
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!!
- Go here: http://jira.secondlife.com/browse/SVC-1224
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
09-09-2008 08:49
From: Meade Paravane

You might also want to do a bit of work on that payment script. The pay price is set to L$10. If somebody doesn't pay it _exactly_ L$10, nothing at all will happen.


you should be able to use the PAY_HIDE function to hide all payment fields except for the one with the correct price
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
09-09-2008 10:37
From: Ruthven Willenov
you should be able to use the PAY_HIDE function to hide all payment fields except for the one with the correct price

That's what the script does, of course. Obviously integer gCorrectAmount will need setting for whatever the price is, but it's impossible to pay anything but the right price.

As to the problem of making sure only the payer can drive the rezzed car, you can pass the payer's uuid to the rezzed object as part of the object_rez event. Something like
CODE
 key payer;

integer gCorrectAmount = 10; // set this to what you want the person to pay
integer myChannel = -12345 // change this

default
{
state_entry()
{
llSetClickAction(CLICK_ACTION_PAY);
llSetPayPrice(PAY_HIDE, [gCorrectAmount]);

}

money(key id, integer amount)
{

if (amount == gCorrectAmount)
{
payer = id;
llSay(0,"Thank you, " + llKey2Name(id) + ".");
llRezObject("Rental Car", llGetPos() + <1, 0, 0>, ZERO_VECTOR, ZERO_ROTATION, 42);
}


}
object_rez(key id) {
llSay(myChannel, (string)payer);
}
}

and then in the rezzed car, pick up the key with something like this
CODE
key buyer;
integer myChannel = -12345; // make sure this is the same as channel the rezzer is using
default
{
state_entry()
{
llListen(myChannel, "Car Rezzer", NULL_KEY, ""); // assuming the thing you pay to rez the car is called "Car Rezzer"
}

listen(integer channel, string name, key id, string message)
{
buyer = (key)message ;
}
}


Vehicle scripts frequently have something in them like
CODE
   changed(integer change)
{
if (change & CHANGED_LINK)
{
key agent = llAvatarOnSitTarget();
if (agent)
{
if (agent != llGetOwner())
{
llSay(0, "You are not my owner);
llUnSit(agent);
}
else
{ // let him drive
}


so, having set the value of key buyer in the way I describe, if you then substitute something like if (agent != buyer) for if (agent != llGetOwner()) I would think it should work, though i haven't tested it.
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
09-09-2008 11:03
My bad on the money stuff - haven't played with buy dialogs in forever.

For passing the buyer id to the car, the best way to do that is still by passing it in llRezObject..

edit: so the rezzer script would be something like this..

CODE

money(key id, integer amount)
{
if (amount == gCorrectAmount)
{
llSay(0,"Thank you, " + llKey2Name(id) + ".");

string prefix = "0x" + llGetSubString((string)id, 0, 7);

llRezObject("Rental Car", llGetPos() + <1, 0, 0>, ZERO_VECTOR,
ZERO_ROTATION, (integer)prefix);
}
}


...and the car script would have...

CODE

key gOwner;
.
.
.
on_rez (integer param)
{
gOwner = param;
}

changed (integer mask)
{
if (mask & CHANGED_LINK)
{
key sitter = llAvatarOnSitTarget();
if (sitter != NULL_KEY)
{
string prefix = "0x" + llGetSubString((string)sitter, 0, 7);

if (gOwner != 0 && prefix != gOwner)
{
llSay (0, "Carjacker! Disproportionate response activated!");
llUnSit (sitter);
}
}
}
}
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!!
- Go here: http://jira.secondlife.com/browse/SVC-1224
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
09-09-2008 15:57
Thanks.. I hadn't realised you could pass UUIDs to the on_rez event like that but I see now.. that makes a lot of sense and it's a lot better than my way.
Sindy Tsure
Will script for shoes
Join date: 18 Sep 2006
Posts: 4,103
09-09-2008 16:39
From: Innula Zenovka
Thanks.. I hadn't realised you could pass UUIDs to the on_rez event like that but I see now.. that makes a lot of sense and it's a lot better than my way.

You can't pass the whole thing - just the first 32 bits..

The chances of somebody else being nearby with the same starting 32 bits are pretty close to zero, though. It's just never gonna happen.