Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Help? LOL

Knight Nootan
Registered User
Join date: 26 May 2008
Posts: 73
05-28-2009 17:52
Ok, I have a script that I need to complete an action but I want it to only complete the action for the one who touches it. For example, I have a vendor, and I want it to be set to XX price but I want it to be at YY price for a certain agent when they touch it. Just not sure how to do this. Or when they touch it can it open the payment box for them?

Thanks in advance!
Day Oh
Registered User
Join date: 3 Feb 2007
Posts: 1,257
05-28-2009 18:16
Attaching related thread meep
_____________________
Knight Nootan
Registered User
Join date: 26 May 2008
Posts: 73
05-28-2009 19:03
I guess what I would really like to do is on the vendor, when it is touched and in use by a person, set it so it can be used by anyone else for a set amount of time set by a llSetTimerEvent. So basiclly, if Joe Blow clicks the vendor then no one else can use it for say 20 seconds ( llSetTimerEvent(20) ). Just not sure how to accomplish this. Thanks for any help you can give.
_____________________
~*~ Knight ~*~
Co-Owner of NIVO

Quality Furniture, Fireplaces, Jewelry, Party Supplies, 1 Prim Plants and Trees, Gifts and More.................

http://slurl.com/secondlife/Oshima/152/101/38
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
05-28-2009 19:45
From: Knight Nootan
I guess what I would really like to do is on the vendor, when it is touched and in use by a person, set it so it can be used by anyone else for a set amount of time set by a llSetTimerEvent. So basiclly, if Joe Blow clicks the vendor then no one else can use it for say 20 seconds ( llSetTimerEvent(20) ). Just not sure how to accomplish this. Thanks for any help you can give.


CODE

//-- in globals
key gKeyUser;

//-- in your touch event
if (!(gKeyUser) || llDetectedKey( 0 ) == gKeyUser){
gKeyUser = llDetectedKey( 0 );
llSetTimerEvent( 20.0 );
//-- other touch related stuff here
}else{
/*//-- we're being used by someone else right now --//*/
}

timer(){
llSetTimerEvent( 0.0 );
gKeyUser = "";
}


think that would work... it might not like the datatype on the first gKeyUser in the test, in which case you could test that half as
"" == gKeyUser
instead of
!(gKeyUser)
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Knight Nootan
Registered User
Join date: 26 May 2008
Posts: 73
05-28-2009 20:20
Thank you! Thank Works!
_____________________
~*~ Knight ~*~
Co-Owner of NIVO

Quality Furniture, Fireplaces, Jewelry, Party Supplies, 1 Prim Plants and Trees, Gifts and More.................

http://slurl.com/secondlife/Oshima/152/101/38
Knight Nootan
Registered User
Join date: 26 May 2008
Posts: 73
05-28-2009 21:54
Ok, that stops the touch event perfect, but it still allows others to pay. Is there a way to stop the pay option as well?
_____________________
~*~ Knight ~*~
Co-Owner of NIVO

Quality Furniture, Fireplaces, Jewelry, Party Supplies, 1 Prim Plants and Trees, Gifts and More.................

http://slurl.com/secondlife/Oshima/152/101/38
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
05-29-2009 00:37
won't be able to stop the pay itself, but you should be able to do the same test and refund their money if they aren't the active user..
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
05-29-2009 06:05
I hadn't realized that myself until yesterday, when I was scripting an auction system. Apparently, funds are transferred immediately once a money event is triggered, so you can't expect limiting tests inside a money event to stop payment. Like the OP, I was hoping to prevent payment unless the person was already a registered bidder (because I need to keep track of each bidder's total). Once I discovered that I couldn't do that, my solution was to refund the bid, register the bidder, and ask him to resubmit it. It works.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
Knight Nootan
Registered User
Join date: 26 May 2008
Posts: 73
05-29-2009 09:40
In the money event, How would I get it to know if the agent is correct or to return the money. I know how to return the money but just not sure on how to have it detect the agent.
Rolig Loon
Not as dumb as I look
Join date: 22 Mar 2007
Posts: 2,482
05-29-2009 10:42
From: Knight Nootan
In the money event, How would I get it to know if the agent is correct or to return the money. I know how to return the money but just not sure on how to have it detect the agent.

You get the agent's key from the id parameter of the money event. Make the DetectedKey variable you used before a global and compare the two. If they don't match, give the money back. You'll have to put a llRequestPermissions statement in your on_rez or state_entry event to give the script permission to debit your own account when it returns the money, but that's easy.
_____________________
It's hard to tell gender from names around here but if you care, Rolig = she. And I exist only in SL, so don't ask.... ;)

