Give Object And Play Sound

Written by: Headmaster
// This script will give out a object from Inventory and play sound file when click on.
 
string object_name = "object";
integer i;
 
default
{
    state_entry()
    {
        llPreloadSound(llGetInventoryName(INVENTORY_SOUND, 0));
 
    }
     touch_start(integer total_number)
    {
         integer i;
        key giver;
        // add a wave that is name sound.wav
        llPlaySound("pour", 1.0);
        giver = llDetectedKey(0);
        string name = llDetectedName(0);
        if (giver != NULL_KEY)
        {
            llGiveInventory(giver, object_name);
        }
 }
}

 

Category: