Iprovidelittlepianos
Vault Senior Citizen

I should probably just ask this on the nexus forums but I’ll try here as well.
I’m trying to write what should be a fairly simple script, but I’m not really sure about the syntax. Essentially, I want to add an item to the player’s inventory every time a weapon is aimed, and remove the item when you stop aiming. I believe this can be achieved using the IsControlPressed function.
Here’s an example:
Begin GameMode
if IsControlPressed controlCode:6 = 1
player.additem (object)
So that should add the object on aim, right? Now for removing the object, do I just do the reverse?
if IsControlPressed controlCode:6 = 0
player.removeitem (object)
Or do I need to GetItemCount for the object before trying to remove it, so the game isn’t constantly trying to remove an item from the inventory that isn’t there? I just don’t really know what I’m doing here and would like some pointers.
Edit: okay, here’s a revised script:
Begin GameMode
if IsControlPressed 6 == 1
player.additem (object)
elseif GetItemCount (object) == 1
player.removeitem (object)
endif
End
I’m trying to write what should be a fairly simple script, but I’m not really sure about the syntax. Essentially, I want to add an item to the player’s inventory every time a weapon is aimed, and remove the item when you stop aiming. I believe this can be achieved using the IsControlPressed function.
Here’s an example:
Begin GameMode
if IsControlPressed controlCode:6 = 1
player.additem (object)
So that should add the object on aim, right? Now for removing the object, do I just do the reverse?
if IsControlPressed controlCode:6 = 0
player.removeitem (object)
Or do I need to GetItemCount for the object before trying to remove it, so the game isn’t constantly trying to remove an item from the inventory that isn’t there? I just don’t really know what I’m doing here and would like some pointers.
Edit: okay, here’s a revised script:
Begin GameMode
if IsControlPressed 6 == 1
player.additem (object)
elseif GetItemCount (object) == 1
player.removeitem (object)
endif
End
Last edited: