Jump to content
Zaine Swords

llSetPayPrice() help.

Recommended Posts

im trying to get my object to set the llSetPayPrice and it just seems to completely ignore it.

[code]

list amount;

 

listen(string chan, string name, key id, string msg)

{

if(llGetSubString(msg, 0, 2) == "pay")

{

amount = (list)llGetSubString(msg, 3, -1);

llSetPayPrice(10, amount);

}

}

[/code]

now its getting all the information from a notecard that's in another prim. the prim reads the notecard, gets the amount then sends the message onto the object that's needing to set the  llSetPayPrice().

Share this post


Link to post
Share on other sites

Well, llSetPayPrice is expecting an integer, but you are giving it a list named amount. Try setting

amount = (integer)llGetSubString(msg,3,-1);

 

Share this post


Link to post
Share on other sites

I set it up a bit differently. I added a few lines of code to use integers instead of a list

integer payment1;integer payment2;integer payment3;integer payment4;listen(integer chan, string name, key id, string msg){if(llGetSubString(msg,0,7)=="Payment1")      {           payment1=(integer)llGetSubString(msg,8,-1);           Debug("payment1",(string)payment1);       }      elseif(llGetSubString(msg, 0, 7)=="Payment2")       {payment2 =(integer)llGetSubString(msg, 8, -1);Debug("payment2", (string)payment2);}elseif(llGetSubString(msg, 0, 7)=="Payment3"){payment3 =(integer)llGetSubString(msg, 8, -1);Debug("payment3", (string)payment3);}elseif(llGetSubString(msg, 0, 7)=="Payment4"){payment4 =(integer)llGetSubString(msg, 8, -1);Debug("payment4", (string)payment4);}llSetPayPrice(0, [payment1, payment2, payment3, payment4]);}

 

 

still doesn't work. :(

Share this post


Link to post
Share on other sites

Looks fine to me.  What happens when you put that code into your main script?  I mean, how does it fail?

Share this post


Link to post
Share on other sites

Maybe I'm misreading what you wrote, but I have been assuming that your four variables payment1, payment2, payment3, and payment4 are all global variables, since you listed them at the top of your snippet ... outside the listen event.  If they are only used in that one event, of course, you should make them local.  Either way, they ought to work if you set them up properly.

Share this post


Link to post
Share on other sites

Here's my test script.  All I added was a state_entry event to set up a listener and a money event to activate the PAY option.  I'm echoing the values of your four variables in a llSay statement as they are provided.  The script works just fine.  It drops all four values correctly into the PAY dialog box and would gladly accept my money if I let it.

