Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

quick money/pay question

Danielz Shackle
Registered User
Join date: 30 Apr 2006
Posts: 100
05-25-2006 20:18
Ive read in several other threads about small problems with payment scripts where other people can grief and use the same item in various ways, and i want to limit my item to one user at a time
i know all the main ideas of ifs and thens to make it work but what is the actualt SL comand to find an id and save it as (string or integer)? for use later in script?

the pay option im using is something similar to

money(key kID, integer iAmount)
{
integer iChange = iAmount % itemprice;
if (iChange > 0)
{
llGiveMoney(kID, iChange);
}

----
also

is there a better or less error/theft way then this, or is this the best way to do it?
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
05-25-2006 22:19
From: someone
comand to find an id and save it as (string or integer)? for use later in script?


make a varible and define it, ie key dude; key dude = data...

the possibility of greif is low, but it can happen, basicly you snipe the machine. so if user mary pays 50L$ for an item, and greifer joe jumps in at the exact same time with a buck, greifer joe will get marys item, for a buck, which looses yours and mary's money

this is something i whiped up really quick that would protect you from that situation, it only deals with one person @ a time :)

CODE

integer price = 50;
key current_user = NULL_KEY;
default
{
money(key id, integer amount)
{
if (current_user == NULL_KEY)
{
current_user = id;
if (amount == price)
{
llOwnerSay("you have been paid by "+llKey2Name(current_user));
current_user = NULL_KEY;
}
else
{
llSay(0,"do money return stuff here");
current_user = NULL_KEY;
}
}

else llInstantMessage(id, "script currently in use, try again in a moment");
}
}


theres probally a billion varients out there, and some possibally better, but its a 2 min quck fix :) just be shure to not clear out the current_user key, untill the transaction is complete
Danielz Shackle
Registered User
Join date: 30 Apr 2006
Posts: 100
ok, one more question
05-26-2006 05:04
ok, obviously i changed the script s a little, but that worked, now it leads to another question. I want to be able to stop other people from touching buttons or gamepieces if they didnt pay, i know theirs a way to pull id froma touch start, but i think im doing it a little off, it isnt working right, im trying to find it on wiki, but i see how to get keys for objects, etc, not person using. I know ive seen it somewhere, can someone point me to it?
Bitzer Balderdash
Dazed and Confused
Join date: 21 Dec 2005
Posts: 246
05-26-2006 05:18
Inside the touch_start event handler use llDetectedKey()
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
05-26-2006 05:37
From: Osgeld Barmy
the possibility of greif is low, but it can happen, basicly you snipe the machine. so if user mary pays 50L$ for an item, and greifer joe jumps in at the exact same time with a buck, greifer joe will get marys item, for a buck, which looses yours and mary's money

(..)

theres probally a billion varients out there, and some possibally better, but its a 2 min quck fix :) just be shure to not clear out the current_user key, untill the transaction is complete

Uhmm is this even possible/needed in the first place? Thought the events in LSL are queued, so it's rather: if Mary pays L$50 and Joe pays L$1, then the money event is triggered for whoever happened to pay first, and then --only after you're fully done handling it-- it's triggered all over again for the other person.

What i figure can happen is someone scrolling the vendor content through touch even or something, while another person is in the process of paying through the pay window... which would cause the person who pays, buy another item than they originally intended. Can be probably countered with item change being limited to one person only in a short slice of time, though o.O;
Danielz Shackle
Registered User
Join date: 30 Apr 2006
Posts: 100
from what ive read yeah
05-26-2006 05:50
theres a whole other thread about 6 paghes long about some problems with it. but i wanted to make sure i was patching/avoiding the problem in its entirety, better to be safe then have me/customers lose money
...

thanks blitzer, im trying that now
Nepenthes Ixchel
Broadly Offended.
Join date: 6 Dec 2005
Posts: 696
05-26-2006 06:20
From: Osgeld Barmy

CODE


key current_user = NULL_KEY;

if (current_user == NULL_KEY)
{
...
}

else llInstantMessage(id, "script currently in use, try again in a moment");
}
}


Shouldn't that be "if (current_user == NULL_KEY || current_user == guy_who_just_paid) ? Otherwise no-one will ever be able to buy anything unless there is no current user.
Danielz Shackle
Registered User
Join date: 30 Apr 2006
Posts: 100
05-26-2006 06:54
Nepenthes, i saw that, i did it little different.

im still stuck with Bitzer Balderdash quote < Inside the touch_start event handler use llDetectedKey() > i just tried it and i think im still missing something simple.

can anyone point me to a finished example at wiki or make one. i gave up sleeping last night and maybe thats why im missing it... lol

ive got the money issue settled on qty/price/right item/gamepice, but trying to make sure it stays with one person. i know others use mulptiple people, but for now i just need to learn how to get it working with the one person limit at a time ( i can figure rest out from there).

lets say i take the basic sl script

integer number = 0;

default
{
state_entry()
{
llSay(0, "Hello, Avatar!";);
}

touch_start(integer total_number)
{
llSay(0, "Touched.";);
}
}

and want to add the key llDetectedKey(integer number). im either not putting it in correct place or not identifying it right. wiki shows this deteced thread but doesnt give example and my brain hurts.. sorry if im running on, but man im lost today
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
05-26-2006 07:11
CODE

touch_start(integer total_numer)
{
key toucher=llDetectedKey(0);
}

is the basics of the structure you're looking for.
Danielz Shackle
Registered User
Join date: 30 Apr 2006
Posts: 100
perfect, thanks all
05-26-2006 08:24
thank you all for your help on this. it was simple and i missed it. im keeping track of you all :) if i ever actually make any money ill get you all some free copys or do what i can for your all help
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
05-26-2006 21:02
From: Nepenthes Ixchel
Shouldn't that be "if (current_user == NULL_KEY || current_user == guy_who_just_paid) ? Otherwise no-one will ever be able to buy anything unless there is no current user.


thats kind of the point, the key is originally setup as null_key so the script will fire the first time, then the key is either

saved and used for transaction, then set back to null_key
or
ignored / refuned

now yes, its not a great chunk of code but it wasnt intended to be, it was made in about 2 min off the top of my head (counting SL login time), and shows the basics

and not to sound snippy, but it was one of the questions in the OP
From: someone
and i want to limit my item to one user at a time


Ok

From: Joannah Cramer
Uhmm is this even possible/needed in the first place? Thought the events in LSL are queued, so it's rather: if Mary pays L$50 and Joe........


i personally do not practice this type of stuff on my own scripts, but i also have basicly nothing invested in the game, so my level of defence may be different :)

but the fact is, the system does glitch and hickup, while highly unlikley@ the exact same moment.

besides, the script shows some basic "need to know" stuff like saving / changing global varibles, plus it sounded like the OP gained something, and thats all that really counts...

Knowing Is Half the Battle!

http://www.joeheadquarters.com/joeendings.shtml