Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

How to test if llGiveMoney fails?

Stone Juran
Registered User
Join date: 21 Mar 2007
Posts: 28
04-05-2008 09:40
Hello,

I want to test if llGiveMoney fails, in my script, but I don't know any technique to test that. Has someone a clue?

Thank you

Stone
MoxZ Mokeev
Invisible Alpha Texture
Join date: 10 Jan 2008
Posts: 870
04-05-2008 09:42
If you have an alt, log it on and try it that way. Otherwise, have a trusted friend help you out.
_____________________
:p
Stone Juran
Registered User
Join date: 21 Mar 2007
Posts: 28
04-05-2008 09:53
That's not really the answer I wanted to hear, I don't want to test my script. I want to know if the call of llGiveMoney has succeded, in case the user does not have enough money to pay the llGiveMoney. Do you understand?
Deanna Trollop
BZ Enterprises
Join date: 30 Jan 2006
Posts: 671
04-05-2008 09:59
Not possible with LSL.
Ravenhurst Xeno
Consiracy with no purpose
Join date: 20 Jan 2007
Posts: 147
04-05-2008 10:01
From: Stone Juran
That's not really the answer I wanted to hear, I don't want to test my script. I want to know if the call of llGiveMoney has succeded, in case the user does not have enough money to pay the llGiveMoney. Do you understand?


For better or worse, thats as good as it gets. There is no programatic way to determine the success or failure of an llGiveMoney. The only testing you can do is to test the script as a user and make sure it does what you expect it to do.
MoxZ Mokeev
Invisible Alpha Texture
Join date: 10 Jan 2008
Posts: 870
04-05-2008 10:05
Make sure your alt is broke.
_____________________
:p
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
04-05-2008 12:07
Create a system that does its own accounting, so that it never gives out more money than it has been told it has allocated, independently of what you are doing with the rest of the money in your account. Then either: A.) manually monitor your funds and make sure you have enough to back the money that the accounting system thinks it has, or B.) don't do any money transactions that are not through the accounting system (this would be with the alt suggestion others are giving, unless you don't plan on spending any money).

Also be ready to check your transaction history and possibly compare it to whatever logs your system is keeping if issues come up with customers.
Papalopulus Kobolowski
working mind
Join date: 11 Aug 2006
Posts: 326
04-05-2008 12:24
the only way I think its setting a MAX amount to give , if that amount was reached the script shutdown or go to another state like "out of service"
Darien Caldwell
Registered User
Join date: 12 Oct 2006
Posts: 3,127
04-05-2008 12:58
From: Stone Juran
That's not really the answer I wanted to hear, I don't want to test my script. I want to know if the call of llGiveMoney has succeded, in case the user does not have enough money to pay the llGiveMoney. Do you understand?


you have to check the amount received from the event against the amount you expect, as reported by the money() event.

money(key giver, integer amount);

if the 'amount' value is less than what you wanted the item to cost, refund the amount they paid. The item will have to have debit permissions to do that. There are some free vendor scripts available which you could look at as an example.
_____________________
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
04-07-2008 02:37
From: Darien Caldwell
you have to check the amount received from the event against the amount you expect, as reported by the money() event.

money(key giver, integer amount);

if the 'amount' value is less than what you wanted the item to cost, refund the amount they paid. The item will have to have debit permissions to do that. There are some free vendor scripts available which you could look at as an example.


You're missing the point here, what he wants is to be able to execute an llGiveMoney() function, and then test to see if it succeeded. Unfortunately, that is entirely not possible in LSL. What would be nice would be if one could do something like this:

integer test = llGiveMoney (avatarKey, amount);

