llGiveMoney Permissions while Creator is offline
|
|
Bart Brule
Registered User
Join date: 10 Dec 2006
Posts: 4
|
12-26-2006 04:21
Hey Guys, the first thing I want to say ist that SL ist the best Game I've ever played. There are so many possibilities to have fun - it's unbelievable.
Because I'm loving scripting in PHP I've tried that in SL, too. LSL is a really easy Scripting Language but I have a problem with llGiveMoney and its permissions. I have the following:
state waiting_for_money { state_entry() { llRequestPermissions(llGetCreator(),PERMISSION_DEBIT); } money(key id, integer amount) { if (amount == 10) { state gz1; } else{ if (amount > 10) { integer diff = amount - 10; llGiveMoney(namekey,diff); state gz1; } if (amount < 10) { llGiveMoney(namekey,amount); state waiting_for_money; } } } }
The problem I have is, that everytime when an avatar pays too much or too many money, the script asks for permissions to give him or her the difference / money back. But when I'm offline there is the error, that the keyid is wrong, because the user is not available (sure, I'm offline).
There must be a possibility to transfer that money back to the avatar without asking me every time. In which way the money chairs are working? I don't think that they ask their Owner / Creator for every transfer.
Thanks for your sulution. Best regards Bart
|
|
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
|
12-26-2006 04:58
Your issue might be that you are changing states there, and every time you enter the state waiting_for_money it tries to get debit permission again. So it will give back money the first time, but then re-enter the state, try to get debit permission and fail, because you have to be logged in to grant debit permission.
Incidentally (a) using the PHP tags is a good idea if you're quoting code, and (b) I would use llGetOwner() rather than llGetCreator() there if you ever want to have anyone else use this script and not have the object ask _you_ for money all the time!
_____________________
http://ordinalmalaprop.com/forum/ - visit Ordinal's Scripting Colloquium for scripting discussion with actual working BBCode!
http://ordinalmalaprop.com/engine/ - An Engine Fit For My Proceeding, my Aethernet Journal
http://www.flickr.com/groups/slgriefbuild/ - Second Life Griefbuild Digest, pictures of horrible ad griefing and land spam, and the naming of names
|
|
Bart Brule
Registered User
Join date: 10 Dec 2006
Posts: 4
|
12-26-2006 05:21
Hi, that Object is a game where you can guess a number between 1 and 10. When that number is correct you get an amount of money. Because nobody else get this script, there is llGetCreator (it will be me every time).
Well, is there any possibility to pay money without get the permission request every time?
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
12-26-2006 05:37
From: Bart Brule Hi, that Object is a game where you can guess a number between 1 and 10. When that number is correct you get an amount of money. Because nobody else get this script, there is llGetCreator (it will be me every time).
Well, is there any possibility to pay money without get the permission request every time? You can only get debit permissions for the owner, not the creator. If you will always be the owner then thats not a problem. Take permiission once in on rez in default state rather than every time. You can check if you need to by performing an llGetPermissions Your money event handler is also a bit long winded. Changing state to the same state is pointless.
|
|
Bart Brule
Registered User
Join date: 10 Dec 2006
Posts: 4
|
12-26-2006 06:10
Sorry, that was my mistake. I scripted a simple thing and it worked fine. Here is the example: default { state_entry() { llSay(0, "Checking for PERMISSION_DEBIT"); llRequestPermissions(llGetOwner(),PERMISSION_DEBIT); }
touch_start(integer total_number) { integer perm = llGetPermissions(); if (perm & PERMISSION_DEBIT) // using & is important! perm is a bitmask! { llSay(0, "You have permission to get money from the owner"); llGiveMoney(llDetectedKey(0),1); } else { llSay(0, "Owner gave no permission to pay money from his account"); } } } Does it works in differnt states, too? Bart
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
12-26-2006 06:25
From: Bart Brule Sorry, that was my mistake. I scripted a simple thing and it worked fine. Here is the example:
[Does it works in differnt states, too?
Bart Once assigned permissions persist until next requested or script reset.
|
|
Tyann Toll
It went... where?!
Join date: 17 Dec 2006
Posts: 37
|
Script that changes animations when keys are pressed
12-26-2006 11:58
I am working on a small script idea that is based on capturing keypresses to start animations. It could be used for a fighting game, or a dancing game. I've had a look at the example scripts on the LSL wiki, and have come up with the following (likely nightmarish) crossbreed. I would really appreciate any input on it, including flame about how horrible it is, and why it wont work (so I can secretly learn). I should probably say that I am not sure it even works, since I am far, far away from a machine that can actually run Second Life^^. // dance/combat script 0.1 - Tyann Toll // A script that puts the avatar into one animation, and then plays other animations when keys are pressed // Based on script examples from lslwiki.com // credit to Ready Jack (pistol script, example control script), Catherine Omega Heavy Industries (basic animation script)
// animations for the various moves and stances
string BaseAnim = "ready"; string Move1 = "punch"; string Move2 = "kick"; string Move3 = "bite"; string Move4 = "claw";
// declare functions for later
say(string message) // This is used to give feedback { llOwnerSay(message); }
// script begins here
default { attach(key who) { if (who == NULL_KEY) // This means that the item containing the script is detached { if (llGetPermissions() & PERMISSION_TAKE_CONTROLS) { llReleaseControls(); } } else { llRequestPermissions(who, PERMISSION_TAKE_CONTROLS | PERMISSION_TRIGGER_ANIMATION); } }
run_time_permissions(integer perms) { integer desired_controls = CONTROL_FWD | CONTROL_BACK | CONTROL_LEFT | CONTROL_RIGHT | ;
if (perms & PERMISSION_TAKE_CONTROLS) { llTakeControls(desired_controls, TRUE, TRUE); }
}
control(key id, integer down, integer new) { integer pressed = down & new; integer held = down & ~new; integer released = ~down & new;
say ("Use W,A, S, D to fight!") if ((held & CONTROL_FWD) llStartAnimation(Move1); // Move One while W is pressed if ((held & CONTROL_BACK) llStartAnimation(Move2); // Move Two while S is pressed if ((held & CONTROL_RIGHT) llStartAnimation(Move3); // Move Three while D is pressed if ((held & CONTROL_LEFT) llStartAnimation(Move4); // Move Three while A is pressed } }
*leaps into cover and adopts brace position*
|