Jump to content

llSetPayPrice() help.


Zaine Swords
 Share

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

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

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().

Link to comment
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. :(

Link to comment
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.

Link to comment
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:

 

 

Link to comment
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.

Link to comment
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.

Link to comment
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();    }}

 

Link to comment
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.

Link to comment
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..

 

Link to comment
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.

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4033 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...