change llRequestUsername

This commit is contained in:
UbitUmarov
2020-08-15 04:05:41 +01:00
parent 657b781f2f
commit 991b97db58
3 changed files with 38 additions and 6 deletions

View File

@@ -15257,14 +15257,46 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return Name2Username(llKey2Name(id));
}
public LSL_Key llRequestUsername(string id)
public LSL_String llRequestUsername(LSL_Key id)
{
UUID rq = UUID.Random();
m_host.AddScriptLPS(1);
if (!UUID.TryParse(id, out UUID key))
return string.Empty;
m_AsyncCommands.DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, rq.ToString());
ScenePresence lpresence = World.GetScenePresence(key);
if (lpresence != null)
{
string lname = lpresence.Name;
string lrq = UUID.Random().ToString();
UUID ltis = m_AsyncCommands.DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, lrq);
m_AsyncCommands.DataserverPlugin.DataserverReply(lrq, Name2Username(lname));
return ltis.ToString();
}
m_AsyncCommands.DataserverPlugin.DataserverReply(rq.ToString(), Name2Username(llKey2Name(id)));
Action<string> act = eventID =>
{
string name = String.Empty;
ScenePresence presence = World.GetScenePresence(key);
if (presence != null)
{
name = presence.Name;
}
else if (World.TryGetSceneObjectPart(key, out SceneObjectPart sop ) && sop != null)
{
name = sop.Name;
}
else
{
UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, key);
if(account != null)
{
name = account.FirstName + " " + account.LastName;
}
}
m_AsyncCommands.DataserverPlugin.DataserverReply(eventID, Name2Username(name));
};
UUID rq = m_AsyncCommands.DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, UUID.Random().ToString(), act);
return rq.ToString();
}

View File

@@ -233,7 +233,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
LSL_String llIntegerToBase64(int number);
LSL_String llKey2Name(LSL_Key id);
LSL_String llGetUsername(LSL_Key id);
LSL_Key llRequestUsername(string id);
LSL_String llRequestUsername(LSL_Key id);
LSL_String llGetDisplayName(string id);
LSL_Key llRequestDisplayName(string id);
void llLinkParticleSystem(int linknum, LSL_List rules);

View File

@@ -961,7 +961,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
return m_LSL_Functions.llGetUsername(id);
}
public LSL_Key llRequestUsername(string id)
public LSL_String llRequestUsername(LSL_Key id)
{
return m_LSL_Functions.llRequestUsername(id);
}