Best way to use Ammo?

Discussion in 'Plugin Development' started by CraftCreeper6, Sep 10, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    CraftCreeper6

    Hi! I don't know if this is related to this topic but I thought this was the most relevant place.
    Anyone have any ideas on a system for ammo?
    If possible not including: Inventory Ammo, HashMaps/ArrayLists, Integers or names.
    I want a really simple way the is unique
    Any ideas? :)
     
  2. CraftCreeper6
    It depends on how you've structured your gun(?) and how you use it. Why don't you want to use those things you listed? How were you planning on doing it without them?
     
  3. Offline

    CraftCreeper6

    Assist
    There is no problem with using them, I just wanted a unique way and plus, I don't actually know how to get any of them fully functioning ;')
     
  4. CraftCreeper6
    Being unique is good, however if you're trying to be unique at creating ammo... I don't even know.

    As I said, it really depends on how you're using the guns, and whatever you prefer. Using inventory items as ammo would be good because there would be a clear visual indication of the ammo, but that's rather "restricted". Tell me which method you prefer and I'll try my best to explain it to you and perhaps provide some examples. :)
     
  5. Offline

    CraftCreeper6

    Assist
    I was thinking maybe levels. I have tried this before. However, the code was really messy and it didn't function very well :/
     
  6. CraftCreeper6
    That's a cool idea, and rather simple too. If you still have the code, could you show it to me so I can see what you tried, maybe we can improve it?
     
  7. Offline

    CraftCreeper6

    Assist
    Well, I did but my PC broke and I was unable to recover any files but I can try remake.
    Here is an example:
    Code:java
    1. //Set the ammo
    2. p.setLevel(p.getLevel() - 1);
    3. //Add ammo
    4. Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable(){
    5. @Override
    6. public void run(){
    7. p.setLevel(p.getLevel() + 1);
    8. }
    9. }, 0, 100);

    This was not coded in an IDE so if some of it is not even a method try and figure out what I mean xD
     
  8. CraftCreeper6
    I get what you're trying to do. I don't really see any problems with that. You'll just have to create player specific runnables (which you've already done, but not a very good way). I have to go now, but tomorrow I'll write you some example code and documentate (is that a word?) it so you know what's going on.

    In the mean time, you should try to improve it yourself if you can.
     
  9. Offline

    BeastCraft3

    CraftCreeper6
    I'm sorry but I dont really understand what you need help with. I know how to add ammo and remove ammo, I just dont know what you mean with set ammo :p My english isnt the best.
     
  10. Offline

    CraftCreeper6

  11. Offline

    BeastCraft3

    CraftCreeper6
    then I guess something like this: player.getInventory().addItem(new ItemStack(Material.CLAY_BALL));
    I used clayball as the "ammo"
     
  12. Offline

    CraftCreeper6

    BeastCraft3
    What would the best way to make multiple guns? :confused:
     
  13. Offline

    Yekllurt

    CraftCreeper6 You can create for each gun a HashMap<UUID, Integer> and then just set each time he shots the munition in his inventory to the amount of the integer
     
  14. Offline

    CraftCreeper6

    Yekllurt
    I am past ammo now but thanks for the idea :)
    What would the best way to make multiple guns? :confused:
     
  15. Offline

    Yekllurt

    CraftCreeper6 You coud do one item and check the name of the item and then chose like that a weapon or do for example that the lore is an rpg
     
  16. Offline

    BeastCraft3

    CraftCreeper6
    Add my skype: torbjorn.firered
    I could learn you the best way to make guns.
     
Thread Status:
Not open for further replies.

Share This Page