Jump to content

Money goes to wrong person


Triexy
 Share

You are about to reply to a thread that has been inactive for 2334 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

My problem is my if query I am using llGiveMoney and thats my problem, I want to send Money to the owner I have try it with money aso but I dont know how to do it.....

 

integer price1 = 100; 
integer price2 = 120; 
integer price3 = 140; 
integer price4 = 160; 

list buttons = ["1 Woche", "2 Wochen", "3 Wochen", "4 Wochen"];
string dialogInfo = "\nPlease make a choice.";

key ToucherID;
integer dialogChannel;
integer listenHandle;
 
default
{
on_rez(integer start_param)
{

llSetPayPrice(PAY_HIDE, [PAY_HIDE ,PAY_HIDE, PAY_HIDE, PAY_HIDE]);
llSetPayPrice(PAY_HIDE, [150,PAY_HIDE,PAY_HIDE,PAY_HIDE]);
llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);
key id = llDetectedKey(0);
}
run_time_permissions(integer perm)
{
if(perm & PERMISSION_DEBIT)
state cash;
}
}

state cash
{
 
    state_entry()
    {

        dialogChannel = -1 - (integer)("0x" + llGetSubString( (string)llGetKey(), -7, -1) );
    }
 
    touch_start(integer num_detected)
    {
        ToucherID = llDetectedKey(0);
 
        llDialog(ToucherID, dialogInfo, buttons, dialogChannel);
        listenHandle = llListen(dialogChannel, "", ToucherID, "");
    }
 
    //HERE'S OUR NEWLY ADDED LISTEN EVENT
    listen(integer channel, string name, key id, string message)
    {
   
 
        // Turn off the listener at a convenient common junction. You can usually avoid coding this multiple times.
        llListenRemove(listenHandle);   
 
        if (message == "1 Woche")
        {
           llSay(0,"bla." );
           llGiveMoney(id, price1);
          // Startet Script test
          
llSetScriptState("woche_01",TRUE);
        }
        else if (message == "2 Wochen")
               
        {
            integer gCountdown = 40;
            llSay(0,"bla" );  ;//do something
         llGiveMoney(id, price2);
        llSetScriptState("woche_02",TRUE);     
         }   
        else if (message == "3 Wochen")

        {
            llSay(0,"blat" );  
            llSetScriptState("woche_03",TRUE); 
    }
    
 else
        {
             llSetScriptState("woche_04",TRUE);
              llGiveMoney(id, price4);
llSay(0,"bla" );
        }
    }

}

Greets and thx

 

 

Link to comment
Share on other sites

 

first, you have:

key id = llDetectedKey(0);

in the on_rez event, nothing is "detected" there, so that won't do anything.

second, you're setting the pay price twice, not sure why.

any money paid to the object goes to the owner of the object, regardless of the script.

the touch event is  allowing anyone to touch it, receive the dialog menu, and make a choice. after they make their choice, the listen event is paying them the money according to the button they press.

if you can explain a little more on what you're trying to acheive, I, or someone else might be able to help more

Link to comment
Share on other sites

I assume (after translating "woche") that you are intending to make a script for paying rent for a number of weeks. Here's what I came up with after re-writing your script. I'm not sure what the other scripts you have named are supposed to do. I assume they have some sort of countdown after being activated, but unless you have a way to reset this script set in those, you may need to add a countdown in this script in order for it to reset and allow someone to pay rent again.

