Template:Needs Translation/
函数名
|
Function: integer llGetInventoryPermMask( string item, integer category )
|
参数:
- string item–an item in the inventory of the prim this script is in
- integer category–MASK_* flag
|
返回值:返回库存项的请求权限类别的位字段(整数)
|
注意事项
|
注意事项
- 如果项目从prim的库存中丢失,那么在DEBUG_CHANNEL上会喊出一个错误。
|
示例
|
if ((permsYouHave & permsYouWant) == permsYouWant)
llSay(PUBLIC_CHANNEL, "You have the perms you want.");
else
llSay(PUBLIC_CHANNEL, "You don't have the perms you want.");
integer ownerPerms = llGetInventoryPermMask("inventory item name goes here", MASK_OWNER);
integer copyAndModPerms = PERM_COPY | PERM_MODIFY;
if ((ownerPerms & copyAndModPerms) == copyAndModPerms)
llSay(PUBLIC_CHANNEL, "Owner has copy & modify perms.");
else
llSay(PUBLIC_CHANNEL, "Owner does not have copy & modify perms.");
string getPermsAsReadableString(integer perm)
{
integer fullPerms = PERM_COPY | PERM_MODIFY | PERM_TRANSFER;
integer copyModPerms = PERM_COPY | PERM_MODIFY;
integer copyTransPerms = PERM_COPY | PERM_TRANSFER;
integer modTransPerms = PERM_MODIFY | PERM_TRANSFER;
string output = " perms: ";
if ((perm & fullPerms) == fullPerms)
output += "full";
else if ((perm & copyModPerms) == copyModPerms)
output += "copy & modify";
else if ((perm & copyTransPerms) == copyTransPerms)
output += "copy & transfer";
else if ((perm & modTransPerms) == modTransPerms)
output += "modify & transfer";
else if ((perm & PERM_COPY) == PERM_COPY)
output += "copy";
else if ((perm & PERM_TRANSFER) == PERM_TRANSFER)
output += "transfer";
else
output += "none";
// Remember, items in Second Life must have either
// PERM_COPY or PERM_TRANSFER when "talking about"
// owner perms or perms for next owner.
return output;
}
default
{
state_entry()
{
string inventoryItemName = "inventory item name goes here";
integer basePerms = llGetInventoryPermMask(inventoryItemName, MASK_BASE);
integer ownerPerms = llGetInventoryPermMask(inventoryItemName, MASK_OWNER);
integer nextOwnerPerms = llGetInventoryPermMask(inventoryItemName, MASK_NEXT);
integer groupPerms = llGetInventoryPermMask(inventoryItemName, MASK_GROUP);
integer everyonePerms = llGetInventoryPermMask(inventoryItemName, MASK_EVERYONE);
llSay(0, "/me [" + inventoryItemName
+ "]: base" + getPermsAsReadableString(basePerms));
llSay(0, "/me [" + inventoryItemName
+ "]: owner" + getPermsAsReadableString(ownerPerms));
llSay(0, "/me [" + inventoryItemName
+ "]: next owner" + getPermsAsReadableString(nextOwnerPerms));
llSay(0, "/me [" + inventoryItemName
+ "]: group" + getPermsAsReadableString(groupPerms));
llSay(0, "/me [" + inventoryItemName
+ "]: everyone" + getPermsAsReadableString(everyonePerms));
}
}
测试反义词(例如,看某物是否不是复制的):
if (!(PERM_COPY & llGetInventoryPermMask(myitem, MASK_OWNER)))
llSay(PUBLIC_CHANNEL, "/me [" + myitem + "]: owner doesn't have copy perms.");
提醒下一位业主在出售前设置哪些权限,选择哪些权限需要设置;
CheckPerms()
{
string item = llGetScriptName();
integer nextOwnerPerms = llGetInventoryPermMask(item, MASK_NEXT);
if(PERM_COPY & nextOwnerPerms)
llOwnerSay("Set no copy");
if(PERM_MODIFY & nextOwnerPerms)
llOwnerSay("Set no mod");
if(PERM_TRANSFER & nextOwnerPerms)
llOwnerSay("Set no transfer");
}
default
{
on_rez(integer start_param)
{
llResetScript();
}
state_entry()
{
if(llGetOwner() != llGetInventoryCreator(llGetScriptName()))
CheckPerms();
}
}
|