mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-07-13 22:01:04 -04:00
* Code compiles - execution NOT tested * updating gitignore * Removed intellij settings files * Removed more intellij files * Added exclusion for JDK classes. * Fixed purchasing script for vendors that have listed coin types. * Updated script to not kick off until the entire preload is complete. * adds static name entry for Solo movie poster and tcg9 vendor entry * clean up empty and orphaned object templates * adds placeholder black market (static) spawns * corrects entries for the video game table to correctly set it in tcg series 2 and remove series 1 console errors * Updated gitignore and removed intellij project files * Fixed appearance reference for thranta payroll and kashyyyk door, added skipLosCheck objvar due to cannit see issue. Requires updated src * Fixed appearance and template for terminal (#2) * Fixed appearance and template for terminal (#3) * Fixed appearance and template for terminal (#4) * Deleted another faulty/orphaned object template * Fixed gcw ranks option on frog. Only issue is that it doesn't award the officer commands or badges. * Fixed some unneeded java 11 changes
169 lines
6.4 KiB
Java
Executable File
169 lines
6.4 KiB
Java
Executable File
package script.hnguyen;
|
|
|
|
import script.dictionary;
|
|
import script.obj_id;
|
|
import script.script_entry;
|
|
|
|
import java.io.*;
|
|
import java.util.StringTokenizer;
|
|
|
|
public class cts_test2 extends script.base_script
|
|
{
|
|
public cts_test2()
|
|
{
|
|
}
|
|
public int OnHearSpeech(obj_id self, obj_id objSpeaker, String strText) throws InterruptedException
|
|
{
|
|
if (objSpeaker != self)
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
if (strText.startsWith("dctsi2 "))
|
|
{
|
|
StringTokenizer st = new StringTokenizer(strText);
|
|
if ((st.countTokens() == 2) || (st.countTokens() == 3))
|
|
{
|
|
String command = st.nextToken();
|
|
String file = st.nextToken();
|
|
boolean onServer = true;
|
|
boolean onClient = false;
|
|
if (st.countTokens() == 1)
|
|
{
|
|
String option = st.nextToken();
|
|
if (option.equals("clientAlso"))
|
|
{
|
|
onClient = true;
|
|
}
|
|
else if (option.equals("clientOnly"))
|
|
{
|
|
onServer = false;
|
|
onClient = true;
|
|
}
|
|
}
|
|
dictionary characterData = new dictionary();
|
|
characterData.put("withItems", true);
|
|
characterData.put("allowOverride", true);
|
|
Object[] triggerParams = new Object[2];
|
|
triggerParams[0] = self;
|
|
triggerParams[1] = characterData;
|
|
try
|
|
{
|
|
int err = script_entry.runScripts("OnUploadCharacter", triggerParams);
|
|
if (err == SCRIPT_CONTINUE)
|
|
{
|
|
byte[] dictPacked = characterData.pack();
|
|
if (onServer)
|
|
{
|
|
FileOutputStream fos = null;
|
|
DataOutputStream dos = null;
|
|
try
|
|
{
|
|
fos = new FileOutputStream(file);
|
|
dos = new DataOutputStream(fos);
|
|
for (byte b : dictPacked) {
|
|
dos.writeByte(b);
|
|
}
|
|
fos.close();
|
|
fos = null;
|
|
long fileSize = (new File(file)).length();
|
|
sendSystemMessageTestingOnly(self, "dictionary written to " + file + " file size=" + fileSize);
|
|
}
|
|
catch(IOException ioe)
|
|
{
|
|
sendSystemMessageTestingOnly(self, "IO error: " + ioe);
|
|
}
|
|
try
|
|
{
|
|
if (fos != null)
|
|
{
|
|
fos.close();
|
|
}
|
|
}
|
|
catch(IOException ioe2)
|
|
{
|
|
sendSystemMessageTestingOnly(self, "IO error on closing file: " + ioe2);
|
|
}
|
|
}
|
|
if (onClient)
|
|
{
|
|
saveBytesOnClient(self, file, dictPacked);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
sendSystemMessageTestingOnly(self, "trigger OnUploadCharacter() *DIDN'T* return SCRIPT_CONTINUE");
|
|
}
|
|
}
|
|
catch(Throwable t)
|
|
{
|
|
sendSystemMessageTestingOnly(self, "trigger OnUploadCharacter() resulted in exception: " + t);
|
|
}
|
|
}
|
|
}
|
|
else if (strText.startsWith("actsi2 "))
|
|
{
|
|
StringTokenizer st = new StringTokenizer(strText);
|
|
if (st.countTokens() == 2)
|
|
{
|
|
removeObjVar(self, "hasTransferred");
|
|
String command = st.nextToken();
|
|
String file = st.nextToken();
|
|
byte[] dictRead = null;
|
|
FileInputStream fis = null;
|
|
DataInputStream dis = null;
|
|
try
|
|
{
|
|
long fileSize = (new File(file)).length();
|
|
sendSystemMessageTestingOnly(self, "reading dictionary " + file + " file size=" + fileSize);
|
|
fis = new FileInputStream(file);
|
|
dis = new DataInputStream(fis);
|
|
dictRead = new byte[(int)(fileSize)];
|
|
int index = 0;
|
|
while (true)
|
|
{
|
|
dictRead[index++] = dis.readByte();
|
|
}
|
|
}
|
|
catch(EOFException eof)
|
|
{
|
|
if (dictRead != null)
|
|
{
|
|
Object[] triggerParams = new Object[2];
|
|
triggerParams[0] = self;
|
|
triggerParams[1] = dictRead;
|
|
int err = script_entry.runScripts("OnDownloadCharacter", triggerParams);
|
|
if (err == SCRIPT_CONTINUE)
|
|
{
|
|
sendSystemMessageTestingOnly(self, "trigger OnDownloadCharacter() return SCRIPT_CONTINUE");
|
|
}
|
|
else
|
|
{
|
|
sendSystemMessageTestingOnly(self, "trigger OnDownloadCharacter() *DIDN'T* return SCRIPT_CONTINUE");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
sendSystemMessageTestingOnly(self, "couldn't read dictionary");
|
|
}
|
|
}
|
|
catch(IOException ioe)
|
|
{
|
|
sendSystemMessageTestingOnly(self, "IO error: " + ioe);
|
|
}
|
|
try
|
|
{
|
|
if (fis != null)
|
|
{
|
|
fis.close();
|
|
}
|
|
}
|
|
catch(IOException ioe2)
|
|
{
|
|
sendSystemMessageTestingOnly(self, "IO error on closing file: " + ioe2);
|
|
}
|
|
}
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|