ItsMods

Full Version: No ammo for secondary
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hey,

Made by request.
No ammo for secondary weapon. ( Useful for sniper servers ).

SOURCE
Code:
using Addon;
using System.Collections.Generic;
namespace noammo
{
    public class noammos : CPlugin
    {
        public override void OnAddonFrame()
        {
           // to prevent errors
            List<ServerClient> clients = new List<ServerClient>();
            if (clients != null && clients.Count > 0)
            {
                foreach (ServerClient cl in GetClients())
                {
                    if (cl != null)
                    {
                        cl.Ammo.SecondaryAkimboAmmo = 0;
                        cl.Ammo.SecondaryAmmo = 0;
                        cl.Ammo.SecondaryAmmoClip = 0;
                    }
                }
            }
        }
    }

}
[attachment=2250]

Credits:
@jaydi - coded
@ALEXFDR - idea
(09-08-2012, 23:27)JayDi Wrote: [ -> ]Hey,

Made by request.
No ammo for secondary weapon. ( Useful for sniper servers ).
Credits:
@jaydi - coded
@ALEXFDR - idea

it didn't work, sry, btw i coped the game folder into my desktop and opened the server but it doesnt show on the server list, is it because i copied the folder or because something else.

tkx in advance.
How could it not? The code is flawless.
You did put the plugin inside your addon folder? And are you using the lastest MW3 Server Addon, the one updated by @zxz0O0
Ohh my fault i compiled that in net 4.0
I will re-upload now.
Sorry.

EDIT: It's fine now.
(09-08-2012, 23:27)JayDi Wrote: [ -> ]
Code:
List<ServerClient> clients = new List<ServerClient>();
            if (clients != null && clients.Count > 0)
To prevent what error also as pointed out by @zxz0O0 it will never execute
It will give error like "Object is undefined".
I will say the whole code is messed, try this
CSHARP Code
  1. using Addon;
  2. using System.Collections.Generic;
  3.  
  4. namespace nope
  5. {
  6. public class Class1:CPlugin
  7. {
  8. public override void OnPlayerSpawned(ServerClient cl)
  9. {
  10. if(cl.Other.SecondaryWeaponAkimbo == true)
  11. cl.Ammo.SecondaryAkimboAmmo = 0;
  12. cl.Ammo.SecondaryAmmo = 0;
  13. cl.Ammo.SecondaryAmmoClip = 0;
  14. }
  15. }
  16. }

If no-one has ammo on spawn, they won't have it ever
(09-09-2012, 13:43)archit Wrote: [ -> ]I will say the whole code is messed, try this
CSHARP Code
  1. using Addon;
  2. using System.Collections.Generic;
  3.  
  4. namespace nope
  5. {
  6. public class Class1:CPlugin
  7. {
  8. public override void OnPlayerSpawned(ServerClient cl)
  9. {
  10. if(cl.Other.SecondaryWeaponAkimbo == true)
  11. cl.Ammo.SecondaryAkimboAmmo = 0;
  12. cl.Ammo.SecondaryAmmo = 0;
  13. cl.Ammo.SecondaryAmmoClip = 0;
  14. }
  15. }
  16. }

If no-one has ammo on spawn, they won't have it ever

What if player will pick ammo?
Also my code is working. I tested it.
No one ever had secondary weapon ammo,how will someone drop it so he can pick it?
Pages: 1 2