ff_i_array

Array functions.

References

void CreateStringArray(string sName, object oWhere = OBJECT_INVALID)
Parameters:
  • sName – Name of the array

  • oWhere – Where to save the array, either module (default) or player

Create a new array.

void CreateObjectArray(string sName, object oWhere = OBJECT_INVALID)
Parameters:
  • sName – Name of the array

  • oWhere – Where to save the array, either module (default) or player

Create a new array of references to objects.

int StringArrayContains(string sName, string sValue, object oWhere = OBJECT_INVALID)
Parameters:
  • sName – Name of the array

  • sValue – Value to search for

  • oWhere – Where to save the array, either module (default) or player

Search the array.

int ObjectArrayContains(string sName, object oValue, object oWhere = OBJECT_INVALID)
Parameters:
  • sName – Name of the array

  • oValue – Object to search for

  • oWhere – Where to save the array, either module (default) or player

Search the array.

void StringArrayAdd(string sName, string sValue, object oWhere = OBJECT_INVALID)
Parameters:
  • sName – Name of the array

  • sValue – String to add

  • oWhere – Where to save the array, either module (default) or player

Add an element to the array.

void ObjectArrayAdd(string sName, object oValue, object oWhere = OBJECT_INVALID)
Parameters:
  • sName – Name of the array

  • oValue – Object to add

  • oWhere – Where to save the array, either module (default) or player

Add an element to the array.

void StringArrayDelete(string sName, string sValue, object oWhere = OBJECT_INVALID)
Parameters:
  • sName – Name of the array

  • sValue – String to delete

  • oWhere – Where to save the array, either module (default) or player

Delete an element from the array.

void ObjectArrayDelete(string sName, object oValue, object oWhere = OBJECT_INVALID)
Parameters:
  • sName – Name of the array

  • oValue – Object to delete

  • oWhere – Where to save the array, either module (default) or player

Delete an element from the array.

sqlquery StringArrayIterate(string sName, object oWhere = OBJECT_INVALID)
Parameters:
  • sName – Name of the array

  • oWhere – Where to save the array, either module (default) or player

Iterate the array with SqlStep.

sqlquery ObjectArrayIterate(string sName, object oWhere = OBJECT_INVALID)
Parameters:
  • sName – Name of the array

  • oWhere – Where to save the array, either module (default) or player

Iterate the array with SqlStep.

Source code

// @code

// -----------------------------------------------------------------------------

//! @brief Create a new array
//! @param sName Name of the array
//! @param oWhere Where to save the array, either module (default) or player
void CreateStringArray(string sName, object oWhere = OBJECT_INVALID);
void CreateStringArray(string sName, object oWhere = OBJECT_INVALID)
{
  if (oWhere == OBJECT_INVALID)
    oWhere = GetModule();

  string sSQL = "CREATE TABLE IF NOT EXISTS " + sName + "(value TEXT)";
  sqlquery sqlQuery = SqlPrepareQueryObject(oWhere, sSQL);
  SqlStep(sqlQuery);
}


// -----------------------------------------------------------------------------

//! @brief Create a new array of references to objects.
//! @param sName Name of the array
//! @param oWhere Where to save the array, either module (default) or player
void CreateObjectArray(string sName, object oWhere = OBJECT_INVALID);
void CreateObjectArray(string sName, object oWhere = OBJECT_INVALID)
{
  CreateStringArray(sName, oWhere);
}


// -----------------------------------------------------------------------------

//! @brief Search the array
//! @param sName Name of the array
//! @param sValue Value to search for
//! @param oWhere Where to save the array, either module (default) or player
int StringArrayContains(string sName, string sValue, object oWhere = OBJECT_INVALID);
int StringArrayContains(string sName, string sValue, object oWhere = OBJECT_INVALID)
{
  if (oWhere == OBJECT_INVALID)
    oWhere = GetModule();

  string sSQL = "SELECT 1 FROM " + sName + " WHERE value == @sValue";
  sqlquery sqlQuery = SqlPrepareQueryObject(oWhere, sSQL);
  SqlBindString(sqlQuery, "@sValue", sValue);
  return SqlStep(sqlQuery);
}


