Files
dsrc/sku.0/sys.server/compiled/game/script/beta/player_warp.script
T
2013-09-10 23:17:15 -07:00

122 lines
3.6 KiB
Plaintext

/**********************************************************************
* Copyright (c)2000-2002 Sony Online Entertainment Inc.
* All Rights Reserved
*
* Title: player_warp
* Description: Enables the warping to a specified location.
* @author $Author:$
* @version $Revision:$
**********************************************************************/
/***** INCLUDES ********************************************************/
include library.utils;
/***** CONSTANTS *******************************************************/
/***** TRIGGERS ********************************************************/
trigger OnSpeaking(string text)
{
if (text.startsWith("warp"))
{
java.util.StringTokenizer st = new java.util.StringTokenizer(text);
if (st.countTokens() < 5)
{
sendSystemMessageTestingOnly(self, "format: warp <planet> <x> <y> <z>");
return SCRIPT_CONTINUE;
}
LOG("LOG_CHANNEL", "tokens -> " + st.countTokens() + " nextToken ->" + st.nextToken());
if (st.hasMoreTokens())
{
string planet = st.nextToken();
float x = (float)utils.stringToInt(st.nextToken());
float y = (float)utils.stringToInt(st.nextToken());
float z = (float)utils.stringToInt(st.nextToken());
//LOG("LOG_CHANNEL", "loc ->" + x + "/" + y + "/" + z);
warpPlayer(self, planet, x, y, z, null, 0.0f, 0.0f, 0.0f);
}
}
if (text.startsWith("create"))
{
java.util.StringTokenizer st = new java.util.StringTokenizer(text);
if (st.countTokens() < 2)
{
sendSystemMessageTestingOnly(self, "format: create <template>");
return SCRIPT_CONTINUE;
}
obj_id inv = getObjectInSlot(self, "inventory");
if (inv == null)
{
LOG("LOG_CHANNEL", "player_warp: create -- Unable to get an inventory slot for " + self);
sendSystemMessageTestingOnly(self, "Your inventory object is null!");
}
string command = st.nextToken();
string template = st.nextToken();
if (template == null || template.length() < 1)
{
sendSystemMessageTestingOnly(self, "That is an invalid object.");
return SCRIPT_CONTINUE;
}
// Check the template against the restricted template list.
LOG("LOG_CHANNEL", "template ->" + template);
int template_idx = dataTableSearchColumnForString(template, "Template", "datatables/beta/restricted_template.iff");
LOG("LOG_CHANNEL", "template_idx ->" + template_idx);
if (template_idx != -1)
{
sendSystemMessageTestingOnly(self, "You cannot create that object.");
return SCRIPT_CONTINUE;
}
// Check for restricted directories.
int num_rows = dataTableGetNumRows ("datatables/beta/restricted_template.iff");
for (int i = 0; i < num_rows; i++)
{
dictionary row = dataTableGetRow("datatables/beta/restricted_template.iff", i);
if (row != null)
{
string directory = row.getString("Directory");
if (directory.length() > 0)
{
if ((template.indexOf(directory)) != -1)
{
sendSystemMessageTestingOnly(self, "You cannot create that object.");
return SCRIPT_CONTINUE;
}
}
else
break;
}
}
if (template.length() < 1)
sendSystemMessageTestingOnly(self, "That is an invalid object.");
else
{
obj_id object = createObjectOverloaded(template, inv);
if (!isIdValid(object))
sendSystemMessageTestingOnly(self, "That is an invalid object.");
else
sendSystemMessageTestingOnly(self, object + " created.");
}
}
return SCRIPT_CONTINUE;
}
/***** MESSAGEHANDLERS *************************************************/
/***** COMMANDHANDLERS *************************************************/
/***** FUNCTIONS *******************************************************/