integer payment1;integer payment2;integer payment3;integer payment4;default{	state_entry()	{		llListen(14,"","","");	}	listen(integer chan, string name, key id, string msg)	{		if(llGetSubString(msg,0,7)=="Payment1")		{			payment1=(integer)llGetSubString(msg,8,-1);			//    Debug("payment1",(string)payment1);		}		else if(llGetSubString(msg, 0, 7)=="Payment2")		{			payment2 =(integer)llGetSubString(msg, 8, -1);			//    Debug("payment2", (string)payment2);		}		else if(llGetSubString(msg, 0, 7)=="Payment3")		{			payment3 =(integer)llGetSubString(msg, 8, -1);			//    Debug("payment3", (string)payment3);		}		else if(llGetSubString(msg, 0, 7)=="Payment4")		{			payment4 =(integer)llGetSubString(msg, 8, -1);			//    Debug("payment4", (string)payment4);		}		llSay(0, (string)payment1 + "  " + (string) payment2 + "  " + (string)payment3 + "  " + (string)payment4);		llSetPayPrice(PAY_HIDE, [payment1, payment2, payment3, payment4]);	}	money (key id, integer amt)	{	}}

 EDIT:  Cleaned it up a bit.  The lack of indents was bothering my obsessive mind.   :smileyhappy:

 

 

Share this post


Link to post
Share on other sites

yea indentes were bugging me to but it wouldn't let me add them.. anyways I c/p your script in world and tested it.. worked great. put what you put in myt script and it doesn't.. I don't get it.. something wrong with y script??

Share this post


Link to post
Share on other sites


Zaine Swords wrote:

[ ...] I don't get it.. something wrong with y script??

Evidently so.  You'll have to put diagnostic llOwnerSay statements in key spots to figure out what you're doing wrong.  Clearly your basic script works, though.

When you find the problem, you'll give yourself a dope slap on the forehead, I'm sure.  Welcome to the crowd.

Share this post


Link to post
Share on other sites

I have a debug function I created just for debugging problems like this.. everything is working up to that point cause I have Debug all over this script

 

Share this post


Link to post
Share on other sites

The obvious difference between Rolig's code and yours is that she's using else if and what you reproduce uses elseif  -- which wouldn't work since it wouldn't compile.

Share this post


Link to post
Share on other sites


Innula Zenovka wrote:

The obvious difference between Rolig's code and yours is that she's using else if and what you reproduce uses elseif  -- which wouldn't work since it wouldn't compile.

Yes. I discounted that error quickly -- and maybe incorrectly -- as a typo in transcription to the forum because I have been assuming that the OP was dealing with an execution error, not a compilation error. I simply fixed it and moved on to see why he was getting bad numbers. If the script hasn't been compiling, though, that's one obvious reason.  Another possibility, or course, is that the error is in his Debug routine.  I commented out those lines when I tested, opting instead for a straightforward llSay

It's always fascinating to me how many ways even a very short script can go wrong.

Share this post


Link to post
Share on other sites

It probably was a transcription error, I agree.   But that tells me that we're not being show the actual code that's causing the problem, so it's just a guessing game why the actual code isn't working.   It's not even clear how it's not working now.

Share this post


Link to post
Share on other sites

your right, I didn't give you all of the code cause I didn't think it was nessesary.. but since it just might be here it is.

string Text;string ColorPicker;string Logo;integer Chan;integer Amount;integer Total;integer Percent;integer percent;integer OnOff = FALSE;integer payment1;integer payment2;integer payment3;integer payment4;float Size = 6.0;vector Red = <1, 0, 0>;vector Green = <0, 1, 0>;vector Blue = <0, 0, 1>;vector White = <1, 1, 1>;vector Black = <0, 0, 0>;vector Color;key Dancer;key Toucher;integer SetID(key id){    integer mainkey = 921;    string tempkey = llGetSubString((string)id, 0, 7);    integer hex2int = (integer)("0x" + tempkey);    return (hex2int + mainkey);}DisplayText(){    if(OnOff == TRUE)    {        llSetText(llKey2Name(Dancer) + "'s Tip Jar\n" + "\nTipped: " + (string)Amount + "\n Total Amount: " + (string)Total , Color, 1.0);    }    else if(OnOff == FALSE)    {        llSetText("", <1,1,1>, 1.0);    }}Resize(){    float scale;    list primparams;    scale = Size;    primparams = [];    if(OnOff == TRUE)    {        primparams += [PRIM_SIZE, llGetScale() / scale];        if(llGetLinkNumber() > 0)        {            primparams += [ PRIM_POSITION, llGetLocalPos() / scale];        }    }    else if(OnOff == FALSE)    {        primparams += [PRIM_SIZE, llGetScale() * scale];        if(llGetLinkNumber() > 0)        {            primparams += [ PRIM_POSITION, llGetLocalPos() * scale];        }    }    llSetPrimitiveParams(primparams);}Debug(string msg, string var){    integer DEBUG = FALSE;    if(DEBUG == TRUE)    {        llSay(0, "DEBUG: " + msg + ":" + var);    }}default{    state_entry()    {        Chan = SetID(llGetOwner());        Debug("state", "default");        llListen(Chan, "", NULL_KEY, "");        llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);        DisplayText();    }    run_time_permissions(integer perm)    {        if(perm & PERMISSION_DEBIT)        {        }        else        {            llOwnerSay("Please grant the permissions to continue.....");            llResetScript();        }    }    changed(integer change)    {        if(change & CHANGED_OWNER)        {            llResetScript();        }    }    listen(integer chan, string name, key id, string msg)    {        //Debug("msg", msg);        if(llGetSubString(msg, 0, 4) == "Color")        {            ColorPicker = llGetSubString(msg, 6, -1);            Debug("ColorPicker", llGetSubString(msg, 6, -1));            if(ColorPicker == "white")            {                Color = White;            }            else if(ColorPicker == "red")            {                Color = Red;                Debug("msg = red", "Color is red");            }            else if(ColorPicker == "blue")            {                Color = Blue;            }            else if(ColorPicker == "black")            {                Color = Black;            }            else if(ColorPicker == "green")            {                Color = Green;            }            Debug("color", (string)Color);        }        else if(llGetSubString(msg, 0, 13) == "Dancer Percent")        {            percent = (integer)llGetSubString(msg, 15, -1);            Debug("percentage is", (string)percent);        }        else if(llGetSubString(msg, 0, 7) == "Payment1")        {            payment1 = (integer)llGetSubString(msg, 8, -1);            Debug("payment1", (string)payment1);        }        else if(llGetSubString(msg, 0, 7) == "Payment2")        {            payment2 = (integer)llGetSubString(msg, 8, -1);            Debug("payment2", (string)payment2);        }        else if(llGetSubString(msg, 0, 7) == "Payment3")        {            payment3 = (integer)llGetSubString(msg, 8, -1);            Debug("payment3", (string)payment3);        }        else if(llGetSubString(msg, 0, 7) == "Payment4")        {            payment4 = (integer)llGetSubString(msg, 8, -1);            Debug("payment4", (string)payment4);        }        //llSay(0, (string)payment1 + "  " + (string) payment2 + "  " + (string)payment3 + "  " + (string)payment4);        DisplayText();        llSetPayPrice(PAY_HIDE, [payment1, payment2, payment3, payment4]);        Debug("PayPrice", "Set");    }    link_message(integer sender_number, integer number, string message, key id)    {        Debug("message id", message + (string)id);        if(OnOff == FALSE)        {            if(message == "LOGGEDIN")            {                Resize();                OnOff = TRUE;            }        }        else if(OnOff == TRUE)        {            if(message == "LOGGEDOUT")            {                Resize();                OnOff = FALSE;                Total = 0;                Amount = 0;            }        }        if(message == "Dancer")        {            Toucher = id;            Dancer = Toucher;            Debug("Dancer is", (string)Dancer);        }        else if(message == "TIPPING")        {            Debug("TipJar", "TIPPING");        }        DisplayText();    }    money(key giver, integer amount)    {        llGiveMoney(Dancer, amount * percent / 100);        llRegionSay(Chan, "tipper" + (string)giver);        llInstantMessage(giver, "Thank you for that wonderful tip " +llKey2Name(giver));        llSay(0, llKey2Name(giver) + " tipped " + llKey2Name(Dancer) + " L$" + (string)amount + ".");        Amount = amount;        Total += amount;        DisplayText();    }}

 

Share this post


Link to post
Share on other sites

I've just tested your script and it's working fine for me in world (I added llListen(5,"",llGetOwner(),"") and used that rather than mess around reading cards).

It does want a message exactly in the form Payment125, so it might be an idea to turn everything to lower (or upper) case and to do llStringTrim(string, STRING_TRIM) on all the elements.   It's going to get confused, for example, by Payment1 25.

When I'm working with this sort of thing, I find it safest to send strings with separators,  and then say something like 

	listen(integer channel, string name, key id, string message)	{		list temp = llParseString2List(message,["|"],[]);		string string1 = llToLower(llStringTrim(llList2String(temp,0),STRING_TRIM));		string string2 = llToLower(llStringTrim(llList2String(temp,1),STRING_TRIM));	}

 But certainly, your code works if it gets the messages in the format it expects.   So I would look closely at what you're actually sending it.

Share this post


Link to post
Share on other sites

if you look at my Debug pieces, it goes through each line and sends me a message at the appropriate time. and the Debug is telling me that it is adding the prices correctly. so each variable is getting the right information its just the llSetPayPrice() is not registering that it has any new prices..

 

Share this post


Link to post
Share on other sites

Just for the heck of it (and because it's a smart thing to do anyway), try adding this tiny test each time you get a value of one of your "payment" variables:

    if ( (string) ( (integer) data) == data)        llOwnerSay("'" + data + "' contains a valid integer");

 where "data" is the "payment" variable you are testing in each case.  My guess is that your Debug function is only appearing to tell you the truth because you asked it to tell you the (string) equivalent of whatever is in those variables.  If you are passing something that is not an integer, it's value will be set to zero even though its string equivalent looks like a number.

Once you find what's screwy, the way to beat it is to be sure that you use llStringTrim to get rid of blanks spaces around the values you are passing and then use that little NAN function to double check and be sure that what's left really is an integer.

 

Share this post


Link to post
Share on other sites

I get the prices that I add, as I add them.   Here's a picture of what I've just done.   The only difference between my code and yours is that I'm saying Payment150 and so on on channel 5.

 

Capture.JPG

Share this post


Link to post
Share on other sites

i still havnt been able to figure out this problem. i even tried just taking out everything i have done i just putting in llSetPayPrice(PAY_DEFAULT, [20, 50, 150, 200]); and it still doesn't work so i am at a loss as to what the problem is.

Share this post


Link to post
Share on other sites

How strange.  Sometimes with bizarre problems like this, I've found it best just to delete the uncooperative object and start again, with new prims and a new script (copy pasted from a back-up in Notepad if I'm sure about the script) on a new sim.

That often fixes whatever it is.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...