// -----------------------------------------------------------------------------

//! @brief Search the array
//! @param sName Name of the array
//! @param oValue Object to search for
//! @param oWhere Where to save the array, either module (default) or player
int ObjectArrayContains(string sName, object oValue, object oWhere = OBJECT_INVALID);
int ObjectArrayContains(string sName, object oValue, object oWhere = OBJECT_INVALID)
{
  return StringArrayContains(sName, GetObjectUUID(oValue), oWhere);
}


// -----------------------------------------------------------------------------

//! @brief Add an element to the array
//! @param sName Name of the array
//! @param sValue String to add
//! @param oWhere Where to save the array, either module (default) or player
void StringArrayAdd(string sName, string sValue, object oWhere = OBJECT_INVALID);
void StringArrayAdd(string sName, string sValue, object oWhere = OBJECT_INVALID)
{
  if (oWhere == OBJECT_INVALID)
    oWhere = GetModule();

  if (StringArrayContains(sName, sValue, oWhere))
    return;

  string sSQL = "INSERT INTO " + sName + " VALUES (@sValue)";
  sqlquery sqlQuery = SqlPrepareQueryObject(oWhere, sSQL);
  SqlBindString(sqlQuery, "@sValue", sValue);
  SqlStep(sqlQuery);
}


// -----------------------------------------------------------------------------

//! @brief Add an element to the array
//! @param sName Name of the array
//! @param oValue Object to add
//! @param oWhere Where to save the array, either module (default) or player
void ObjectArrayAdd(string sName, object oValue, object oWhere = OBJECT_INVALID);
void ObjectArrayAdd(string sName, object oValue, object oWhere = OBJECT_INVALID)
{
  StringArrayAdd(sName, GetObjectUUID(oValue), oWhere);
}


// -----------------------------------------------------------------------------

//! @brief Delete an element from the array
//! @param sName Name of the array
//! @param sValue String to delete
//! @param oWhere Where to save the array, either module (default) or player
void StringArrayDelete(string sName, string sValue, object oWhere = OBJECT_INVALID);
void StringArrayDelete(string sName, string sValue, object oWhere = OBJECT_INVALID)
{
  if (oWhere == OBJECT_INVALID)
    oWhere = GetModule();

  string sSQL = "DELETE FROM " + sName + " WHERE value == @sValue";
  sqlquery sqlQuery = SqlPrepareQueryObject(oWhere, sSQL);
  SqlBindString(sqlQuery, "@sValue", sValue);
  SqlStep(sqlQuery);
}


// -----------------------------------------------------------------------------

//! @brief Delete an element from the array
//! @param sName Name of the array
//! @param oValue Object to delete
//! @param oWhere Where to save the array, either module (default) or player
void ObjectArrayDelete(string sName, object oValue, object oWhere = OBJECT_INVALID);
void ObjectArrayDelete(string sName, object oValue, object oWhere = OBJECT_INVALID)
{
  StringArrayDelete(sName, GetObjectUUID(oValue), oWhere);
}


// -----------------------------------------------------------------------------

//! @brief Iterate the array with SqlStep
//! @param sName Name of the array
//! @param oWhere Where to save the array, either module (default) or player
sqlquery StringArrayIterate(string sName, object oWhere = OBJECT_INVALID);
sqlquery StringArrayIterate(string sName, object oWhere = OBJECT_INVALID)
{
  if (oWhere == OBJECT_INVALID)
    oWhere = GetModule();

  string sSQL = "SELECT * FROM " + sName;
  return SqlPrepareQueryObject(oWhere, sSQL);
}


// -----------------------------------------------------------------------------

//! @brief Iterate the array with SqlStep
//! @param sName Name of the array
//! @param oWhere Where to save the array, either module (default) or player
sqlquery ObjectArrayIterate(string sName, object oWhere = OBJECT_INVALID);
sqlquery ObjectArrayIterate(string sName, object oWhere = OBJECT_INVALID)
{
  return StringArrayIterate(sName, oWhere);
}