Jump to content

[Script help] Click an object to pop up a menu for purchase by name.


HisaDrug
 Share

You are about to reply to a thread that has been inactive for 4248 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Yesterday my mate helped me out get a hold of a clickable script that allows me to put an object on sale for 4 separate objects in the menu, which is pretty common vendor for inworld shop. However, I'd like to have them by separate names, not  by price. Anyone can help me for this, id be muchly appreciated for this. Thank you !!

Link to comment
Share on other sites

Innula's right.  Unless you plan on writing the LSL script yourself and need some help in doing it, please do not repost this in the LSL Scripting forum.  Your best bet is to look in Marketplace or post a note in the Wanted forum to see if anyone has a script that does what you want.  If you are a little more adventurous and know enough about scripting to know what you are doing with it, you can also look among the various script libraries here in the forums, in the Second Life wiki, or on the Internet.  It may be easiest, though, to simply  hire a scripter to write what you want.  It's not a terribly hard script to write, so you should get quick responses.  Post your request in the InWorld Employment forum. 

Link to comment
Share on other sites

Yeah this is wot Im talking about ! haha my scriptting is this.

 

integer price1 = 100;

integer price2 = 200;

integer price3 = 300;

integer price4 = 400;

 

 

default

{

state_entry()

{

 

llSetPayPrice(PAY_HIDE, [PAY_HIDE ,PAY_HIDE, PAY_HIDE, PAY_HIDE]);

llSetPayPrice(PAY_HIDE, [150,PAY_HIDE,PAY_HIDE,PAY_HIDE]);

llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);

key id = llDetectedKey(0);

}

run_time_permissions(integer perm)

{

if(perm & PERMISSION_DEBIT)

state cash;

}

}

 

state cash

{

state_entry()

{

llSetPayPrice(price1, [price1, price2, price3, price4]);

 

}

money(key id, integer amount)

{

if(amount == price1)

{

llInstantMessage(id, "Thank You for Buy Our.:.[*JiHyunChel*].:. Cloth :)");

 

string item = "test111";

llGiveInventory(id, item);

}

else if(amount ==price2)

 

{

llInstantMessage(id, "Thank You for Buy Our.:.[*JiHyunChel*].:. Cloth :)");

string item = "test222";

llGiveInventory(id, item);

}

else if(amount ==price3)

 

{

llInstantMessage(id, "Thank You for Buy Our.:.[*JiHyunChel*].:. Cloth :)");

string item = "test333";

llGiveInventory(id, item);

}

else if(amount ==price4)

 

{

llInstantMessage(id, "Thank You for Buy Our.:.[*JiHyunChel*].:. Cloth :)");

string item = "test444";

llGiveInventory(id, item);

}

else

{

llGiveMoney(id, amount);

llInstantMessage(id, "You paid "+(string)amount+", Which is the Wrong Price, The Price Are: L$"+(string)price1+", L$"+(string)price2+", L$"+(string)price3+", L$"+(string)price4+"Please Check Your Money and Try it again.");

 

 

}

}

}

Link to comment
Share on other sites

This is going to be a lot easier to answer in the scripting tips forum, where we can post code properly. It also raises some interesting questions -- I know how I do it, but I'd be interested to see what other people's approaches are.

 

If you ask about getting it moved, I'll try to help you there. I'll ask for it to be moved too.

Link to comment
Share on other sites

Personally, I'd change the problem to make it a single-prim vendor.  (Yes, I know that's cheating.  I prefer to call it "thinking outside the box." :matte-motes-wink-tongue:)

I'd have the choice of item be made on the scripted prim itself, so the buyer would click a specific area for a specific product, the vendor would visually change to indicate which product was to be bought and the one corresponding pay price would be set in the script.

(There are various ways to detect which choice is made and to effect that visual change--more now that the vendor can be Mesh.)

Link to comment
Share on other sites

While I agree with Qie that a single prim vendor is almost certainly a better way to do this than presenting people with a menu, the basic idea is the same. 

You need to capture the customer's choice of product,  determine the price, and then sell it.     I'd do this by storing the items and prices in a list.   Then when someone touches the item for the first time, give them a menu of items from which to choose.   Store the choice,  look up the price, ask them to confirm their choice and pay for it.

You'll need to run a timer, I think, in case they simply wander off (or crash) and also do something to stop other people using the vendor while someone's trying to buy stuff.   This is a case where I think states would be useful, since that's an easy way to make the vendor touchable at some times and not others, payable at some times and not others, and so on.

So, I would grab the debit permissions in state default and then move to state running when I had them.

In state running I'd grab the uuid of the person who touches the vendor (assuming it's not use) and give them a menu based on the list of contents and prices.  Something like 

 

list products =[	"Cube",10,	"Sphere",20,	"Tube",30,	"Torus",50		];llDialog(user,"Please choose a product",llList2ListStrided(products,0,-1,2),dialog_chan);//list of product names as buttons

 Then in the listen event, I'd do something like

 

	listen(integer channel, string name, key id, string message)	{		if("Yes"==message){			state vending;		}		if("No"==message){			llDialog(user,"Please choose a product",llList2ListStrided(products,0,-1,2),dialog_chan);//list of product names as buttons		}		integer s = llListFindList(products,[message]);		if(~s){			item = llList2String(products,s);			price = llList2Integer(products,(s+1);			llDialog(user,"Do you want to buy a "+item+" at a price of L$"+(string)price,["Yes","No"],dialog_chan);//confirmation message		}	}

 and then in state vending do something like this

 

state vending{	state_entry()	{		llSetClickAction(CLICK_ACTION_PAY);		llSetPayPrice(PAY_HIDE,[price]);		llSetTimerEvent(20.0);		llRegionSayTo(user,0,"Please pay the vendor L$ "+(string)price);	}	money(key giver, integer amount)	{		if(giver==user && amount == price){			llGiveInventory(user,item);			llSetTimerEvent(0.0);			state running;		}		else{			//give refund if paid by the wrong person...		}	}}

 Obviously these are just fragments round which to build your code -- in particular you're going to need timer events to handle cases were the user loses interest part way through the process or crashes or whatever.   You'll also want to return to state default from each state when the owner changes and possibly on_rez too.   Don't forget to set llClickAction(CLICK_ACTION_TOUCH) when you enter state running.   I'd make it ask for permissions on touch in state default, too, in case they're not granted immediately.

But that would be my general approach. 

  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4248 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...