Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

tip jar help

Dragger Allen
Registered User
Join date: 3 Mar 2007
Posts: 247
06-09-2007 10:26
ok first off not sure if this is in the right section but its scripting and i need help

I purchased a tip jar script with full perms to put in a object i am selling but the script gives an error of

: Invalid parameter in llGiveMoney().
i am not a scripter in any way that is why i buy full perm scripts for items when i need them so any help would be appreacated thank you in advance


key line1;

key keyactive;
string nameactive;

key splitwith;
integer percentage;

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

state_entry()
{
line1 = llGetNotecardLine("config",0);
llSetText("Tip jar intactive", <1,1,1> ,1.0);
}

dataserver(key queryid, string data)
{
if (queryid == line1)
{
list templist = llParseString2List(data, [" "],[]);
splitwith = (key) llList2String(templist,0);
percentage = (integer) llList2String(templist,1);
llOwnerSay("Profit will be split with: "+llKey2Name(splitwith)+". Person will receive: "+(string) percentage+"%.";);

llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);
}
}

run_time_permissions (integer perm)
{
if (perm == PERMISSION_DEBIT)
{
state active;
} else
{
llOwnerSay("I need those permissions. Please reset me to try again.";);
}
}

}

state active
{
on_rez(integer param)
{
llResetScript();
}

state_entry()
{
llSetText("Tip jar unassigned",<1,1,1>,1.0);
llSetPayPrice(PAY_HIDE, [PAY_HIDE, PAY_HIDE, PAY_HIDE, PAY_HIDE]);
}


touch_start(integer nr)
{
key toucher = llDetectedKey(0);
if (!llSameGroup(toucher))
{
return;
}

if (toucher == keyactive)
{
keyactive = NULL_KEY;
nameactive = "";
llSetText("Tip jar unassigned",<1,1,1>,1.0);
llSetPayPrice(PAY_HIDE, [PAY_HIDE, PAY_HIDE, PAY_HIDE, PAY_HIDE]);
} else
{
keyactive = toucher;
nameactive = llKey2Name(toucher);
llSetText(nameactive+"'s tip jar",<1,1,1>, 1.0);
llSetPayPrice(PAY_DEFAULT, [PAY_DEFAULT, PAY_DEFAULT, PAY_DEFAULT, PAY_DEFAULT]);
}

}

money(key id, integer amount)
{
integer split = llRound((amount * percentage) / 100);
integer tipreceiver = amount - split;
llGiveMoney(keyactive, tipreceiver);
llGiveMoney(splitwith, split);

llSay(0,"Thank you for your donation.";);
}
}


and here is the note card

34353002-c0c7-4fdc-b232-a84ec3682b8f 10

# first line containts the key of the person to split profit with and the percentage in % seperated with a space
# for example:
b1c6f961-0e0c-4de1-ba69-307b9d58f742 10
# this would give me Goldorak Alonzo the creator of this script 10% of all tips. REMEMBER IT MUST BE ON THE FIRST LINE!!!

# to retreive the key of an avater use the key extractor or go to http://w-hat.com/name2key
Jake Trenchard
Registered User
Join date: 31 May 2007
Posts: 104
06-09-2007 11:27
I'm guessing you probably didn't put the right config information in the notecard, so the 'splitwith' key isn't valid.
RJ Source
Green Sky Labs
Join date: 10 Jan 2007
Posts: 272
06-09-2007 11:28
It looks like it requires a notecard named "config".
Did you have that in there? Posting the contents would help, since the notecard lines could be the problem.
Jim Guyot
Tinkerer
Join date: 21 Apr 2007
Posts: 38
06-09-2007 14:05
There is also the possibility that run time permissions do not keep during state changes. I don't know this for certain, however, as I am fairly new to using permissions.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
06-10-2007 00:45
I assume all other indications are correct?
i.e. the tip jar name is set to teh toucher and the percentage pay out message shows teh correct value?

As previosuly stated the most likely cause is an invalid key but also check for a zero or negative amount.

Try Adding a couple of llSay's around the llGiveMoney to see what values it is using.

Code Fragment
CODE

