|
Tomfox Wiranata
Registered User
Join date: 20 Dec 2006
Posts: 80
|
01-02-2007 13:59
hi everybody. when someone touches my object a dialog box pops up. the problem: if two residents touches it the same time, they can see the information from each other. i tried to make a channel from each persons name, so everybody has his own channel. but it doesn't work. list letters = [" ","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
integer ChannelFromName() { integer x; integer length; integer channel; string owner = llToLower(llKey2Name(llDetectedName(0))); for(x=0, length=llStringLength(owner); x<length; ++x) { channel+=llListFindList(letters,[llGetSubString(owner,x,x)]); } return channel; } default {
state_entry() {
}
touch_start(integer total_number) { integer ch = ChannelFromName(); llListen(ch,"",NULL_KEY,""); //init(); //string name = llDetectedName(0); //playername = name; llDialog(llDetectedKey(0), "Choose your Numbers", PC__01_11, ch); }//touch
listen(integer channel, string name, key id, string message) { //Channel = 0; //init(); integer ch = ChannelFromName();
if(message == "12-21 >>>") llDialog(id,"ff",PC__12_21,ch);
if(message == "<<< 01-11") llDialog(id,"dd",PC__01_11,ch); if(message == "22-31 >>>") llDialog(id,"dd",PC__22_31,ch); if(message == "<<< 12-21") llDialog(id,"dd",PC__12_21,ch); if(message == "32-41 >>>") llDialog(id,"dd",PC__32_41,ch); if(message == "<<< 22-31") llDialog(id,"dd",PC__22_31,ch); if(message == "42-45 >>>") llDialog(id,"dd",PC__42_45,ch); if(message == "<<< 32-41") llDialog(id,"dd",PC__32_41,ch);
etc. etc.
maybe you can help me... thx so much 
|
|
DisQ Hern
Registered User
Join date: 25 Aug 2006
Posts: 58
|
01-02-2007 15:09
Make a variable set to 1 when someone touches the prim.
When it is set to 1 amessage is displayed: "Sorry object is in use" Or seomthing like that.
When it is 0 your script comes into play.
_____________________
The Isle of DisQ
http://slurl.com/secondlife/Isle%20of%20DisQ/60/20/21/
Gadgets (Polygon creator, Inventory sorter, ScripterAid and more) Textures (SL's finest.) Land rental (4096 sq.m. plots for rent)
DisQ Hern
|
|
Tomfox Wiranata
Registered User
Join date: 20 Dec 2006
Posts: 80
|
01-02-2007 15:19
ok. can u help me out with example code ?
|
|
GC Continental
Registered User
Join date: 8 Aug 2006
Posts: 17
|
01-02-2007 17:56
I like to use a random channel  list avkeys; list channels; touch(integer total_number){ int index; for(index = 0; index <= total_number; index++){ // first two million channels free! channels += -llFrand(2000000); avkeys += llDetectedKey(index); } } Of course, all this here really does is make two lists, one with an av key and another with a corresponding channel. It's rudimentary, and this example doesn't do anything other than suck memory (I didn't include a function for cleaning the lists out over time), but you can be be sure one person's channel doesn't match another's, and if you want to get one av's channel later, all you have to do is reference the the same index in both lists, i.e.: Bob's key is in avkey[5]... ... so his channel is in channels[5] The "for" loop is just because people tend to click on things in groups, much like they go to the bathroom in groups. Walk around in a public area brandishing an Xcite "unit" for proof.
|
|
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
|
01-03-2007 11:38
From: Tomfox Wiranata when someone touches my object a dialog box pops up. the problem: if two residents touches it the same time, they can see the information from each other. ...just out of morbid curiosity, you... //Channel = 0; ...weren't using channel 0 at some point? Everyone is going to see anything on Channel 0 as it's the open chat channel. That is to say that a Dialog responding on channel 0 will echo its reply in open chat even if it's 'keyed' to a specific Agent (avatar). Maybe I'm missing something but, in principle, I don't see anything wrong with your script's logic. llDialog is issued to llDetectedKey(0), the llListen listens to everyone (NULL_KEY), and the listen reissues the llDialog to the Agent according to the key id. Therefore, using anything other than channel 0 should work fine. Unless you also implement llListenRemove (including Dialog timeouts), switching channels is ultimately doomed because eventually you will get a "Too many listens" error. I would, however, suggest you use an 'exotic' channel (a negative channel), and preferably one with a lot of digits. This simply makes the job of a third party script scaning the communications of the Dialog very difficult. One caveat. If many Agents click the object very close to each other, llDetectedKey(0) will always pick the first Agent to click. I've never seen a coded solution to this situation (and have never had cause to investigate it) but I guess a loop on 0 through total_number would address this eventuality. Something like... for (x = 0; x < total_number; x++) { llDialog(llDetectedKey(x), "Choose your Numbers", PC__01_11, ch); } Or have I lost the plot here? 
|
|
Tomfox Wiranata
Registered User
Join date: 20 Dec 2006
Posts: 80
|
01-03-2007 14:31
thx everybody... got it. i just made it impossible that 2 resident work with my object the same time  wish u all a nice day
|
|
Cyberboy Longcloth
Registered User
Join date: 17 Nov 2006
Posts: 1
|
01-04-2007 02:16
May I also suggest checking the list to see if the avatars name is already in the list. That way you won't get two channels assigned to the same AV if they click it more than once.
// Checks to see AV is on list integer isOccupant( string strName ) { integer len = llGetListLength( lstOccupant ); integer i; for( i = 0; i < len; i++ ) { if( llList2String(lstOccupant, i) == strName ) { return TRUE; } } return FALSE; }
You would call this Function and pass it the Avatar's Name. It will return True or False. If true than don't add the avatar to list. If False - add the avatar to list.
|
|
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
|
01-04-2007 05:18
The other way would be to use multiple scripts that are 'brokered' by a master script ina similar manner to how the majority of dance machines work.
|