mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-01-17 00:05:07 -05:00
60 lines
2.0 KiB
Java
Executable File
60 lines
2.0 KiB
Java
Executable File
package script.test;
|
|
|
|
import script.library.utils;
|
|
import script.library.weapons;
|
|
import script.obj_id;
|
|
|
|
public class create_weapon extends script.base_script
|
|
{
|
|
public create_weapon()
|
|
{
|
|
}
|
|
public int OnAttach(obj_id self) throws InterruptedException
|
|
{
|
|
if (!isGod(self) || getGodLevel(self) < 10 || !isPlayer(self)) {
|
|
detachScript(self, "test.create_weapon");
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
public void makeResource(obj_id self, String rclass) throws InterruptedException
|
|
{
|
|
obj_id[] rtypes = getResourceTypes(rclass);
|
|
sendSystemMessageTestingOnly(self, "Types are..." + rtypes[0].toString());
|
|
obj_id rtype = rtypes[0];
|
|
if (!isIdValid(rtype))
|
|
{
|
|
sendSystemMessageTestingOnly(self, "No id found");
|
|
sendSystemMessageTestingOnly(self, "Type was " + rclass);
|
|
return;
|
|
}
|
|
String crateTemplate = getResourceContainerForType(rtype);
|
|
if (!crateTemplate.equals(""))
|
|
{
|
|
obj_id pInv = utils.getInventoryContainer(self);
|
|
if (isIdValid(pInv))
|
|
{
|
|
obj_id crate = createObject(crateTemplate, pInv, "");
|
|
if (addResourceToContainer(crate, rtype, 100000, self))
|
|
{
|
|
sendSystemMessageTestingOnly(self, "Resource of class " + rclass + " added");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
public int OnSpeaking(obj_id self, String strText) throws InterruptedException
|
|
{
|
|
String[] strCommands = split(strText, ' ');
|
|
if (strCommands[0].equals("cwep"))
|
|
{
|
|
obj_id pInv = utils.getInventoryContainer(self);
|
|
String type = "all";
|
|
if (strCommands.length > 1)
|
|
{
|
|
type = strCommands[1];
|
|
}
|
|
weapons.createOneOfEach(type, pInv, weapons.VIA_TEMPLATE, 1.0f);
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|