Jump to content

Having a Tip Jar Script Issue!! Please Help!!!


DominicBasino
 Share

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

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

Recommended Posts

Okay. So I wrote a donation script and it works, but when a person pays it the hover text will not how the payment made. 

Example:

Before Billy pays donation jar the hover text shows :  Total donations L$0

Once Billy pays the donation jar the hover text should show : Total Donations L$50 (but it doesn't)

here is the script below please help me fix this:

 

 

integer nTotalDonation;

default
{
on_rez(integer start_param)
{
llResetScript();
}
state_entry()
{
llSetText("Psi Alpha Psi Fraternity Donations!\n" + "Total Donations: L$" + (string)nTotalDonation, <1.0,1.0,1.0>, 1);
}

money(key id, integer amount)
{
string cGiver = llKey2Name(id);
llSay(PUBLIC_CHANNEL, "Psi Alpha Psi thanks you for the donation.");
llInstantMessage(llGetOwner(), "Donation Jar in " + llGetRegionName() + "(" + (string)llGetPos() + ")" + "has recieved a donation from " + cGiver + "; " + (string) amount + "L");
nTotalDonation += amount;
}
}

Link to comment
Share on other sites

Firstly, you have horrible styling. Styling is relevant because the source code is read not by machine but by other programmers and every effort should be made to make it easier for them, not harder.

Do not write code like this:

default
{
on_rez(integer start_param)
{
llResetScript();
}

. . .

. . .

}

Write code like this:

default
{
   on_rez(integer start_param)
   {
      llResetScript();
   }
. . .

. . .

}

Secondly, to the issue, you only set text on script reset. To get dynamic display set text every time money is paid:

money(key id, integer amount)
{
  string cGiver = llKey2Name(id);
  llSay(PUBLIC_CHANNEL, "Psi Alpha Psi thanks you for the donation.");
  llInstantMessage(llGetOwner(), "Donation Jar in " + llGetRegionName() + "(" + (string)llGetPos() + ")" + "has recieved a    donation from " + cGiver + "; " + (string) amount + "L");
  nTotalDonation += amount;

  llSetText("Psi Alpha Psi Fraternity Donations!\n" + "Total Donations: L$" + (string)nTotalDonation, <1.0,1.0,1.0>, 1);
}

 

Link to comment
Share on other sites

The OP made a small mistake that could be fixed by moving or copying a single line of code to the money event. 

Perhaps the OP is new to scripting. 

So my suggestion to you is don't start out by telling the OP that they have done something horrible.

Much easier to accept the answer if it comes likes this:

  • Oh, you made a little mistake - just copy this one line to the money event and you're good to go
  • BTW, if you indent your scripts consistently it will help you and anyone else looking at it

It is good to develop good habits.  Both in scripting and in answering requests for help.

BTW source code is read by the machine.  But you probably already knew that.

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 years later...

Hello all!

Thanks for very valuable information.  Was wondering if any of you might be able to assist with a script for a "tip hat".  I have a new script that allowed me to change both my name and linden amounts however...when an amount is "tipped" the name reverts back to my log in name rather than Russo.  Say's Russo when I first put it out until someone deposits a tip.  Any thoughts or assistance that can be provided would be very helpful.  Thanks in advance :)

Russo Patzoconcini

Link to comment
Share on other sites

It's difficult to say without the script in front of me, but the problem sounds as if it's caused by using llGetDisplayName() to find your name when first you wear the hat but then using something else (llGetUsername()?  llKey2Name(llGetOwner())?  -- there's lot s of possibilities) in the money event.

Simplest fix, to my mind, is to have a global variable, strOwnerName, and set that in the attach event, thus:

string strOwnerName;

default {

	state_entry() {
		strOwnerName = llGetDisplayName(llGetOwner());
	}

	//stuff
	attach(key id) {
		if(id){
			strOwnerName = llGetDisplayName(id);
		}
	}
}

and then simply use strOwnerName in your hovertext and chat.

Link to comment
Share on other sites

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

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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...