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

67 lines
1.4 KiB
Plaintext

// senate cell
include library.utils;
const string JEDI_ROOM_PERMISSIONS_TABLE = "datatables/pvp/jedi_enclave_room_permissions.iff";
const string DATA_COLUMN_COMMUNITY_CELLS = "_community_cells";
trigger OnAboutToReceiveItem(obj_id srcContainer, obj_id transferer, obj_id item)
{
if(checkCellPermission(item, self, false))
{
return SCRIPT_CONTINUE;
}
return SCRIPT_OVERRIDE;
}
//
// check to see if @item has access permission for @cell
//
boolean checkCellPermission(obj_id item, obj_id cell, boolean silent)
{
if(!isIdValid(item))
{
return false;
}
if(isGod(item))
{
sendSystemMessageTestingOnly(item, "god access granted to this area");
return true;
}
if(!isMob(item))
{
return true;
}
obj_id enclave = getTopMostContainer(cell);
string alignment = "light";
string cellName = getCellName(cell);
string columnName = alignment + "_" + cellName;
if(isPlayer(item))
{
string[] commonsAreaCells = dataTableGetStringColumn(JEDI_ROOM_PERMISSIONS_TABLE, alignment + DATA_COLUMN_COMMUNITY_CELLS);
if(utils.getElementPositionInArray(commonsAreaCells, cellName) > -1)
{
return true;
}
else
{
int[] allowedRanks = dataTableGetIntColumnNoDefaults(JEDI_ROOM_PERMISSIONS_TABLE, columnName);
int rank = getIntObjVar(item, "senator_rank");
if(utils.getElementPositionInArray(allowedRanks, rank) >= 0)
{
return true;
}
}
}
return false;
}