Jump to content

Papyrus Error: type mismatch in parameter 2 - cannot pass a none to a int


Recommended Posts

Hello everyone!

 

I've been trying to create a simple activator that turns gas canisters in the player inventory into full gas canisters (custom item), but I've run into a snag.

 

the full script is as follows:

Scriptname gasCanFillSCRIPT extends ObjectReference

MiscObject Property GasCanister Auto Const
MiscObject Property GasCanisterFull Auto Const

EVENT OnLoad()    
	blockActivation()
endEVENT

EVENT OnActivate(ObjectReference akActionRef)
    ;int Property playerCanCount
		(Game.GetPlayer().GetItemCount(GasCanister))
	;EndProperty
	;if akActionRef == game.GetPlayer() && playerCanCount > 0
		akActionRef.RemoveItem(GasCanister, -1)
		akActionRef.ddItem(GasCanisterFull, playerCanCount, False)
    ;endif
endEVENT

Everything seems to be fine except the last line before the endif, which throws me two errors: variable playerCanCount is undefined and type mismatch in parameter 2 - cannot pass a none to a int.

 

Originally my variable was just int playerCanCount = (Game.GetPlayer().GetItemCount(GasCanister)), but since it didn't work I changed it to a property. Seeing that its giving me the same error, though, leads me to believe my mistake is not with the definition.

 

Does anyone know the reason why it errors? Thanks!

Edited by placeholderthesteam
Link to comment
Share on other sites

Your original count should work fine, are you sure the script is firing having blocked activation ? This works fine for me:

EVENT OnActivate(ObjectReference akActionRef)

Game.GetPlayer().AddItem(GasCanister, aiCount = 11, abSilent = true) ;test to make sure there are some 

int playerCanCount = (Game.GetPlayer().GetItemCount(GasCanister))

Debug.Trace ("MYSCRIPT.OnActivate " + akActionRef + " playerCanCount " + playerCanCount)

if (akActionRef == game.GetPlayer()) && (playerCanCount > 0)
   akActionRef.RemoveItem(GasCanister, aiCount = playerCanCount, abSilent = true, akOtherContainer = None)
   akActionRef.AddItem(GasCanisterFull,  aiCount = playerCanCount, abSilent = false)
endif

endEVENT
Edited by SKK50
Link to comment
Share on other sites

 

Your original count should work fine, are you sure the script is firing having blocked activation ? This works fine for me:

EVENT OnActivate(ObjectReference akActionRef)

Game.GetPlayer().AddItem(GasCanister, aiCount = 11, abSilent = true) ;test to make sure there are some 

int playerCanCount = (Game.GetPlayer().GetItemCount(GasCanister))

Debug.Trace ("MYSCRIPT.OnActivate " + akActionRef + " playerCanCount " + playerCanCount)

if (akActionRef == game.GetPlayer()) && (playerCanCount > 0)
   akActionRef.RemoveItem(GasCanister, aiCount = playerCanCount, abSilent = true, akOtherContainer = None)
   akActionRef.AddItem(GasCanisterFull,  aiCount = playerCanCount, abSilent = false)
endif

endEVENT

 

Thanks, that works for me. Not sure why though, since the only difference between my original script is that the conditionals in the if are in parentheses, and all of the parameters are explicitly assigned. Either way thank you!

Link to comment
Share on other sites

  • Recently Browsing   0 members

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