OsAddAgentToGroup

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
m (Change 0 to PUBLIC_CHANNEL)
Line 23: Line 23:
 
     }
 
     }
 
}
 
}
 +
</source>
 +
|ossl_example=<source lang="lsl">
 +
//
 +
// osAddAgentToGroup Script Example
 +
//
 +
 +
// Define the group and role to which avatars will be added.
 +
string GroupToJoin = "Test Group";
 +
string RoleToJoin = "Everyone";
 +
 +
default
 +
{
 +
    // This event is triggered when the script is initialized.
 +
    state_entry()
 +
    {
 +
        // Send a message in public chat to inform users about the script's functionality.
 +
        llSay(PUBLIC_CHANNEL, "Touch to use osAddAgentToGroup to add yourself to a group.");
 +
    }
 +
 +
    // This event is triggered when an avatar touches the object containing the script.
 +
    touch_end(integer num)
 +
    {
 +
        // Get the unique identifier (key) of the avatar who touched the object.
 +
        key AgentID = llDetectedKey(0);
 +
 +
        // Use the osAddAgentToGroup function to add the avatar to a specified group and role.
 +
        // This allows the avatar to join the group and take on the specified role.
 +
        osAddAgentToGroup(AgentID, GroupToJoin, RoleToJoin);
 +
    }
 +
}
 +
 
</source>
 
</source>
 
|description=Prerequisites  
 
|description=Prerequisites  
Line 28: Line 59:
 
* You must have the Group UUID
 
* You must have the Group UUID
 
* Roles within the group must be defined (default has Everyone & Owners)
 
* Roles within the group must be defined (default has Everyone & Owners)
 +
 +
Script Description:
 +
 +
    Script Name: N/A (This script doesn't have a specific name, but it's used as an example for adding avatars to a group in a virtual world.)
 +
 +
    Description: This script is intended for use in a virtual world environment and demonstrates how to add avatars to a designated group with a specified role when they touch an object containing the script.
 +
 +
Events and Functionality:
 +
 +
    state_entry() Event:
 +
        This event is triggered when the script is initialized.
 +
        In this event, the script uses llSay to send a message in the public chat channel (PUBLIC_CHANNEL). The message informs users that they can touch the object to use the osAddAgentToGroup function to add themselves to a group.
 +
 +
    touch_end(integer num) Event:
 +
        This event is triggered when an avatar touches the object containing the script.
 +
        It retrieves the unique identifier (key) of the avatar who touched the object using llDetectedKey(0).
 +
 +
    Adding an Avatar to a Group:
 +
        Inside the touch_end event, the script uses the osAddAgentToGroup function to add the avatar (identified by AgentID) to the specified group (GroupToJoin) and assigns them the specified role (RoleToJoin).
 +
        This function effectively adds the avatar to the group and grants them the specified role within that group.
 
|
 
|
 
}}
 
}}

Revision as of 08:55, 29 September 2023

osAddAgentToGroup(key AgentID, string GroupName, string RequestedRole)
Prerequisites
  • The Group must be created
  • You must have the Group UUID
  • Roles within the group must be defined (default has Everyone & Owners)

Script Description:

   Script Name: N/A (This script doesn't have a specific name, but it's used as an example for adding avatars to a group in a virtual world.)
   Description: This script is intended for use in a virtual world environment and demonstrates how to add avatars to a designated group with a specified role when they touch an object containing the script.

Events and Functionality:

   state_entry() Event:
       This event is triggered when the script is initialized.
       In this event, the script uses llSay to send a message in the public chat channel (PUBLIC_CHANNEL). The message informs users that they can touch the object to use the osAddAgentToGroup function to add themselves to a group.
   touch_end(integer num) Event:
       This event is triggered when an avatar touches the object containing the script.
       It retrieves the unique identifier (key) of the avatar who touched the object using llDetectedKey(0).
   Adding an Avatar to a Group:
       Inside the touch_end event, the script uses the osAddAgentToGroup function to add the avatar (identified by AgentID) to the specified group (GroupToJoin) and assigns them the specified role (RoleToJoin).
       This function effectively adds the avatar to the group and grants them the specified role within that group.
Threat Level None
Permissions No permissions specified
Extra Delay No function delay specified
Example(s)
//
// osAddAgentToGroup Script Example
//
 
// Define the group and role to which avatars will be added.
string GroupToJoin = "Test Group";
string RoleToJoin = "Everyone";
 
default
{
    // This event is triggered when the script is initialized.
    state_entry()
    {
        // Send a message in public chat to inform users about the script's functionality.
        llSay(PUBLIC_CHANNEL, "Touch to use osAddAgentToGroup to add yourself to a group.");
    }
 
    // This event is triggered when an avatar touches the object containing the script.
    touch_end(integer num)
    {
        // Get the unique identifier (key) of the avatar who touched the object.
        key AgentID = llDetectedKey(0);
 
        // Use the osAddAgentToGroup function to add the avatar to a specified group and role.
        // This allows the avatar to join the group and take on the specified role.
        osAddAgentToGroup(AgentID, GroupToJoin, RoleToJoin);
    }
}
Personal tools
General
About This Wiki