johnjos13 Posted June 8, 2023 Posted June 8, 2023 Im trying to write what should be a fairly simple script, but Im not really sure about the syntax. Essentially, I want to add an item to the players 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. Heres an example: Begin GameMode if IsControlPressed controlCode:6 = 1player.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 = 0player.removeitem (object) Or do I need to GetItemCount for the object before trying to remove it, so the game isnt constantly trying to remove an item from the inventory that isnt there? I just dont really know what Im doing here and would like some pointers.
johnjos13 Posted June 8, 2023 Author Posted June 8, 2023 (edited) Heres my revised script: Begin GameMode if IsControlPressed 6 == 1 player.additem (object) elseif GetItemCount (object) == 1 player.removeitem (object) endif End How does this look? Ignore the indentation errors, cant get indentations to work on these forums. Edited June 8, 2023 by johnjos13
Recommended Posts