Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Invalid Keys and instant messages and giving money

Siro Mfume
XD
Join date: 5 Aug 2004
Posts: 747
09-16-2004 13:32
I'm having a rather annoying problem.

I'm passing valid keys to a code snippet for both llInstantMessage and llGiveMoney and both refuse to accept the keys. Has anyone else had this problem or am I just doing something woefully incorrect?

myAuthors is a previously defined list of strings ( I am retrieving keys from a notecard).
amount is a previously defined amount of money.
CODE
integer numberOfPeople = llGetListLength(myAuthors);
// Amount each person gets
integer amountPerPerson = amount / numberOfPeople;
// Index of person's key in list.
integer personIndex = 0;
// For every person in the list:
for (personIndex = 0; personIndex < numberOfPeople; personIndex++)
{
// Get the person's key
key personKey = (key)llList2String(myAuthors, personIndex);
llWhisper(0, (string)personKey);
// If person is not owner
// (paying the owner of the object would be redundant)
if (llList2Key(myAuthors, personIndex) != llGetOwner()) {
llInstantMessage(llList2Key(myAuthors, personIndex), ". Your share is L$" + (string)amountPerPerson + ".");
llGiveMoney(llList2Key(myAuthors, personIndex), amountPerPerson);
}
}


it compiles and it should do everything I want it to... I even have it whisper the key it's going to use so I can make sure it'll work right. But it just won't. They both come back and say it's invalid key. Yet I copy and paste the 'invalid key' into a simple script that pays money or sends messages (using the key directly) and it works fine. So seriously, wtf. Is this a type conversion problem or something?
Kurt Zidane
Just Human
Join date: 1 Apr 2004
Posts: 636
09-17-2004 00:35
Well not running your code, but just reading it. I see a few things that are unnecessary.
key personKey = (key)llList2String(myAuthors, personIndex); should be key personKey = llList2Key(myAuthors, personIndex);
You use "llList2Key(myAuthors, personIndex)" several times. It is unnecessary, you've already defines personKey, so use it.

I also notice the script snippet lacks permission.
Ie llRequestPermissions(owner,PERMISSION_DEBIT);
I will assume that you already have permission. Personally I ask for permission right before I pay. That way I never get cought trying to pay, when my script isn't allowed to.

I know you think the list myAuthors contains all valid keys. But how do you know that? And how do you know that all those valid keys are keys of avatars? I would try using llSay(0, "list line " (string)personIndex + " = " + llKey2Name(personKey)); as debug code inside the loop.

I also notice your using devistion with hole numbers. Are you ware that od number may round up, and thus pay out more then it should. Or it may pay out less then what it should.
ie 4.8 = 5, 4.3 = 4