I have this script assigned to the module's on_acquired slot to prevent pickpocketing:
// * This script prevents pickpocketing (and kills pickpocketer)
void main()
{
object oItem = GetModuleItemAcquired();
object oByPC = GetModuleItemAcquiredBy();
object oFromPC = GetModuleItemAcquiredFrom();
object oPC;
string sMessage;
// * If the item is aquired by a PC and is stolen
if (GetIsPC(oFromPC) && GetStolenFlag(oItem))
{
// * Remove the stolen flag and return to the owner
SetStolenFlag(oItem, FALSE);
ActionTakeItem(oItem, oByPC);
ActionGiveItem(oItem, oFromPC);
// * Give warning to pickpocketer, or if warning was given, kill player
if (GetLocalInt(oByPC, "CAUGHT_STEALING"))
{
FloatingTextStringOnCreature("Pickpocket warning ignored! Killing Player!", oByPC, FALSE);
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDeath(), oByPC);
sMessage = GetName(oByPC) + " has been executed for being a moron.";
// * SetLocalInt(oByPC, "CAUGHT_STEALING", 0);
}
else
{
FloatingTextStringOnCreature("Pickpocket is not allowed! Warning given!", oByPC, FALSE);
sMessage = GetName(oByPC) + " tried to steal from " + GetName(oFromPC) + "!";
SetLocalInt(oByPC, "CAUGHT_STEALING", 1);
}
// * Broadcast message to all
oPC = GetFirstPC();
while(GetIsObjectValid(oPC)){
SendMessageToPC(oPC, sMessage);
oPC = GetNextPC();
}
}
}
While the code does kill the pickpocketing player (after a warning is given), it fails to return the item. I don't know why...
Thanks.