Max integer?

Hello,

I was wondering how I could set a max number for an integer. I can do 'if attribute game.SoldierAmmo >= 156' :do: 'timer:"every 0.0001 change attribute game.SoldierAmmo :to: 156"'. But that seemed like to much. I was wondering if there is an easier way to stop the number. Like in FPS games, where you can only have a certain amount of ammo.

Thanks

Comments

  • colandercolander Member Posts: 1,610

    Where ever you are adding to your ammo count create a rule with the condition "When game.SoldierAmmo <= to 156" and place your Change Attribute inside it.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    There are a couple of ways to do this:

    1. When attribute game.SoldierAmmo ≥ 156 ... Constrain Attribute game.SoldierAmmo to 156.

    2. Alter your Change Attribute so that it says something like When [condition] ... Change Attribute game.SoldierAmmo to min(game.SoldierAmmo+1,156).

    I prefer #2. The min() function returns the smaller of two values, so it will never go above 156. You can add 1 or 10 or 100 or whatever you like... I just added 1 as an example.

  • SLOCM3ZSLOCM3Z Member Posts: 797

    Thanks guys! :smile:

Sign In or Register to comment.