Jump to content

pay to play game script


SLGTeam
 Share

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

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

Recommended Posts

Use one state with a money event .

When the player has paid ,  save his key, and go to an another state. The player can start to play in the another state.

After the game , or a timeout because the player has left , go back to the state default , to listen other players ( or the same player with a new game)

 

key player;integer priceToPlay = 5;default{    state_entry()    {        llSetClickAction(CLICK_ACTION_PAY);        llSetPayPrice(PAY_HIDE, [ priceToPlay ,PAY_HIDE,PAY_HIDE,PAY_HIDE]);    }    money(key id, integer amount)       {        if ( amount >= priceToPlay )        {            player = id; state playing;        }            }}state playing{// your game starts here}

 

Link to comment
Share on other sites

thanks alot for the script!
i've built a script of my own which divides the money payed between two people, it works perfectly.
only problem is when i try to link it with other parts of my project (when the object with the payment script isn't chosen last) it wont let me pay the set amount, instead it asks how much would i like to pay.
even if i set the right amount it gives me problems..

here is a screenshot of the screen received
also here is the code i wrote

 

error.JPG

integer  percentage=50;
key player;
integer priceToPlay = 2;
key dudu = "791a6a83-0c8f-4b8f-bb7c-a03c64eff29c";
key eran= "7d9de5a1-0a60-4101-8fbf-6cfbcdf87b59";//"6f9118fa-504b-447d-bb14-02edfaae8a24";
default
{
    state_entry()
    {
        llSetClickAction(CLICK_ACTION_PAY);
        llSetPayPrice(PAY_HIDE, [ priceToPlay ,PAY_HIDE,PAY_HIDE,PAY_HIDE]);
         llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);
    }

    money(key id, integer amount)   
    {
        if ( amount >= priceToPlay )
        {
            llGiveMoney(eran, llRound(amount * (float)(percentage/100.0)));
     llGiveMoney(dudu, llRound(amount * (float)(percentage/100.0)));
            player = id;
        key id = llDetectedKey(0);
        string name = llKey2Name(id);
 
        string detectedName = llDetectedName(0);
        llSay (-5, "start");
         llSay (-5, name);
          
        
        state default;
        }
        
    }
}



any help would appreciated
thanks

Link to comment
Share on other sites

Right.  See the wiki article for llSetPayPrice:

This function only works when called from the root prim of an object. Its effect applies to all the prims in the object. Calling it from a child prim has no effect.

The money() event can be scripted in a child prim, but llSetPayPrice must be executed in the root. (It appears that it's setting a prim property or something similar, in that it's reported to persist even after the setting script is removed.)

I'm not sure why this is a problem in this application, so maybe more details are needed.

Link to comment
Share on other sites

thanks i think i partly understand what was my problem.

when i try to sell an item or a service i must give a menu with a choise to the user to choose how much he wants to pay and then check if it matches ( like the screenshot i uploaded before)? or is there a way to just show him the amount of linden and he will press accpet or something?


in my particular script im detecting the key and name of the user pressing the object with the commands:

key id = llDetectedKey(0);
string name = llKey2Name(id);

but in this case if he presses the buy option it doesnt detect any key so i get an empy string

is there any way around it?

maybe a command that calls the selling menu without the avatar needing to press the buy option?

hope you understand what i ment ^^

Link to comment
Share on other sites

I guess I still don't understand the problem, exactly.

Take two prims and link them together. In the root prim (the last one selected when linking), add this script:

default{    state_entry()    {        llSetPayPrice(PAY_HIDE, [ 50 ,PAY_HIDE,PAY_HIDE,PAY_HIDE]);    }}

 In the other, child prim, add this script:

default{    money(key id, integer amount)    {        llOwnerSay(llKey2Name(id)+" paid me L$"+(string)amount);    }    /*    This next part is optional, just making it easier to get to "Pay"    without having to right-click the object.    */    state_entry()    {        llSetClickAction(CLICK_ACTION_PAY);    }}

Now, when clicking to pay the child prim, it will use the pay price that was set in the root. I'm unclear how this differs from what you want.

Link to comment
Share on other sites

llDetectedKey : in this page , in the "specification" paragraph

 

llDetected* functions only work if called from within Detection events
(collision, collision_start, collision_end, sensor, touch, touch_start, touch_end)
or in functions called by Detection events.
They will fail silently and return unusable values if called during other events.

 


That s why in your script you dont receive anything in your lines of your script :

        key id = llDetectedKey(0);        string name = llKey2Name(id);         string detectedName = llDetectedName(0);

 

 

In fact inside the money event , the key in parameter of the event contains already

the key of someone who has payed the object.

 

money(key id, integer amount)  
{
string name = llKey2name(id)
}

 

Link to comment
Share on other sites

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