Files
NGECore2/scripts/commands/transferitemweapon.py
T
CharonInferar 5e94fd024c Fix for #952
- Weapons, armor and clothing are now correctly equipped again
serverside.
This also re-ensures armor buffs etc
- Vehicles spawn correctly again
2014-06-30 00:15:43 +02:00

52 lines
1.3 KiB
Python

import sys
def setup():
return
def run(core, actor, target, commandString):
parsedMsg = commandString.split(' ', 3)
objService = core.objectService
containerID = long(parsedMsg[1])
container = objService.getObject(containerID)
if target and container and target.getContainer():
oldContainer = target.getContainer()
if container == oldContainer:
print 'Error: New container is same as old container.'
return;
canEquip = core.equipmentService.canEquip(actor, target)
if canEquip[0] is False and container == actor:
actor.sendSystemMessage(canEquip[1], 0)
return
replacedObject = None
slotName = None
replacedObjects = []
slotNames = None
if actor == container:
slotNames = container.getSlotNamesForObject(target)
for slotName in slotNames:
object = container.getSlottedObject(slotName)
if not object in replacedObjects and not object == None:
replacedObjects.append(object)
if object != None:
container.transferTo(actor, container, object)
if target.getTemplate().find('/wearables/') or target.getTemplate().find('/weapon/'):
core.equipmentService.equip(actor, target)
for object in replacedObjects:
core.equipmentService.unequip(actor, object)
oldContainer.transferTo(actor, container, target)
return