I am using this script to restrict use of certain items,
#include "x2_inc_switches"
void main()
{
object oPC;
oPC = GetPCItemLastEquippedBy();
object oItem;
int nSlot;
//If not level 40, unequip the item!
if(GetHitDice(oPC)<=39)
{
for (nSlot=0; nSlot<NUM_INVENTORY_SLOTS; nSlot++)
{
oItem=GetItemInSlot(nSlot, oPC);
if (GetIsObjectValid(oItem))
{
//Unequip all items tag named "epic"
if(GetTag(oItem) == "epic")
{
AssignCommand(oPC, ActionUnequipItem(oItem));
FloatingTextStringOnCreature
("You are not level 40 and cannot use this item!", oPC);
}
else
{ }
}
}
}
}
When players equip the items it unequips it right away, thing is when they try to equipe it the second time it allows this ????
Something not right with script
Débuté par
Madasahatter
, avril 18 2011 04:41
#1
Posté 18 avril 2011 - 04:41
#2
Posté 18 avril 2011 - 05:35
#include "x2_inc_switches"
void main()
{
object oPC;
oPC = GetPCItemLastEquippedBy();
object oItem = GetPCItemLastEquipped();
//If not level 40, unequip the item!
if(GetHitDice(oPC)<=39)
{
AssignCommand(oPC, ClrarAllActions(TRUE));
AssignCommand(oPC, ActionUnequipItem(oItem));
AssignCommand(oPC, ActionDoCommand(SetCommandable(TRUE)));
SetCommandable(FALSE,oPC);
}
}
I am currently not near the toolset, SO sorry if it does not compile right the first time.
There Is no need to search for the item. GetPCItemLastEquipped(); will return the correct item that triggered the event without a search. We also set the PC uncommandable untill he has unequiped the item. This way he can not do anything so clear his action of unequiping it.
Edit: Now that I look at the script again. If you are running the script as a TagBasedScript you will also need a check for the Event that is runnung the script. If you are running it directly in the module Event you will need some kind of filter for the item, Such as the Tag, Or else the will not be able to equip any item.
void main()
{
object oPC;
oPC = GetPCItemLastEquippedBy();
object oItem = GetPCItemLastEquipped();
//If not level 40, unequip the item!
if(GetHitDice(oPC)<=39)
{
AssignCommand(oPC, ClrarAllActions(TRUE));
AssignCommand(oPC, ActionUnequipItem(oItem));
AssignCommand(oPC, ActionDoCommand(SetCommandable(TRUE)));
SetCommandable(FALSE,oPC);
}
}
I am currently not near the toolset, SO sorry if it does not compile right the first time.
There Is no need to search for the item. GetPCItemLastEquipped(); will return the correct item that triggered the event without a search. We also set the PC uncommandable untill he has unequiped the item. This way he can not do anything so clear his action of unequiping it.
Edit: Now that I look at the script again. If you are running the script as a TagBasedScript you will also need a check for the Event that is runnung the script. If you are running it directly in the module Event you will need some kind of filter for the item, Such as the Tag, Or else the will not be able to equip any item.
Modifié par Lightfoot8, 19 avril 2011 - 02:01 .
#3
Posté 18 avril 2011 - 08:52
Thanks for the reply, I still have the same problem. the first time I try to equip the item all is good, second time i try it equips the item but its shaded out but still usable.
#4
Posté 18 avril 2011 - 08:58
Ok just checked again and it looks as if its been equiped but does not apply enhancements
#5
Posté 18 avril 2011 - 09:21
Close your Character window and reopen it. What you are seing is either a Display Bug. Or a problem with the script trying to unequip again on the unequip event.
Note my Edit Above. Your script is not compleate. In order compleate it, I would have to know How you are running it. Is it a TagBased Script Or entered directly into the OnEquip Event Script.
Either Was once an Item Grays out just close the character Screen and reopen it. The Item is not really equipted. It is Que-ed up to get equipted but something is stopping it. In this case it is your script that is stopping it.
Note my Edit Above. Your script is not compleate. In order compleate it, I would have to know How you are running it. Is it a TagBased Script Or entered directly into the OnEquip Event Script.
Either Was once an Item Grays out just close the character Screen and reopen it. The Item is not really equipted. It is Que-ed up to get equipted but something is stopping it. In this case it is your script that is stopping it.
#6
Posté 18 avril 2011 - 09:33
I will assume that you are useing it as a TagBasedScript. in that case it should look like this.
#include "x2_inc_switches"
void main()
{
if (GetUserDefinedItemEventNumber() != X2_ITEM_EVENT_UNEQUIP) return;
object oPC;
oPC = GetPCItemLastEquippedBy();
object oItem = GetPCItemLastEquipped();
//If not level 40, unequip the item!
if(GetHitDice(oPC)<=39)
{
AssignCommand(oPC, ClearAllActions(TRUE));
AssignCommand(oPC, ActionUnequipItem(oItem));
AssignCommand(oPC, ActionDoCommand(SetCommandable(TRUE)));
SetCommandable(FALSE,oPC);
}
}
Modifié par Lightfoot8, 19 avril 2011 - 02:01 .





Retour en haut






