|
Stephen Delcon
Registered User
Join date: 16 Feb 2007
Posts: 7
|
04-10-2007 03:47
I have written a script for a game machine, but I can't get it to keep the key ID of the user... I get the key, when the user pay the mechine, but because it changes states a couple of times, the key is not stored... have used llGetOwner() for testing, but need for something to get the user key. my script looks like this: . . key user; default { state_entry() { llRequestPermissions( llGetOwner(), PERMISSION_DEBIT ); } run_time_permissions(integer perms) { if (perms & PERMISSION_DEBIT) state PermissionGiven; } }
state PermissionGiven { money(key id, integer amount) { if (amount != price) { llWhisper(0,"Sorry! The price is $" + (string)price); llGiveMoney(id,amount); } else { state GoOn; } } }
state GoOn { state_entry() { . . state game; } }
state game { state_entry() { llListen(Channel,"",user, ""); user = llGetOwner(); // KEY ISSUE!!! llInstantMessage(user, "Game startet!"); . . .
(I have greatly reduced the code, to make it easier to read) What I need is a way to get the key of the user, instad of using "llGetOwner()" as I am done testing.
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
04-10-2007 03:50
From: Stephen Delcon I have written a script for a game machine, but I can't get it to keep the key ID of the user... I get the key, when the user pay the mechine, but because it changes states a couple of times, the key is not stored... have used llGetOwner() for testing, but need for something to get the user key. my script looks like this: . . key user; default { state_entry() { llRequestPermissions( llGetOwner(), PERMISSION_DEBIT ); } run_time_permissions(integer perms) { if (perms & PERMISSION_DEBIT) state PermissionGiven; } }
state PermissionGiven { money(key id, integer amount) { if (amount != price) { llWhisper(0,"Sorry! The price is $" + (string)price); llGiveMoney(id,amount); } else { state GoOn; } } }
state GoOn { state_entry() { . . state game; } }
state game { state_entry() { llListen(Channel,"",user, ""); user = llGetOwner(); // KEY ISSUE!!! llInstantMessage(user, "Game startet!"); . . .
(I have greatly reduced the code, to make it easier to read) What I need is a way to get the key of the user, instad of using "llGetOwner()" as I am done testing. In the code posted you never store the user id into the user variable? in your money event before switching to state GoOn store the id of the person who just paid.
|
|
Tiarnalalon Sismondi
Registered User
Join date: 1 Jun 2006
Posts: 402
|
04-10-2007 04:28
Which they mean store it in a global variable. Right now it's only being stored to a local variable when they pay, which is lost once it changes states.
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
04-10-2007 04:54
Well the variable user is already declared, I just dont think it is being updated. What I meant was state PermissionGiven { money(key id, integer amount) { if (amount != price) { llWhisper(0,"Sorry! The price is $" + (string)price); llGiveMoney(id,amount); } else { user = id; state GoOn; } } }
|
|
Stephen Delcon
Registered User
Join date: 16 Feb 2007
Posts: 7
|
04-10-2007 11:07
ah, thank you very much!  I tried using user = llDetectedKey(0);
to get the key, but that didn't work. though the user = id;
did! thx a lot for the help 
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
04-10-2007 13:32
From: Stephen Delcon ah, thank you very much!  I tried using user = llDetectedKey(0);
to get the key, but that didn't work. though the user = id;
did! thx a lot for the help  llDetecteded functions only work in sensor, touch and collision events
|