Role Play Community

Creative writing, Latest news, Character stories from the virtual world role-players

LaRPS : Legacies Role Play System » Support » Developer

RP Coin Product Example v0.1

(1 post)
  1. TriJin | May 3, 2011 - 02:00 AM

    This requires "Vendor.LaRPS.API.v.0.25" in the same object as this script.

    Also add your notecard, landmark or prim object into the object, so when the player pays the box with a Coin, it will give that item to the player.


    // :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    // LaRPS example product box. Content purchased by the player paying a set amount of RP Money to this object.
    // :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    integer CostOfThisProduct = 1; // RP Money (coins, kredits, hamsters, etc)
    string NameOfProductToGive = "A Really Great Product";
    // :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    key CurrentUser = NULL_KEY;
    //\\::::::::::::::::::: LaRPS Constants ::::::::::::::::::://\\
    integer LaRPS_InitChan = -99990000;
    integer LaRPS_Event_Balance = -50000000;
    integer LaRPS_Event_BankMoneyRecd = -50000001;
    integer LaRPS_Event_MoneyRecdForOwner = -50000002;
    integer LaRPS_AnnounceObject = -99990001;
    integer LaRPS_AnnounceAsTarget = -99990002;
    integer LaRPS_AnnounceAsTargetNoMenu = -999900021;
    integer LaRPS_RequestBankBalance = -99990003;
    integer LaRPS_BankTakeAmount = -99990004;
    integer LaRPS_DisplayMemory = -99999999;
    //\\::::::::::::::::::::::::::::::::::::::::::::::::::::::://\\
    default
    {
    state_entry()
    {
    // Initialise the object
    llMessageLinked(LINK_THIS, LaRPS_InitChan, "", NULL_KEY);
    llSetText("RP Coin Product Example API\nPay this box a LaRPS coin",<0.95,0.5,0.5>, 1.0);
    }
    on_rez(integer int)
    {
    llResetScript();
    }
    touch_start(integer total_number)
    {
    // Announce this as a valid LaRPS object
    llMessageLinked(LINK_THIS, LaRPS_AnnounceObject, "", NULL_KEY);
    CurrentUser = llDetectedKey(0);
    llSay(0,"/me churns and splutters, \"The cost to buy "+NameOfProductToGive+" is "+(string)CostOfThisProduct+" coins. Exact money please. No refunds are given if you pay too much.\", The machine appears to giggle but you shake your head and realize it's just some internal gears churning due to old age.");
    // So the player can interact with this object
    llMessageLinked(LINK_THIS, LaRPS_AnnounceAsTarget, "", CurrentUser);
    }
    link_message(integer sender, integer num, string msg, key id)
    {
    if(num == LaRPS_Event_Balance)
    {
    llSay(0,"whoops.");
    }
    else
    if(num == LaRPS_Event_MoneyRecdForOwner)
    {
    // At this point, the money has gone to the character owner of this product box. It goes into the object owner Bank balance.
    integer coins = (integer)msg;
    if( coins >= CostOfThisProduct )
    {
    // Money received so give the content. The transaction has already been recorded.
    llDialog(CurrentUser,
    "Thank You for your purchase.", ["You're Welcome"], -1);
    llGiveInventory(CurrentUser, NameOfProductToGive);
    }
    }
    }
    }


Reply

You must log in to post.

 

LaRPS™ :: Legacies Role Play System © TriJin Bade, GemX | software
Second Life®, SL™, are registered trademarks of their respective owners.
The features and the use of LaRPS the Legacies Role Play System is FREE and will always strive to be FREE to all users.
Any amount of donations are certainly appreciated to help keep the service up and running.