mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-10-10 01:12:58 -04:00
212 lines
5.7 KiB
Plaintext
212 lines
5.7 KiB
Plaintext
/**
|
|
* online_jedi_test.script
|
|
*
|
|
* Assumes this script is attached to a character
|
|
*/
|
|
|
|
//----------------------------------------------------------
|
|
|
|
include library.utils;
|
|
include library.jedi;
|
|
include java.util.StringTokenizer;
|
|
|
|
//----------------------------------------------------------
|
|
|
|
trigger OnInitialize()
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnHearSpeech(obj_id objSpeaker, string strText)
|
|
{
|
|
if (objSpeaker != self)
|
|
return SCRIPT_CONTINUE;
|
|
|
|
if (strText.startsWith("ojt3"))
|
|
{
|
|
StringTokenizer st = new StringTokenizer(strText);
|
|
if (st.countTokens() == 2)
|
|
{
|
|
string command = st.nextToken();
|
|
string file = st.nextToken();
|
|
|
|
if (true)
|
|
{
|
|
int numOnlineJedis = 0;
|
|
int numOfflineJedis = 0;
|
|
string strOutput = "";
|
|
string strOffline = "offline jedi\r\n";
|
|
dictionary dctJediInfo = requestJedi(IGNORE_JEDI_STAT, IGNORE_JEDI_STAT, 1, 1000, IGNORE_JEDI_STAT, IGNORE_JEDI_STAT);
|
|
|
|
if (dctJediInfo==null)
|
|
{
|
|
strOutput = "requestJedi() returned NULL dctJediInfo\r\n";
|
|
}
|
|
else
|
|
{
|
|
obj_id[] objJedis = dctJediInfo.getObjIdArray("id");
|
|
boolean[] boolOnline = dctJediInfo.getBooleanArray("online");
|
|
string[] strNames = dctJediInfo.getStringArray("name");
|
|
int[] visibility = dctJediInfo.getIntArray("visibility");
|
|
int[] bountyValue = dctJediInfo.getIntArray("bountyValue");
|
|
int[] level = dctJediInfo.getIntArray("level");
|
|
int[] faction = dctJediInfo.getIntArray("faction");
|
|
location[] loc = dctJediInfo.getLocationArray("location");
|
|
obj_id[][] bounties = (obj_id[][])(dctJediInfo.get("bounties"));
|
|
|
|
if (objJedis != null && boolOnline != null && strNames != null && visibility != null)
|
|
{
|
|
strOutput = "requestJedi() returned " + objJedis.length + " jedis\r\n";
|
|
|
|
for (int i = 0; i < objJedis.length; ++i)
|
|
{
|
|
if (boolOnline[i])
|
|
{
|
|
++numOnlineJedis;
|
|
strOutput += objJedis[i];
|
|
strOutput += " [";
|
|
strOutput += strNames[i];
|
|
strOutput += ",";
|
|
strOutput += visibility[i];
|
|
strOutput += ",";
|
|
strOutput += bountyValue[i];
|
|
strOutput += ",";
|
|
strOutput += level[i];
|
|
strOutput += ",";
|
|
strOutput += getFactionString(faction[i]);
|
|
strOutput += ",";
|
|
strOutput += loc[i];
|
|
strOutput += ", hunted by (";
|
|
for (int j = 0; j < bounties[i].length; ++j)
|
|
{
|
|
if (j > 0)
|
|
strOutput += ",";
|
|
|
|
strOutput += bounties[i][j];
|
|
strOutput += "-";
|
|
strOutput += getPlayerName(bounties[i][j]);
|
|
}
|
|
strOutput += ")";
|
|
|
|
strOutput += "] is online\r\n";
|
|
}
|
|
else
|
|
{
|
|
++numOfflineJedis;
|
|
strOffline += objJedis[i];
|
|
strOffline += " [";
|
|
strOffline += strNames[i];
|
|
strOffline += ",";
|
|
strOffline += visibility[i];
|
|
strOffline += ",";
|
|
strOffline += bountyValue[i];
|
|
strOffline += ",";
|
|
strOffline += level[i];
|
|
strOffline += ",";
|
|
strOffline += getFactionString(faction[i]);
|
|
strOffline += ",";
|
|
strOffline += loc[i];
|
|
strOffline += ", hunted by (";
|
|
for (int j = 0; j < bounties[i].length; ++j)
|
|
{
|
|
if (j > 0)
|
|
strOffline += ",";
|
|
|
|
strOffline += bounties[i][j];
|
|
strOffline += "-";
|
|
strOffline += getPlayerName(bounties[i][j]);
|
|
}
|
|
strOffline += ")";
|
|
|
|
strOffline += "] is offline\r\n";
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
strOutput = "requestJedi() returned null data\r\n";
|
|
}
|
|
}
|
|
|
|
strOutput += numOnlineJedis;
|
|
strOutput += " online jedis\r\n";
|
|
|
|
strOffline += numOfflineJedis;
|
|
strOffline += " offline jedis\r\n";
|
|
|
|
saveTextOnClient(self, "online_jedi" + file + ".txt", strOutput);
|
|
saveTextOnClient(self, "offline_jedi" + file + ".txt", strOffline);
|
|
}
|
|
}
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler hnguyencrbtConfirmed()
|
|
{
|
|
obj_id bhId = params.getObjId( "hunter");
|
|
obj_id jediId = params.getObjId( "jedi");
|
|
int bounties = params.getInt("bounties");
|
|
|
|
string bhName = "";
|
|
string jediName = "";
|
|
|
|
if ((bhId != null) && (isIdValid(bhId)))
|
|
bhName = getPlayerName(bhId);
|
|
|
|
if ((jediId != null) && (isIdValid(jediId)))
|
|
jediName = getPlayerName(jediId);
|
|
|
|
sendSystemMessageTestingOnly(self, "SUCCESS - bounty created bh=(" + bhId + "," + bhName + ") jedi=(" + jediId + "," + jediName + "," + bounties + ")");
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler hnguyencrbtFailed()
|
|
{
|
|
obj_id bhId = params.getObjId( "hunter");
|
|
obj_id jediId = params.getObjId( "jedi");
|
|
int bounties = params.getInt("bounties");
|
|
|
|
string bhName = "";
|
|
string jediName = "";
|
|
|
|
if ((bhId != null) && (isIdValid(bhId)))
|
|
bhName = getPlayerName(bhId);
|
|
|
|
if ((jediId != null) && (isIdValid(jediId)))
|
|
jediName = getPlayerName(jediId);
|
|
|
|
sendSystemMessageTestingOnly(self, "FAILED - bounty not created bh=(" + bhId + "," + bhName + ") jedi=(" + jediId + "," + jediName + "," + bounties + ")");
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
string getFactionString(int iTefFac)
|
|
{
|
|
string sTefFacName = "<unknown>";
|
|
|
|
if (iTefFac == ##"battlefield")
|
|
sTefFacName = "battlefield";
|
|
else if (iTefFac == ##"duel")
|
|
sTefFacName = "duel";
|
|
else if (iTefFac == ##"bountyduel")
|
|
sTefFacName = "bountyduel";
|
|
else if (iTefFac == ##"nonaggressive")
|
|
sTefFacName = "nonaggressive";
|
|
else if (iTefFac == ##"unattackable")
|
|
sTefFacName = "unattackable";
|
|
else if (iTefFac == ##"bountytarget")
|
|
sTefFacName = "bountytarget";
|
|
else if (iTefFac == ##"guildwarcooldownperiod")
|
|
sTefFacName = "guildwarcooldownperiod";
|
|
else if (iTefFac == ##"imperial")
|
|
sTefFacName = "imperial";
|
|
else if (iTefFac == ##"rebel")
|
|
sTefFacName = "rebel";
|
|
else if (iTefFac == ##"bubblecombat")
|
|
sTefFacName = "bubblecombat";
|
|
|
|
return sTefFacName;
|
|
}
|