list prices = [100, 120, 140, 160];list buttons = ["1 Woche", "2 Wochen", "3 Wochen", "4 Wochen"];list scripts = ["woche 1", "woche 2", "woche 3", "woche 4"];string dialogInfo = "\nPlease make a choice.";key ToucherID;integer dialogChannel;integer listenHandle;integer index;integer price;integer active = FALSE; default{on_rez(integer start_param){llResetScript();}state_entry(){llSetPayPrice(PAY_HIDE, [PAY_HIDE ,PAY_HIDE, PAY_HIDE, PAY_HIDE]);llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);}run_time_permissions(integer perm){if(perm & PERMISSION_DEBIT)state cash;}}state cash{     state_entry()    {        dialogChannel = -1 - (integer)("0x" + llGetSubString( (string)llGetKey(), -7, -1) );    }     touch_start(integer num_detected)    {        if(!active)        {        ToucherID = llDetectedKey(0);         llDialog(ToucherID, dialogInfo, buttons, dialogChannel);        listenHandle = llListen(dialogChannel, "", ToucherID, "");        }        else        {            llInstantMessage(llDetectedKey(0), "Sorry the system is not available at this moment.");//or whatever message you want when week(s) are already paid for    }}    listen(integer channel, string name, key id, string message)    {            // Turn off the listener at a convenient common junction. You can usually avoid coding this multiple times.        llListenRemove(listenHandle);        index = llListFindList(buttons, [message]);//look in the list of buttons for the message index         if (index >= 0)//if the message exists in the button list        {            price = llList2Integer(prices, index);//use the extracted index to get the intended price from the list of prices            llSay(0,"Pay Price Set To " + (string)price+" for "+message+ ". Please right-click and pay" );            llSetPayPrice(PAY_HIDE, [price ,PAY_HIDE, PAY_HIDE, PAY_HIDE]);//set the intended price        }    }money(key payer, integer Amount){    integer test = llListFindList(prices, [Amount]);//checks to make sure amount received is valid    if(test >= 0)    {        string script = llList2String(scripts, test);//find the script name according to the index found above        llSetScriptState(script, TRUE);//set the script named to active        llInstantMessage(payer, "You have paid for " + llList2String(buttons, test));    active = TRUE;//set to active so that future touches are not used    }    else    {        llInstantMessage(payer, "Amount invalid, please try again.");//If the amount paid isn't in the list of prices, tells avatar, and refunds them        llGiveMoney(payer, Amount);    }    llSetPayPrice(PAY_HIDE, [PAY_HIDE ,PAY_HIDE, PAY_HIDE, PAY_HIDE]);}}
Link to comment
Share on other sites

It looks like you are trying to write a script to collect rents, but you have written it completely backwards.  Instead of collecting money from the person who clicks, it it giving your money to that person.

I suggest spending time reading about how a money event works.  Then, I recommend not using llRequestPermissions with PERMISSION_DEBIT unless you are absolutely sure that you understand how it works and unless you have a good reason to give your money to someone else.  If you are simply collecting money, you can save yourself a lot of trouble -- and possibly a catastrophic L$ loss -- if you forget about using PERMISSION_DEBIT at all.

Link to comment
Share on other sites

A simple example, with no menu...

 

key  gAv;default{    touch_start(integer num)    {        gAv = llDetectedKey(0);        llSay(0,"Thank you for touching.  This vendor only lets you pay for ONE week;"        state OneWeek;    }}state OneWeek{    state_entry()    {        llSetPayPrice(PAY_HIDE,[100,PAY_HIDE,PAY_HIDE,PAY_HIDE]);        llSetClickAction(CLICK_ACTION_PAY);    }    money (key id, integer amount)    {        llSay(0,"Thank for for paying L$" + (string)amount + " for one week's rent.");        llSetClickAction(CLICK_ACTION_TOUCH)        llSetPayPrice(PAY_HIDE,PAY_HIDE,PAY_HIDE,PAY_HIDE,PAY_HIDE]);        state default;     } }

There's the basic logic.  Now all you need to do instead is trigger a dialog in the touch_start event so that you have more than one choice.  Each of the possible choices in your dialog menu should point to a different state (OneWeek, TwoWeek, ThreeWeek, FourWeek) to collect the appropriate rent if the player makes that choice from the menu. (And of course you need to do a lot of things to pretty up the script, but that's not part of the basic logic.)

And again, I advise you to forget about requesting PERMISSION_DEBIT. If you only give renters specific, fixed choices, there's no way that they can give you the wrong amount and expect a refund, so you don;t need to provide that option in your script.

 

 

Link to comment
Share on other sites

I have now the player choice his week and after that the he need to do right click and pay but I want player click on 1 week and he transfer the money to me

 

list prices = [10, 20, 30, 40];list buttons = ["1 Woche", "2 Wochen", "3 Wochen", "4 Wochen"];list scripts = ["1_woche", "2_woche", "3_woche", "4_woche"];string dialogInfo = "\nPlease make a choice.";key ToucherID;integer dialogChannel;integer listenHandle;integer index;integer price;integer active = FALSE; default{on_rez(integer start_param){llResetScript();}state_entry(){llSetPayPrice(PAY_HIDE, [PAY_HIDE ,PAY_HIDE, PAY_HIDE, PAY_HIDE]);llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);}run_time_permissions(integer perm){if(perm & PERMISSION_DEBIT)state cash;}}state cash{     state_entry()    {        dialogChannel = -1 - (integer)("0x" + llGetSubString( (string)llGetKey(), -7, -1) );            }     touch_start(integer num_detected)    {        if(!active)        {        ToucherID = llDetectedKey(0);         llDialog(ToucherID, dialogInfo, buttons, dialogChannel);        listenHandle = llListen(dialogChannel, "", ToucherID, "");        }        else        {         ToucherID = llDetectedKey(0);         llDialog(ToucherID, dialogInfo, buttons, dialogChannel);        listenHandle = llListen(dialogChannel, "", ToucherID, "");    }}    listen(integer channel, string name, key id, string message)    {            // Turn off the listener at a convenient common junction. You can usually avoid coding this multiple times.        llListenRemove(listenHandle);        index = llListFindList(buttons, [message]);//look in the list of buttons for the message index         if (index >= 0)//if the message exists in the button list        {            price = llList2Integer(prices, index);//use the extracted index to get the intended price from the list of prices            llSay(0,"Pay Price Set To " + (string)price+" for "+message+ ". Please right-click and pay" );            llSetPayPrice(PAY_HIDE, [price ,PAY_HIDE, PAY_HIDE, PAY_HIDE]);//set the intended price        }    }money(key payer, integer Amount){    integer test = llListFindList(prices, [Amount]);//checks to make sure amount received is valid    if(test >= 0)    {        string script = llList2String(scripts, test);//find the script name according to the index found above        llSetScriptState(script, TRUE);//set the script named to active        llInstantMessage(payer, "You have paid for " + llList2String(buttons, test));    active = TRUE;//set to active so that future touches are not used    }    else    {        llInstantMessage(payer, "Amount invalid, please try again.");//If the amount paid isn't in the list of prices, tells avatar, and refunds them        llGiveMoney(payer, Amount);    }    llSetPayPrice(PAY_HIDE, [PAY_HIDE ,PAY_HIDE, PAY_HIDE, PAY_HIDE]);}}
Link to comment
Share on other sites

Yes the command money is working but I cant use it for a query

To example

1 week = 10l$

2 weeks = 20$

3 weeks = 30$

4 weeks = 40$

 

so the user has clicked on the prim and seeing now a dialog with

1 week

2 week

3 week

4 week

after he clicked on 1 week he paid automatically 10l$ on 2 weeks 20l$ and so on.

Link to comment
Share on other sites


Ruthven Willenov wrote:

I only put the test for a valid amount because, as it's scripted the official viewer would only show the scripted choices, but a third-party viewer may allow someone to enter a different amount. I put the permission debit in case that were to happen, they would be refunded.

We all use the same LSL.  :smileywink:

And since the OP clearly does not understand how
money
works, it's dangerous for him to be scripting anything that includes PERMISSION_DEBIT.  He can be opening a trap door that will suck up all his L$.

Link to comment
Share on other sites


Triexy wrote:

Yes the command money is working but I cant use it for a query

To example

1 week = 10l$

2 weeks = 20$

3 weeks = 30$

4 weeks = 40$

 

so the user has clicked on the prim and seeing now a dialog with

1 week

2 week

3 week

4 week

after he clicked on 1 week he paid automatically 10l$ on 2 weeks 20l$ and so on.

That sounds like exactly what you asked for.  Congratulations.

Link to comment
Share on other sites


Ruthven Willenov wrote:

I don't understand where the problem is then. Are you expecting the dialog to take the money after the user makes a choice? Dialogs can't do that.

Absolutely right.  The user will need to touch the vendor twice: one time to get the dialog and the second time to pay it.  That's the way SL works. 

That is why I wrote my very simple example the way I did, so it is obvious that there are two touches. The only significant weakness in having more than one touch -- instead of just using a simple PAY window -- is that there is no way to prevent a second person from paying after the player has clicked the dialog menu.  If you know what you are doing, you could refund the second person's payment if that happens -- so that's a legitimate reason to have PERMISSION_DEBIT -- or you could just decide that it's such an unlikely circumstance that it's not worth worrying about. :smileywink:

Link to comment
Share on other sites


Triexy wrote:

My problem is I dont find a way how to make a Dialog before he pays

Right. Don't do that. It is not the standard way payment works in SL, it would confuse payers, and force them to jump through a clumsy extra dialogue step before each payment.

As recommended much earlier, simply use four different pay prices in llSetPayPrice() corresponding to the four different terms of the rental -- this is what payers will expect. Do check that the money() event amount is for one of those prices and credit the rental duration accordingly -- and if the amount is not one of those prices, maybe fuss about it, but do not llGiveMoney() to send it back, and do not request PERMISSION_DEBIT. That would be to go dangerously out of your way to help someone trying to swindle you.

Link to comment
Share on other sites

Ok i have done it now like that dialog menue set the price and after that he need todo a right click on pay. Thx your helpout and to show me how it works at second life really thx it was helpfully. Give it some good Books or something to learn more because I want to learn it correct :)

Link to comment
Share on other sites

  • 3 weeks later...

"- or you could just decide that it's such an unlikely circumstance that it's not worth worrying about. Smiley Wink"

After 30 years in the software industry , I have found that unlikely circumstances will ALWAYS happen, and bite you you know where :) 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2334 days.

Please take a moment to consider if this thread is worth bumping.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...