|
Haplo Voss
Registered User
Join date: 18 Nov 2006
Posts: 137
|
03-31-2007 09:40
Ok I have searched my butt off, perhaps I am just not using the right keywords, and I've looked throught the wiki and tried every variation of money() GiveMoney() and others I can think of... but I can't seem to get an object to PAY another person to save my life... Here is what I am trying to do: I need a tip / donation jar right? Ok no problem. Got that as you can see below. NOW THEN... every 100th person (or whatever you sript into it) wins some money back. HOW DO I PAY THEM??? Here is the basic Donation Script I have: //Winner() //{ // llShout(0,"YOU ARE THE 100th DONATION!!"); // llShout(0,"Every 100th Donation wins L$100!"); // llSay(0,"Thank you very much for your contribution and congratulations!"); // // llGiveMoney(llKey2Name(id),3); //}
integer totaldonated; string owner; integer counter;
default { state_entry() { owner = llKey2Name(llGetOwner()); llSetText( "All donations gratefully accepted!\n$0 donated so far.\nClick on me and select Pay to donate.",<1,1,1>,1); } on_rez( integer sparam ) { llResetScript(); }
money(key id, integer amount) { totaldonated+=amount; llSetText( "All donations gratefully accepted!\n$" + (string)totaldonated + " donated so far.\nClick on me and select Pay to donate.",<1,1,1>,1); llInstantMessage(id,"Thanks very much for the tip!"); llInstantMessage(llGetOwner(),llKey2Name(id)+" donated $" + (string)amount); //counter++; //if (counter==3) //Had it set up to 3 for testing w/ friends. never has worked yet. //{ //counter=0; //Winner(); //{ } }
The above script contains my very first generation attempt at giving money back. I only included it to show you how I tried to go about it... I tried using get permission everything I could find and think of, but it never did work right. Please refrain from complete humiliation ifi t's really simple. Thanks for any help you can provide!
|
|
Sys Slade
Registered User
Join date: 15 Feb 2007
Posts: 626
|
03-31-2007 10:11
You are trying to pay a name rather than a key, and using llKey2Name(id) in a function where id is undefined. The code also has a typo ( { instead of } ). Also, do you need the owners name stored for any reason? You are defining the owner variable without ever using it. Finally, you never request permissions to debit the owners account, so attempted payments will fail. Tested for typos etc: integer totaldonated=0; integer counter=0; integer prize=10;
default{ state_entry(){ llRequestPermissions(llGetOwner(),PERMISSION_DEBIT); llSetText("All donations gratefully accepted!\n$0 donated so far.\nClick on me and select Pay to donate.",<1,1,1>,1); } on_rez( integer sparam ){ llResetScript(); }
money(key id, integer amount){ totaldonated+=amount; llSetText("All donations gratefully accepted!\n$" + (string)totaldonated + " donated so far.\nClick on me and select Pay to donate.",<1,1,1>,1); llInstantMessage(id,"Thanks very much for the tip!"); llInstantMessage(llGetOwner(),llKey2Name(id)+" donated $" + (string)amount); counter++; if(counter==3){ llShout(0,"YOU ARE THE 100th DONATION!!"); llShout(0,"Every 100th Donation wins L$100!"); llSay(0,"Thank you very much for your contribution and congratulations!"); llGiveMoney(id,prize); counter=0; } } } change prize to whatever value you want, and make sure to change counter==3. One final point, llInstantMessage delays scripts by 3 seconds. llSay doesn't. Presumably you want the owner to recieve an IM (and email if they are off world), but is it necessary for the tipper to have an IM?
|
|
Haplo Voss
Registered User
Join date: 18 Nov 2006
Posts: 137
|
03-31-2007 10:34
Thank you very much for the help! No there really isn't any purpose for the Instant Message other than the fact that I have found some people like to be 'anonymous' when tipping, aside from when they win something!  I was thinking that llSay would let everyone see it unless I defined a channel. I must have made an incorrect definition somewhere in the past, because when I tried using the same statement: llGiveMoney (id,variable); it didn't work, therefore I tried the name thinking perhaps I was wrong and it did have to be attached to the name rather than the id. LSL is so weird sometimes, not to mention I have a hard time finding information on command formats. Descriptions are great, but how the command actually works is what's important you know? Originally - I stored the owner's name so as to use it in a couple of places. I didn't think to take it out afterwards. Good point. Thanks again for the help and for pointing out where everything is. I'm going to comment it out for myself and others. Let me know if it's ok to include you as the fixer. - Hap
|
|
Sys Slade
Registered User
Join date: 15 Feb 2007
Posts: 626
|
03-31-2007 10:43
It was less than 2 minutes work, you don't need to give me any credit  If you're looking for clear usage instructions for the functions, I always use this wiki: http://rpgstats.com/wiki/index.phpMost of the functions have small demos as well. If you want anonymity, you can actually circumvent the 3 second delay on IMs using link messages. It has potential for abuse though, so I'll contact you in world about it.
|