Look for my work in XStreetSL at
Papalopulus Kobolowski
working mind
Join date: 11 Aug 2006
Posts: 326
05-29-2009 11:31
You can use diferent states to handle the pay money event and check if the user is in the allowed payment list.

With out part of your script i can point you in a few parts, the other part its filled by you ;)

CODE

default
{
state_entry(){
// do your request permission to the owner
}

// run_time_permissions( integer perm )...... run your time permissions
{

touch_start(integer total_number)
{

// check if the user is on the list , keep the key of the toucher to make comparations later in the money part
// if is go to the payment state

}



}


state Deposit

{
state_entry()
{
llSetPayPrice(PAY_DEFAULT, [PAY_DEFAULT, PAY_DEFAULT, PAY_DEFAULT, PAY_DEFAULT]);
llSetTimerEvent(15);
}
money(key id, integer amount2)
{

//if is the same user as in the list keep the payment or refund it if not

}

timer()
{
llInstantMessage(usrNow,"Time is up! try again.");
llSetTimerEvent(0);
state default;
}

}



With this the "Pay" option dont show up until they are allowed when touch you prim
and refund them if they pay when another person is active in the payment part
it can look as a mess , but it works im using something like this in my terminals .
_____________________


RAW terrain files - terraform your SIM!!
http://www.wishland.info/
PD:the wiki its your friend ;)
http://wiki.secondlife.com/wiki/LSL_Portal
Knight Nootan
Registered User
Join date: 26 May 2008
Posts: 73
05-29-2009 17:18
Ok, Now I have gone a stray and confused the hell out of my self. Not sure where to put the
if (perms & PERMISSION_DEBIT) and now it doesn't give me the product when the second price is paid. It only refunds the payment. Here is the code from the money event:

CODE


money(key id, integer amount)
{
if( amount>=price )
{
llGiveInventory(id,itemName);
llSay(0,"Thank you for your purchase!");
return;

}
string disc = llList2String(notecardList,(index*4)+3);
gKeyUser = llDetectedKey( 0 );
if (llKey2Name(id) == gKeyUser)
{
if ( amount=price - (integer)disc )
{
llGiveInventory(id,itemName);
llSay(0,"Thank you for your purchase!");

}

}
else
{
llWhisper(0,"I am sorry bt this vendor is in use, please try again.");
llGiveMoney(id,amount);
}
}
}

state loading
{
state_entry()
{
llRequestPermissions( llGetOwner(), PERMISSION_DEBIT );
llSay(0,"Loading product data...Please wait............");
notecardIndex = 0;
notecardQuery = llGetNotecardLine(notecard,notecardIndex++);
}
run_time_permissions(integer perms)

{
}

dataserver(key query_id, string data)
{
if ( notecardQuery == query_id)
{
// this is a line of our notecard
if (data == EOF)
{
llSay(0,"All products loaded and ready for use.");
state default;

} else
{
notecardList += [data];
notecardQuery = llGetNotecardLine(notecard,notecardIndex++);
}
}
}
}

CODE
Knight Nootan
Registered User
Join date: 26 May 2008
Posts: 73
05-29-2009 18:59
ok, I got the money event to work as it should. I took a break and came back and looked at it and realized, I had done it all wrong and changed it to if ( id==gKeyUser && amount=price - (integer)disc ) and it returns the other users money and still allows the object to be delivered to the original buyer.

I am however still confused on where to place the other part of the permissions as stated in the above post. It works fine without it but I would really like to have it only work if they agree as it is suppose to.