#include "da_includefile_1"
#include "dmfi_init_inc"
#include "sha_subr_methds"
// If your module's OnClientEnter has custom scripting, just paste the following into it.
// Be sure to include the file "da_includefile_1" at the very top, as it is here.
void main()
{
SetLocalInt(GetEnteringObject(), "nRestingCounterPC", 100); // (100) number of rounds between rest must be same as on OnModRest
int iPUNISHMENT = TRUE; //Change this to FALSE to turn *off* the module's auto-punishment for criminals who try to log off and on again to evade punishment.
object DA_oMODULE = GetModule();
object DA_oPC = GetEnteringObject();
object DA_oAREA = GetArea(DA_oPC);
object DA_oPITMASTER = GetObjectByTag("da_pitmaster");
object DA_oPIT = GetArea(DA_oPITMASTER);
object DA_oWP_ENTRANCE = GetWaypointByTag("da_wp_entrance");
int iENFORCER = GetIsEnforcer(DA_oPC);
int iEXEMPT = GetIsExempt(DA_oPC);
string DA_sNAME = GetName(DA_oPC);
string DA_sUSERID = GetPCPlayerName(DA_oPC);
DeleteLocalInt(DA_oPC, "da_slot");
DeleteLocalInt(DA_oPC, "da_Team");
if (iENFORCER == TRUE) //Place an Enforcer Key in the inventory of every Enforcer who doesn't yet have one.
{
int iHASKEY = FALSE;
string sKEY = "da_enforcerkey";
object oITEM = GetFirstItemInInventory(DA_oPC);
while (GetIsObjectValid(oITEM))
{
string sITEM = GetTag(oITEM);
string sITEMLEFT14 = GetStringLeft(sITEM, 14);
if (sITEMLEFT14 == sKEY)
iHASKEY = TRUE;
oITEM = GetNextItemInInventory(DA_oPC);
}
if (iHASKEY == FALSE)
{
CreateItemOnObject("da_enforcerkey", DA_oPC);
SendMessageToPC(DA_oPC, "You might find this item useful; please hold on to it.");
}
}
else //Destroy all Enforcer Keys in the inventory of non-authorized enforcers.
{
string sKEY = "da_enforcerkey";
object oITEM = GetFirstItemInInventory(DA_oPC);
while (GetIsObjectValid(oITEM))
{
string sITEM = GetTag(oITEM);
string sITEMLEFT14 = GetStringLeft(sITEM, 14);
if (sITEMLEFT14 == sKEY)
{
DestroyObject(oITEM);
SendMessageToPC(DA_oPC, "You are not authorized to carry an Enforcer Key; it has been destroyed.");
}
oITEM = GetNextItemInInventory(DA_oPC);
}
}
if (iEXEMPT == TRUE)
DeleteLocalInt(DA_oMODULE, "da_" + DA_sNAME + DA_sUSERID); //Make sure no exempt player is counted as punishable.
int iJAIL = GetLocalInt(DA_oMODULE, "da_" + DA_sNAME + DA_sUSERID);
if (iJAIL == TRUE && iPUNISHMENT == TRUE)
{
int iPRIORXP = GetXP(DA_oPC);
int iXPHIT = iPRIORXP/10;
int iPOSTXP = iPRIORXP - iXPHIT; //Take 10% of the criminal's XP.
SetXP(DA_oPC,iPOSTXP); //Default punishment is 5%; the other 5% is for logging off and on again.
object oITEM = GetFirstItemInInventory(DA_oPC);
while (GetIsObjectValid(oITEM))
{
DestroyObject(oITEM); //Destroy all items in the criminal's inventory.
oITEM = GetNextItemInInventory(DA_oPC);
}
oITEM = GetItemInSlot(INVENTORY_SLOT_ARMS, DA_oPC); //Destroy all equipped items.
if (GetIsObjectValid(oITEM))
DestroyObject(oITEM);
oITEM = GetItemInSlot(INVENTORY_SLOT_ARROWS, DA_oPC);
if (GetIsObjectValid(oITEM))
DestroyObject(oITEM);
oITEM = GetItemInSlot(INVENTORY_SLOT_BELT, DA_oPC);
if (GetIsObjectValid(oITEM))
DestroyObject(oITEM);
oITEM = GetItemInSlot(INVENTORY_SLOT_BOLTS, DA_oPC);
if (GetIsObjectValid(oITEM))
DestroyObject(oITEM);
oITEM = GetItemInSlot(INVENTORY_SLOT_BOOTS ,DA_oPC);
if (GetIsObjectValid(oITEM))
DestroyObject(oITEM);
oITEM = GetItemInSlot(INVENTORY_SLOT_BULLETS, DA_oPC);
if (GetIsObjectValid(oITEM))
DestroyObject(oITEM);
oITEM = GetItemInSlot(INVENTORY_SLOT_CHEST, DA_oPC);
if (GetIsObjectValid(oITEM))
DestroyObject(oITEM);
oITEM = GetItemInSlot(INVENTORY_SLOT_CLOAK,DA_oPC);
if (GetIsObjectValid(oITEM))
DestroyObject(oITEM);
oITEM = GetItemInSlot(INVENTORY_SLOT_HEAD,DA_oPC);
if (GetIsObjectValid(oITEM))
DestroyObject(oITEM);
oITEM = GetItemInSlot(INVENTORY_SLOT_LEFTHAND, DA_oPC);
if (GetIsObjectValid(oITEM))
DestroyObject(oITEM);
oITEM = GetItemInSlot(INVENTORY_SLOT_LEFTRING, DA_oPC);
if (GetIsObjectValid(oITEM))
DestroyObject(oITEM);
oITEM = GetItemInSlot(INVENTORY_SLOT_NECK, DA_oPC);
if (GetIsObjectValid(oITEM))
DestroyObject(oITEM);
oITEM = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, DA_oPC);
if (GetIsObjectValid(oITEM))
DestroyObject(oITEM);
oITEM = GetItemInSlot(INVENTORY_SLOT_RIGHTRING, DA_oPC);
if (GetIsObjectValid(oITEM))
DestroyObject(oITEM);
int iGP = GetGold(DA_oPC);
AssignCommand(DA_oPC, TakeGoldFromCreature(iGP, DA_oPC, TRUE)); //Take the criminal's gold.
object oGARB = CreateItemOnObject("da_prsngrb", DA_oPC); //Make the criminal don prison garb.
DelayCommand(0.1, AssignCommand(DA_oPC, ActionEquipItem(oGARB, INVENTORY_SLOT_CHEST)));
DelayCommand(10.0, FloatingTextStringOnCreature("You're still a criminal; leaving & coming back won't help.", DA_oPC, FALSE)); //Verbal reprimand.
}
object oUser = GetEnteringObject();
// do any other module OnClientEnter work here
ExecuteScript("x3_mod_def_enter", OBJECT_SELF);
// initialize DMFI
dmfiInitialize(oUser);
SubraceOnClientEnter();
}