Jump to content

Need help with papryus function.


Recommended Posts

The line as Pokepunch described should work fine with keywords.

Game.GetPlayer().RemoveItem(EquipSlot_A_Coat, -1, true)

Only thing I can imagine why it might not be working is that the keyword property might not be correctly set? Check in the CK just to make sure...

Link to comment
Share on other sites

It's hard to know how to help you because we can't see your whole script. You have people essentially guessing as to how to do that.

 

From what I can tell you are trying to remove an item that has a certain keyword?

 

If so then you want something along the lines of:

 

Game.GetPlayer().RemoveItem(<ObjectNameHere>.HasKeyword(<KeywordNameHere>))

 

Of course you'll need some kind of way of iterating through objects, either through a list that runs through and checks everything, or using events to check items. But, again, to say any more than that we'd need to see your code.

My code realy won't tell you nothing.

 

I think that's the point:

"Of course you'll need some kind of way of iterating through objects, either through a list that runs through and checks everything, or using events to check items. But, again, to say any more than that we'd need to see your code"

 

I'm not quiete sure what you mean tho...

You mean I need to asign an array there?

Any idea why "akObjectToRemove.HasKeyword(<KeywordNameHere>)" does not compile?

Link to comment
Share on other sites

The line as Pokepunch described should work fine with keywords.

Game.GetPlayer().RemoveItem(EquipSlot_A_Coat, -1, true)

Only thing I can imagine why it might not be working is that the keyword property might not be correctly set? Check in the CK just to make sure...

Property is properly set.

Other functions using this property are working correctly.

Did you compile it yourself and got it working?

Link to comment
Share on other sites

Because "akObjectToRemove.HasKeyword(<KeywordNameHere>)" is not valid papyrus code. You dont put statements in double quotes and you cannot use angle brackets in variable names. Compiler errors are the most rookie of problems. If you knew enough about papyrus to say you dont need to post your source then you wouldnt be having compiler errors to begin with. LISTEN to the two pages of experienced scripters telling you what you need to do!

 

POST. YOUR. SOURCE. All of it. Post the EXACT compiler errors from the output windows and stop making yourself absolutely unhelpable.

Link to comment
Share on other sites

Property is properly set.

Other functions using this property are working correctly.

Did you compile it yourself and got it working?

 

Not with your keyword, but works for me just fine in my scripts with keywords. Also, you don't need to iterate through anything unless you want to do something extra to each object. Setting the parameter aiCount to -1 will remove all items of that type or that contain that keyword. So, theoretically, that simple line should work. Does the log give you any errors?

 

I asked about the property because it has happened to me, something not working for days and then it was the property which had not been correctly registered by the CK. Since then I always use auto-form to fill them just in case.

Link to comment
Share on other sites

Ok I'm posting it again...

 

CODE:

 

Scriptname PlayerEqupingLimiter extends Actor Const

 

Event OnItemEquipped(Form akBaseObject, ObjectReference akReference)
if akBaseObject.HasKeyword(EquipSlot_A_Coat)
if Game.GetPlayer().HasPerk(SlotEquipped_A_Coat)
Game.GetPlayer().RemoveItem(Keyword EquipSlot_A_Coat, int aiCount = -1, bool abSilent = true)
Game.GetPlayer().EquipItem(akBaseObject, abSilent = True)
Game.GetPlayer().AddPerk(SlotEquipped_A_Coat)
Else
Game.GetPlayer().AddPerk(SlotEquipped_A_Coat)
EndIf
EndIf
endEvent
Perk Property SlotEquipped_A_Coat Auto Const
Keyword Property EquipSlot_A_Coat Auto Const
AND THE LOG:
Papyrus Compiler Version 2.8.0.4 for Fallout 4
Copyright © ZeniMax Media. All rights reserved.
Starting 1 compile threads for 1 files...
Compiling "PlayerEqupingLimiter"...
C:\Users\borys\AppData\Local\Temp\PapyrusTemp\PlayerEqupingLimiter.psc(8,45): no viable alternative at input 'EquipSlot_A_Coat'
C:\Users\borys\AppData\Local\Temp\PapyrusTemp\PlayerEqupingLimiter.psc(8,79): required (...)+ loop did not match anything at input ','
C:\Users\borys\AppData\Local\Temp\PapyrusTemp\PlayerEqupingLimiter.psc(8,101): required (...)+ loop did not match anything at input ')'
No output generated for PlayerEqupingLimiter, compilation failed.
Edited by khazerruss
Link to comment
Share on other sites

I see a couple of problems in your code. Try this to see if it compiles:

Scriptname PlayerEqupingLimiter extends Actor Const

 
Event OnItemEquipped(Form akBaseObject, ObjectReference akReference)
   if akBaseObject.HasKeyword(EquipSlot_A_Coat)
      if Game.GetPlayer().HasPerk(SlotEquipped_A_Coat)
         Game.GetPlayer().RemoveItem(EquipSlot_A_Coat, -1, true)
         Game.GetPlayer().EquipItem(akBaseObject, False, True)
         Game.GetPlayer().AddPerk(SlotEquipped_A_Coat)
      Else
         Game.GetPlayer().AddPerk(SlotEquipped_A_Coat)
      EndIf
   EndIf
endEvent
 
 
Perk Property SlotEquipped_A_Coat Auto Const
 
Keyword Property EquipSlot_A_Coat Auto Const
Link to comment
Share on other sites

 

I see a couple of problems in your code. Try this to see if it compiles:

Scriptname PlayerEqupingLimiter extends Actor Const

 
Event OnItemEquipped(Form akBaseObject, ObjectReference akReference)
   if akBaseObject.HasKeyword(EquipSlot_A_Coat)
      if Game.GetPlayer().HasPerk(SlotEquipped_A_Coat)
         Game.GetPlayer().RemoveItem(EquipSlot_A_Coat, -1, true)
         Game.GetPlayer().EquipItem(akBaseObject, False, True)
         Game.GetPlayer().AddPerk(SlotEquipped_A_Coat)
      Else
         Game.GetPlayer().AddPerk(SlotEquipped_A_Coat)
      EndIf
   EndIf
endEvent
 
 
Perk Property SlotEquipped_A_Coat Auto Const
 
Keyword Property EquipSlot_A_Coat Auto Const

It does compile!! Great thanx Dielos!

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...