|
woofbag Fudo
Registered User
Join date: 3 Aug 2006
Posts: 31
|
09-03-2007 18:25
I adjusted a script someone gave me to fit my needs for a server and a vendor. They both save correctly, but for some reason it's really only worked once. I pay the vendor the 2L, and then I automatically pay myself 1L (I had it made so i could sell the vendors and get 1L of every soda sold), but then it doesnt hand out the soda. Why?? Here's the script that goes into the vending machine: //This half the the setup is dead simple, it just sends the key of the person that touched the prim this script is in off to the server, which then distributes the items inside it. integer giPrice = 2; string gTargetKey = "10f76b21-e37b-08b1-ae60-d39072955c2a"; // Update this with the UUID of your server prim. //string gTargetKey = "b041bc00-3d6a-41f7-f65d-81aa36093fca"; //uncomment out this line to see how it should work if you're having trouble with your own. init() { integer i; llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);; }
default { state_entry() { init(); llSetTimerEvent(1); } run_time_permissions(integer perm) { if(perm && PERMISSION_DEBIT) { llWhisper(0,"Permissions Accepted. Ready to Vend."); } else { llWhisper(0, "Permissions NOT Accepted. YOU MUST ACCEPT! Resetting..."); llResetScript(); } } money(key id, integer amount) { if(amount == giPrice) { llWhisper(0, "Sending Soda From the Machine. Accept the Inventory Offer " + llKey2Name(id) + "."); llGiveMoney(llGetCreator(),1); llEmail(gTargetKey + "@lsl.secondlife.com", llDetectedKey(0), ""); } else { llInstantMessage(id, "That is not the right amount of L$ " + (string)giPrice + " to buy a soda."); if(amount > 0) { llInstantMessage(id, "Not Accepting"); llGiveMoney(id, amount); } } } }
And here's the script that goes into the server. // Distributed item giver (I made it to use with my store landmarks, since I kept having to update multiple vendors) // You do not need to change anything in this script, just put your items in the server prim that you want handed out when the "giver" prim is touched. // // NOTE: THE UUID OF THE SERVER MUST NEVER CHANGE! If it does you'll need to update ALL the child scripts. This means you can NEVER pickup the server prim. // A simple way to move the server is to right-click the prim, and select "wear", "right hand", // proceed to teleport or fly to your new location, right-click the prim again and select "DROP", // (NOT DETACH! if you detach it will move into your inventory and the unique UUID will be lost) // // Lasivian Leandros
string gServerKey = ""; list inventory_types = [INVENTORY_BODYPART,INVENTORY_CLOTHING,INVENTORY_LANDMARK,INVENTORY_NOTECARD,INVENTORY_OBJECT,INVENTORY_SCRIPT,INVENTORY_SOUND,INVENTORY_TEXTURE]; integer j; integer k; integer type; integer typecount; string objectname;
default { on_rez(integer i) { llResetScript(); }
state_entry() { gServerKey = llGetKey(); llSetObjectDesc(gServerKey); llSetTimerEvent(2.5); // I would not speed this up beyond one e-mail check per 2.5 seconds, it's laggy enough as it is. }
touch_start(integer total_number) { gServerKey = llGetKey(); llInstantMessage(llDetectedKey(0), "Update Server Key is: " + gServerKey); } email(string time, string address, string subj, string message, integer num_left) { key target = subj; // This allows you to test the system without getting all the junk it's setup to give ouy if (target == llGetOwner()) { llOwnerSay("Touch received on a client prim from you."); }
integer total_number = 1; integer i; for (i=0;i<total_number;i++) { integer inventory_count = llGetListLength(inventory_types); string myname = llGetScriptName(); for (j=0; j<inventory_count;j++) { type = llList2Integer(inventory_types,j); // get the next inventory type from the list typecount = llGetInventoryNumber(type); // how many of that kind of inventory is in the box? if (typecount > 0) { for (k=0; k<typecount;k++) { objectname = llGetInventoryName(type,k); if (objectname != myname) // don't give self out so the user doesn't get fifty thousand copies. { llGiveInventory(target,objectname); } } } } } }
timer() { llGetNextEmail("", ""); // check for email with any subject/sender } }
And I know I have everything set up with the server correctly, when I sue the original vendor script it works fine. here it is. //This half the the setup is dead simple, it just sends the key of the person that touched the prim this script is in off to the server, which then distributes the items inside it.
string gTargetKey = "10f76b21-e37b-08b1-ae60-d39072955c2a"; // Update this with the UUID of your server prim. //string gTargetKey = "b041bc00-3d6a-41f7-f65d-81aa36093fca"; //uncomment out this line to see how it should work if you're having trouble with your own.
default { touch_start(integer total_number) { llEmail(gTargetKey + "@lsl.secondlife.com", llDetectedKey(0), ""); } }
Can anyone help??
|
|
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
|
09-03-2007 22:22
May be other things broken, but one thing is surely not gonna work: in the Vending Machine's money() event handler, it calls: llEmail(gTargetKey + "@lsl.secondlife.com", llDetectedKey(0), ""  ; but llDetectedKey() is undefined in a money() event. Not hard to fix in this case because the payer's key is bound to the "id" variable in that handler.
|
|
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
|
09-03-2007 23:23
Whenever you rez an object it gets a new UUID key.
So the delivery server will eventually have to have a way to inform the vending machines of such a change. Since it cannot possibly know all vendor locations or keys....
I would suggest you have the server submit its key to a defined web url / website and the vendors can then check that website on a regular basis (usually when someone makes a purchase) to get the current UUID key of the delivery server.
|
|
woofbag Fudo
Registered User
Join date: 3 Aug 2006
Posts: 31
|
09-04-2007 02:12
From: Squirrel Wood Whenever you rez an object it gets a new UUID key.
So the delivery server will eventually have to have a way to inform the vending machines of such a change. Since it cannot possibly know all vendor locations or keys....
I would suggest you have the server submit its key to a defined web url / website and the vendors can then check that website on a regular basis (usually when someone makes a purchase) to get the current UUID key of the delivery server. Too bad I barely know how to script and can't get even get this to work in the first place 
|
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
09-04-2007 03:41
From: woofbag Fudo Too bad I barely know how to script and can't get even get this to work in the first place  You really do need to contact the person who scripted your vendor scripts the first time or place an ad in products wanted. There is nothing wrong with learning to script and it is great fun, but unfortunately these two scripts aren't a good place to begin learning. You need to learn the basics, the language and the concepts first with very simple little scripts first. What you are asking for and what you need done are not going to cost very much money. You will have the added benefit of having a couple of scripts which have been optimized and won't be stealing precious simulator resources. There is a lot of nasty code that people have let loose into SL and continue to do so on a daily basis. It is alright to learn and make mistakes. But wouldn't it be fair to say that you really have no desire to learn scripting and just want these two scripts to work?
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
|
woofbag Fudo
Registered User
Join date: 3 Aug 2006
Posts: 31
|
09-04-2007 04:01
From: Qie Niangao Not hard to fix in this case because the payer's key is bound to the "id" variable in that handler. Lol, I just tried replacing llDetectedKey(0) with id, and it worked! Thanks! From: Jesse Barnett But wouldn't it be fair to say that you really have no desire to learn scripting and just want these two scripts to work? You're half right. I do want these scripts to work, and I also REALLY want to learn how to script. You think I like having to turn to other people every time I have a simple problem I can't figure out, and if no ones available, I just have to wait until someone is? In this particular scripts case, I didn't know that llDetectedKey(0) is undefined in a money event, but id, which is relatively the same thing, is. How much you want to bet I'll need this knowledge repeatedly in the future? And it's not like I asked for a whole script to be converted, I changed the original script (the third posted script) to the one that requires payment first (the first posted script) by myself, through what I've learned thus far in scripting.
|