// Add this function outside of the state definitions
PayMoney(key id, integer amount)
{
if( (id != NULL_KEY) && (amount > 0))
{
llGiveMoney(id, amount);
llSay(0,"Giving " + llKey2Name(id) + " L$" + (string)amount);
}
}


money(key id, integer amount)
{
integer split = llRound((amount * percentage) / 100);
integer tipreceiver = amount - split;

PayMoney(keyactive, tipreceiver );
PayMoney(splitwith, split);
}


Jim, Permissions are retained across state changes. You would receive a trying to take money but DEBIT permissiosn not granted type message had that been the case.
_____________________
I'm back......
Boss Spectre
Registered User
Join date: 5 Sep 2005
Posts: 229
06-10-2007 04:40
Note that llKey2Name() will only return the agent's name if they are present in the sim where this script is run, otherwise it will be blank. Here is a method you can use to make sure that they key given in the notecard is a valid agent:

CODE

// at the top add the following line:
key agentinfo;


// replace the dataserver event handler with this one:
dataserver(key queryid, string data)
{
if (queryid == line1)
{
list templist = llParseString2List(data, [" "],[]);
splitwith = (key) llList2String(templist,0);
percentage = (integer) llList2String(templist,1);
if (splitwith) // only TRUE if key looks like a valid one
{
llOwnerSay("Checking key " + (string)splitwith + ", if script does not continue then key is invalid.");
agentinfo = llRequestAgentData(splitwith, DATA_NAME);
}
else
{
llOwnerSay("ERROR: Invalid key found in first line of note. Reset script after fixing this, to try again.");
}
}
else if (queryid == agentinfo)
{
llOwnerSay("Profit will be split with: "+ data +", who will receive: "+(string) percentage+"%.");

llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);
}
}


This code will complain if the note does not find a (possibly valid) key in the note, and will stop before asking permission for debit if the key is not a valid agent key.

Other suggestions for future improvement: To make the script re-read the note if it's changed, and to put a timer on the agent validation to handle the situation if there is no response to the request for the agent's name. I can post a new version of the script with these features if you wish.
Dragger Allen
Registered User
Join date: 3 Mar 2007
Posts: 247
06-10-2007 07:53
i would love to see the additions on the script
as i said i am not a scriptor and i purchase the scripts i need for p[rojects its just aggrivating to purch one and it does not work

so thanks once again i will try to see if i can get it working so i can un viel this project on saturday at the opening of a friends place
Boss Spectre
Registered User
Join date: 5 Sep 2005
Posts: 229
06-13-2007 14:50
Here you go, a complete version of the above posted script with these additions:

1) Checks note "config" but if that is not present, checks first note in the object
2) Re-reads the note / resets the script if the note is changed.
3) Validation of the percentage split participant's agent key (from the note).
4) Timeout message on key validation, waits for note to be edited.
5) Sends $L1 to Boss Spectre for every tip received. (Just kidding.)

(If BBCode is still turned off when you read this, you can copy the original script with its formatting by pressing "Quote" on this message and copying it from the edit box with its original indentation, then pressing the Back button on your browser without sending a reply. Remember not to copy the [] enclosed tags at the top and bottom of the script.)

CODE

string notename = "config"; // default name for config note

// variables below this line are set by the code or the notecard

key keyactive; // who will receive the bulk of the tip
string nameactive; // this person's name

key splitwith; // who will receive a percentage of the tip
integer percentage; // how much is that share of the tip

key notekey; // the key of the note which was last read
key line1; // query ID for notecard line
key agentinfo; // query ID for agent's name

// checks if note exists, and if not, gets first notecard in object
// only re-reads if the note has changed since it was last read.
readnote()
{
string name = notename;
key newkey;

if (llGetInventoryType(name) != INVENTORY_NOTECARD) // if note not found
{
if (llGetInventoryNumber(INVENTORY_NOTECARD) < 1) // if no notes found
{
llOwnerSay("Notecard \"" + notename + "\" is missing from this object.");
return;
}

name = llGetInventoryName(INVENTORY_NOTECARD, 0); // get first note's name
}
newkey = llGetInventoryKey(name);
if (newkey != notekey) // note needs to be read
{
llOwnerSay("Reading notecard \"" + name + "\"...");
notekey = newkey;
line1 = llGetNotecardLine(name, 0);
agentinfo = NULL_KEY;
notename = name;
}
}


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