and if test were true, the function succeeded, false, it did not. However, that is not the case. LL as far as I can see more or less purposely left out pretty much everything aside from llGiveMoney() to cut down on the possiblilty of people being able to determine via scripting peoples L$ account amount. llGiveMoney will just silently fail. Generally, you'll get an IM from someone if a script was supposed to give money and didn't. Usually, this happens when SL is borked, and most people understand. You have to then simply check your transaction log, and verify that the transaction failed, and fix it manually (unless I'm missing something).

The problem with my example is that there's a pretty big lag, 15-30 seconds or so, that the system waits before considering a transaction stale, so something like that as part of lsl would most likely delay the script up to that amount of time before the script would continue to execute... Still, it would be great if you could do that.
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
04-07-2008 11:38
Delay? We know how to handle such things. It could easily look like:

CODE

key moneyRequest = llGiveMoney(target, amount);
...
dataserver(key request, string data)
{
if (request == moneyRequest)
{
integer success = (integer)data;
if (success)
{
// ...
} else
{
// ...
}
}
}

Or some similar asynchronous event.
Darien Caldwell
Registered User
Join date: 12 Oct 2006
Posts: 3,127
04-07-2008 12:42
From: Johan Laurasia
You're missing the point here, what he wants is to be able to execute an llGiveMoney() function, and then test to see if it succeeded. Unfortunately, that is entirely not possible in LSL. What would be nice would be if one could do something like this:

integer test = llGiveMoney (avatarKey, amount);


Sorry, I completely misread the post. oops! :(
_____________________
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
04-07-2008 23:22
From: Hewee Zetkin
Delay? We know how to handle such things. It could easily look like:

CODE

key moneyRequest = llGiveMoney(target, amount);
...
dataserver(key request, string data)
{
if (request == moneyRequest)
{
integer success = (integer)data;
if (success)
{
// ...
} else
{
// ...
}
}
}

Or some similar asynchronous event.


Even better than my suggestion... woot!
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
04-07-2008 23:50
according to
http://wiki.secondlife.com/wiki/LlGiveMoney

From: someone
Function: integer llGiveMoney( key destination, integer amount );


99 Function ID 0.0 Delay 10.0 Energy
Transfer amount of L$ money from script owner to destination avatar.

Returns an integer that is always zero.


• key destination – avatar key.
• integer amount – number of L$, must be greater than zero, (amount > 0)

Requires the PERMISSION_DEBIT permission, granted by the owner, to run.


Therefore checking the return value will not yield you anything useful at all. Its always ZERO.
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
04-08-2008 01:15
From: Squirrel Wood
Therefore checking the return value will not yield you anything useful at all. Its always ZERO.

Yes. We're well aware of that. We're grumbling about "what ifs." Come on. Give some old scripters their grumbles, will ya? ;)
Winter Ventura
Eclectic Randomness
Join date: 18 Jul 2006
Posts: 2,579
04-08-2008 01:56
From: Hewee Zetkin
Yes. We're well aware of that. We're grumbling about "what ifs." Come on. Give some old scripters their grumbles, will ya? ;)


"what ifs" only serve to confuse the OP.

Short answer repeated again... it is IMPOSSIBLE to verify via a script, if llGiveMoney (or llGiveInventory to an avatar) fails.

Frustratingly as well, with the recent problems in SL.. "stale transaction" vendor failures are showing that the "money" event in the vendor scripts is simply NOT being triggered during these "high load" times.. this is what's causing these failures of vendors. The script never "saw" the payment.
_____________________

● Inworld Store: http://slurl.eclectic-randomness.com
● Website: http://www.eclectic-randomness.com
● Twitter: @WinterVentura
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
04-08-2008 03:03
I believe Kelly Linden was quoted as saying that the information simply isn't available to a simulator, and therefore can't be returned immediately. What we need is a new llGiveMoney() function that returns a key, so that we can get a dataserver event with the result. It won't be instant, but at least we could find out if a transaction is failing.
_____________________
Computer (Mac Pro):
2 x Quad Core 3.2ghz Xeon
10gb DDR2 800mhz FB-DIMMS
4 x 750gb, 32mb cache hard-drives (RAID-0/striped)
NVidia GeForce 8800GT (512mb)
Lee Ludd
Scripted doors & windows
Join date: 16 May 2005
Posts: 243
04-08-2008 16:45
From: Haravikk Mistral
... What we need is a new llGiveMoney() function that returns a key, so that we can get a dataserver event with the result. It won't be instant, but at least we could find out if a transaction is failing.


Yes we do need something like this, for llGiveMoney() and llGiveInventory() and even llEmail(). But how long do you wait for the dataserver to return before you conclude the transaction failed?
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
04-09-2008 21:37
From: Lee Ludd
Yes we do need something like this, for llGiveMoney() and llGiveInventory() and even llEmail(). But how long do you wait for the dataserver to return before you conclude the transaction failed?


You don't wait for the dataserver event, events occur when they occur. Say for example (for squirrel wood E X A M P L E, WHAT IF, NOT REAL), that the was (for squirrel wood HYPOTHETICALLY), a key returned on an llGiveMoney() function, like so:

CODE

key transactionQuery;
default
{
state_entry ()
{
transactionQuery = llGiveMoney (key giver, integer amount);
}

dataserver (key query, string data)
{
if (query == transactionQuery) // if true, an llGiveMoney() function was called...
{
if ((integer)data) // if the data returned is true, the money event succeeded
{
llSay (0,"the function succeeded");
}
else
{
llSay (0,"the function failed");
}
}
}
}


That way, the dataserver event would happen when it happened, in other words, say everything goes ok, and the llGiveMoney () function goes off OK, the key would be returned, and the dataserver event triggered. If a transaction fails, the system waits (typically 15-20 seconds or so), and if the system doesn't get confirmation that the transaction succeeded, it considers it a stale transaction, and stops attempting to complete the transaction, which, at that point, it would return the key, which would then trigger the dataserver event, but this time around, the data returned to the dataserver event would be false indicating a failed transaction.