Jump to content

Scripting help


johnjos13

Recommended Posts

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 = 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 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.

Link to comment
Share on other sites

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 by johnjos13
Link to comment
Share on other sites

  • Recently Browsing   0 members

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