state_entry()
{
llSetText("Tip jar intactive", <1,1,1> ,1.0);
readnote();
}

dataserver(key queryid, string data)
{
if (queryid == line1)
{
list templist = llParseString2List(data, [" "],[]);
splitwith = (key) llList2String(templist,0);
percentage = (integer) llList2String(templist,1);
if (splitwith) // only TRUE if key looks like a valid one
{
llOwnerSay("Fetching name for key " + (string)splitwith + "...");
agentinfo = llRequestAgentData(splitwith, DATA_NAME);
llSetTimerEvent(20.0); // set a 20 second timeout
}
else
{
llOwnerSay("ERROR: Invalid key found in first line of note. Reset script after fixing this, to try again.");
}
}
else if (queryid == agentinfo)
{
llOwnerSay("Payments will be split with: "+ data +", who will receive: "+(string) percentage+"%.");

llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);
llSetTimerEvent(0.0);
}
}

run_time_permissions (integer perm)
{
if (perm == PERMISSION_DEBIT)
{
state active;
} else
{
llOwnerSay("I need those permissions. Please reset me to try again.");
}
}

changed(integer change)
{
if (change & CHANGED_INVENTORY)
{
readnote(); // will only read if note actually changed
}
}

timer()
{
llSetTimerEvent(0.0);
llOwnerSay("Error, key \"" + (string)splitwith + "\" does not appear to be a valid agent key, waiting for note to be changed.");
}

}

state active
{
on_rez(integer param)
{
llResetScript();
}

state_entry()
{
llSetText("Tip jar unassigned",<1,1,1>,1.0);
llSetPayPrice(PAY_HIDE, [PAY_HIDE, PAY_HIDE, PAY_HIDE, PAY_HIDE]);
}


touch_start(integer nr)
{
key toucher = llDetectedKey(0);
if (!llSameGroup(toucher))
{
return;
}

if (toucher == keyactive)
{
keyactive = NULL_KEY;
nameactive = "";
llSetText("Tip jar unassigned",<1,1,1>,1.0);
llSetPayPrice(PAY_HIDE, [PAY_HIDE, PAY_HIDE, PAY_HIDE, PAY_HIDE]);
} else
{
keyactive = toucher;
nameactive = llKey2Name(toucher);
llSetText(nameactive+"'s tip jar",<1,1,1>, 1.0);
llSetPayPrice(PAY_DEFAULT, [PAY_DEFAULT, PAY_DEFAULT, PAY_DEFAULT, PAY_DEFAULT]);
}

}

money(key id, integer amount)
{
integer split = llRound((amount * percentage) / 100);
integer tipreceiver = amount - split;
llGiveMoney(keyactive, tipreceiver);
llGiveMoney(splitwith, split);

llSay(0,"Thank you for your donation.");
}

changed(integer change)
{
if (change & CHANGED_INVENTORY)
{
if (llGetInventoryKey(notename) != notekey) // note needs to be read
llResetScript(); // need to reset
}
}

}
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
02-25-2008 17:10
thanks for the script! :-) but how do you change the default tip amounts?
Claari Shepherd
Danri CEO and Designer
Join date: 20 Feb 2007
Posts: 170
02-25-2008 20:00
From: someone
I purchased a tip jar script with full perms to put in a object i am selling


Just from a business perspective, you posted an entire script that you purchased that you intend to use in an object you want to sell. First off, you've provided the creator's entire script code to the SL community for free.... and may have cut yourself from some profits. Anyone wanting such a tip jar can now use this code to create their own removing the need to purchase the script from the original creator or purchase the item from you.

When you pay for a script and it doesn't work as intended.. it's best to contact the creator directly so that they may fix the script or instruct you on use. I understand if they were non-responsive or you were unable to contact them.

And thanks to the scripting community. I've learned quite a bit here myself reading these forums. You provide an invaluable service to those trying to learn to write LSL code.