Jump to content

Recommended Posts

Hey scripting gurus, I have a question; 

We all know it’s possible for an agent to pay an object to be delivered an item (see every vendor script ever), but is it possible to have an agent give an item to an object and receive payment? 

Ie: Turn in 10 rocks to this Panel and receive 1 linden. 

If so - does anyone know how I would script that? It’s out of my league 

Link to post
Share on other sites
changed (integer change)
{
    if (change & CHANGED_INVENTORY)
    {
        integer iNumRocks;
        integer i;
        while ( i < llGetInventoryNumber(INVENTORY_OBJECT))
        {
            string name = llToLower(llGetInventoryName(INVENTORY_OBJECT,i));
             if ( ~llSubStringIndex(name, "rock") )
            {
                ++iNumRocks;
                if ( iNumRocks%10 == 0 )  // Every time iNumRocks is a multiple of ten
                {
                    llGiveMoney(kAv, 1);
                }
            }
            ++i;
        }
    }
}

Rather silly, but that's the general idea of how you might write a changed event to keep track as kAv adds rocks to the object. Put that into a state that is only accessible  to avatar kAv, and then remove all the rocks when he has left or has stopped dumping rocks in.  Then all you have to do is figure out the rest of the script.  😉 

Edit:  Yes, I know I left out all the really interesting part in which you figure out who kAv is, how to keep other people from dropping rocks in, how to identify fake rocks, and where to get the L$1 from each time to have to pay for the rocks.  That's your part.

Edited by Rolig Loon
  • Like 1
  • Thanks 1
Link to post
Share on other sites

Is there a different way you would handle it Lucia? I’m trying to make it a quest turn in system like when you do a gathering quest in an MMO (“bring me 10 of this item and get a reward”). 

 

 

 

Link to post
Share on other sites

The problem is to identify objects. While in an object inventory there is not much you can check.

I make 1 cube and name it "rock" and feed it 100 times to your machine. What you pay per "rock" ?

You need to add a code to the objects name and make sure that it can only used once.

 

Link to post
Share on other sites
2 hours ago, Mowri Panache said:

Is there a different way you would handle it Lucia? I’m trying to make it a quest turn in system like when you do a gathering quest in an MMO (“bring me 10 of this item and get a reward”). 

Incidentally, this is exactly what Linden Realms has, which is something created by LL with basic LSL features. https://secondlife.com/destination/paleoquest

Objects can pay people with llGiveMoney or llTransferLindenDollars, but as the others sort of warned you, "little mistakes" or vulnerabilities in your script can turn out costly. If people are able to turn in fake items for example, they can drain you dry. I would at least recommend that the "turn-in vendor" is owned by an alt specifically created for that purpose, which you'll periodically transfer money to. This way, if someone manages to exploit the system, you won't lose all of your money.

I would also recommend that you go look at PaleoQuest and take some notes. Using a HUD to keep track of the collectibles is much safer (and convenient) than actual inventory items.

Edited by Wulfie Reanimator
  • Like 2
Link to post
Share on other sites

As others pointed out, there are not many safeguards that you can build into your script.

Let's just forget about the money part for a moment (after all, what nobody seemed to have considered is that the money in question may not be actual L$ but could be your own coin system for this quest game) and just look at how to check if the object which was dropped into the "vendor" is genuine.

You can obviously use llGetInventoryName() and pair it with llGetInventoryType() to make sure that the item dropped is not a texture or a notecard or whatever, but this can still be easily spoofed by just creating a prim and call it whatever it is supposed to be called (like "rock").
You could add an additional check in the form of llGetInventoryCreator() to verify that the prim called "rock" is indeed made by you but as far of checking inventory items go, this is really all you can do.

As Wulfie mentioned, a HUD system is safer and more convenient but may not offer the immersion that you seek. A HUD-based collection system does not have the vulnerabilities of the inventory drop system that many people have pointed out.

 

  • Like 1
Link to post
Share on other sites
8 minutes ago, Fritigern Gothly said:

Let's just forget about the money part for a moment (after all, what nobody seemed to have considered is that the money in question may not be actual L$ but could be your own coin system for this quest game)

OP said "Turn in 10 rocks to this Panel and receive 1 linden." If the payment wouldn't have needed to be in linden, I don't think the question/example would've been worded like this. Maybe he'll clarify. 

And while checking inventory type/name/creator can be done, you'd have to be sure you've haven't made anything full-perm (or even mod/trans) publicly available. (I know you know this, Frit, I'm just clarifying.)

Edited by Wulfie Reanimator
  • Like 1
Link to post
Share on other sites

what Wulfie said is the safest way to do it. The Linden Realms way

this said, there is a way, but is messy

1) make a rock which is no-copy no-modify

2) when the person drops the rock in the Panel then the Panel rezzes the rock inworld

3) on rock rez, the Panel reads the rock's: OBJECT_NAME, OBJECT_CREATOR, OBJECT_CREATION_TIME and OBJECT_DESC. Uses these to validate the rock. OBJECT_DESC will contain a Unique Number which is passed from the Rock Rezzer when the rock is rezzed on the gameplay arena

5) after being read/validated, the rock then deletes itself

the Unique Number helps because there is a exploit that can duplicate no-copy no-modify objects. The Panel (game server) can know when a Unique Number has been issued and will discard/ignore any rock with a Unique Number that has already been presented. Treat the second presentation as a counterfeit and reject it

is pretty messy tho as I mention, but is doable

  • Like 1
Link to post
Share on other sites

Can you verify the item dropped into the panel is safe to rez in world?  I would not rez just anything transferred into my ownership.  That can get ugly fast.  Maybe try letting the bearer of the item rez it on a small parcel then inspect the resulting object.  The parcel can be decorated to suit your needs and auto return could be used to clean it of debris.  Use an object no entry perimeter and auto return, if needed, to protect the rest of the area.  Also, I suspect there is a function to selectively return objects.  The object of interest can be scripted to transform or delete themselves after receiving  a message from the script doing the accounting.

  • Like 2
Link to post
Share on other sites
5 minutes ago, Ardy Lay said:

Maybe try letting the bearer of the item rez it on a small parcel then inspect the resulting object.  The parcel can be decorated to suit your needs and auto return could be used to clean it of debris.  Use an object no entry perimeter and auto return, if needed, to protect the rest of the area.  Also, I suspect there is a function to selectively return objects.  The object of interest can be scripted to transform or delete themselves after receiving  a message from the script doing the accounting.

i like this idea

like there is a rock.  Player bumps the rock. The rock temp attaches to player with appropriate lifting animation.  Player carries the rock to the basket.  Sits on the basket. Game then does the validation and rock detach/delete.  Player then goes and finds another rock

  • Like 1
Link to post
Share on other sites

Or again, doing it the PaleoQuest way.

The collectibles are permanently rezzed inworld by the game host. (Either statically, or in some set location.) They periodically become visible (change alpha and/or move into their intended location) and actually "collectable." When a player bumps into one, it can play an effect, hide itself, and communicate with the game HUD.

Turning them in can be done simply by walking near the turn-in point. You can use collisions again to activate the vendor just like the collectibles. 

  • Thanks 1
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...