Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

List payer (donator) names as llSetText

Man Clave
Registered User
Join date: 30 Jan 2007
Posts: 22
04-17-2007 19:18
I'm a newbie to script, and i need help to get have donator (payer) names list above the donation box. Could anyone show me how to do that please?

below is the code for my donation box.

CODE


integer price = 1;



default
{
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()
{
llSetPayPrice(PAY_HIDE, [price, PAY_HIDE, PAY_HIDE, PAY_HIDE]);
}
money(key id, integer amount)

{
llInstantMessage(id, "thank you for your donation.");
}
}
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
04-17-2007 20:28
you dont really need to ask permissions unless your giving money out from your av via script ... anyone else can pay you without them

CODE

integer price = 1;

string user_names;


default
{
state_entry()
{
llSetPayPrice(price, [PAY_HIDE ,PAY_HIDE, PAY_HIDE, PAY_HIDE]);
}

money(key id, integer amount)
{
llInstantMessage(id, "thank you for your donation.");

// if string is full clear it
if (llStringLength(user_names) >= 255) user_names = "";

user_names += (llKey2Name(id) + "\n");

llSetText(user_names, <1,1,1>, 1);
}
}

Deanna Trollop
BZ Enterprises
Join date: 30 Jan 2006
Posts: 671
04-17-2007 20:58
Or here's a slight twist. This will, instead of wiping the list when it reaches capacity (which, according to the wiki, is 255 characters, not 1024), it'll just remove the first name (or rather, as many as necessary to bring it down to 255 or less.)

CODE

money( key id, integer amount )
{
llInstantMessage( id, "thank you for your donation." );

user_names += llKey2Name( id ) + "\n";

while( llStringLength( user_names ) > 255 )
user_names = llDeleteSubString( user_names, 0, llSubStringIndex( user_names, "\n" ) );

llSetText( user_names, < 1, 1, 1 >, 1 );
}
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
04-17-2007 22:07
From: Deanna Trollop
Or here's a slight twist. This will, instead of wiping the list when it reaches capacity (which, according to the wiki, is 255 characters, not 1024), it'll just remove the first name (or rather, as many as necessary to bring it down to 255 or less.)

CODE

money( key id, integer amount )
{
llInstantMessage( id, "thank you for your donation." );

user_names += llKey2Name( id ) + "\n";

while( llStringLength( user_names ) > 255 )
user_names = llDeleteSubString( user_names, 0, llSubStringIndex( user_names, "\n" ) );

llSetText( user_names, < 1, 1, 1 >, 1 );
}



your correct on the 255, i remembered a thing about text being 1024, looking tru the blog it does 1023, for chat

just for giggles i thought i would test it (the wiki for what its worth does have the occasional mistake) loaded up a string right at 1023, and set it at hovertext ... and it died right at 255

which kinda sucks hovertext would have benifited from it but whatever

ive changed my above script in between the 2 chunks of code (my blind written quickie and Deanna's revision) you should be able to hammer this out

:)
Man Clave
Registered User
Join date: 30 Jan 2007
Posts: 22
Thanks!
04-20-2007 15:56
Thanks alot for your help. But i have one more question though.

I have a friend ( a girl). She just keep on donated me for the last few days. Is there anyway to NOT taking money from her through the donate box? Cause she donated when i wasn't there, and i dont want to do that.

Thanks
Kenn Nilsson
AeonVox
Join date: 24 May 2005
Posts: 897
04-20-2007 21:14
You can create a list of keys from whom you do not wish to accept payment...check the 'giver' key in your money event against this list (llListFindList()), and if there's a match, pay them back with an llGiveMoney() function (remember to request PERMISSION_DEBIT from yourself with the script).

You can also opt to turn the donation script off while you're away...either through a touch on/off (state switch would probably be easiest) or an actual online-check that turns off automatically when you go offline and turns on automatically when you come online.
_____________________
--AeonVox--

Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms chasing ghosts, eating magic pills, and listening to repetitive, addictive, electronic music.
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
04-20-2007 22:45
on /off for everyone based on your online time
CODE

integer price = 1;
integer time = 30;
string user_names;

default
{
state_entry()
{
llSetPayPrice(price, [PAY_HIDE ,PAY_HIDE, PAY_HIDE, PAY_HIDE]);
llSetTimerEvent(time);
}

money( key id, integer amount )
{
llInstantMessage( id, "thank you for your donation." );
user_names += llKey2Name(id) + "\n";

do
{
user_names = llDeleteSubString( user_names, 0, llSubStringIndex( user_names, "\n" ) );
}

while( llStringLength( user_names ) > 255 );

llSetText( user_names, < 1, 1, 1 >, 1 );
}

timer()
{
llRequestAgentData(llGetOwner(), DATA_ONLINE);
}

dataserver(key qid, string data)
{
if (data) llSetTimerEvent(time);
else state offline;
}
}

state offline
{
timer()
{
llRequestAgentData(llGetOwner(), DATA_ONLINE);
}

dataserver(key qid, string data)
{
if (data) state default;
else llSetTimerEvent(time);
}
}
Deanna Trollop
BZ Enterprises
Join date: 30 Jan 2006
Posts: 671
04-21-2007 08:49
One slight correction to Osgeld's code above:

CODE

dataserver(key qid, string data)
{
// This evaluates as false only if data is an empty string,
// which it shouldn't ever be when requesting AGENT_ONLINE
if (data)

// Cast data to an integer so that you are evaluating wether
// the value is is 0 (false) or non-0 (true)
if ( (integer)data )
// Agent is online
else
// Agent is offline
}