Simply because I was so bored, I decided to show you guys this for those who didn't know.
Visual C# is required and you must have some basic knowledge of the language.
Ok so make a new C# project. Class Library is our thing and .NET Framework's gonna be 4.0 so go ahead and select that. Type in your project's name etc.
Before we continue, let's add the InfinityScript.dll to the references now:
Solution Navigator -> References -> Right Click -> Add Reference -> File Name -> Browse -> Select "InfinityScript.dll" -> Add -> Close.
Now you should see pretty empty looking code..
We now need to include it in our file. So we use "using InfinityScript;" at the top of the file where all the "using"s are.
So your file should look like thisOr somewhat close)
Obviously I added some stuff...So you may add them too.
using System. IO;
Ok now this little code:
Oh lovely. Now let's make it ugly
public class Class1
We gotta inherit from BaseScript (just as when we used Nukem's addon we inherited from CPlugin)
We're gonna get dirty with our class now. (Sex pun? Or is my mind really that immature?)
public class Unlimited_Ammo : BaseScript
We're gonna add a little check for the player name and a function to add the ammo to a player, which from here-on-out will be referred to an "Entity" inside our class.
So now we create a list and a function as follows:
I just realized I need to further explain the following code.
//Create a list to store the player names.
public List<string> EntityReturn = new List<string>();
Ok so in InfinityScript there's a class called "Entity" which basically holds the player's data. Now an "Entity" can not only refer to players alone but objects as well. If you ever dug around in source code for ESPs or Aimbots you'd see they have entities too.
So now we can create a function which holds an entity like so:
Awesome now we gotta actually set the ammo as a player is spawed right?
//Making a boolean function, can be anything but for this case, we'll use bool.
//The parameters are in the format Entity ThePlayer, int AmountOfAmmoTOSetToPlayer.
public bool SetAmmo(Entity player, int amtOfAmmo)
//Remember the list we created earlier? Here's where we check if a false entity was passed. We check the name against null.
//Now let's set up the ammo adding. Remember our passed entity's name is "player"
//Let's get the current and offhand ammo for unlimited grenades also.
var Currwep = player.CurrentWeapon;
var offhandAmmo = player.Call<string>("getcurrentoffhand");
//Now we'll use the "Call" operator to set the ammo amount we passed to the offhand ammo.
player.Call("setweaponammoclip", offhandAmmo, amtOfAmmo);
//Now the same for the current weapon:
player.Call("setweaponammoclip", Currwep, amtOfAmmo);
player.Call("setweaponammoclip", Currwep, amtOfAmmo, "left");
player.Call("setweaponammoclip", Currwep, amtOfAmmo, "right");
//And we return true to indicate the operation was sucessful
To do this we use an awesome little setup InfinityScript uses. We call a certain part of the program as it loads.
This is the format:
So we add this to the class (Well for my class, change yours to the class name:
public ClassName() : base
And that's it! Your code should fully compile now. Add it the the "scripts" folder and it will auto-execute every time you start your server!
public Unlimited_Ammo() : base
//So here's where we check is a player has connected and create a new action to do as they are. Gotta love threads right? :P
//It's gonna take the Entity(player) as it's parameter and do a specific action on that entity.
PlayerConnected += new Action<Entity>(PLAYERx =>
//Here's where we do the action, ik it looks weird but you'll learn to love it. We add another action that happens when they're spawned
PLAYERx.SpawnedPlayer += new Action(() =>
//We'll use OnInterval which creates a thread that executes ever X ms on the player
OnInterval(10, () => SetAmmo(PLAYERx, 99));
//Close the braces now.
//Now close the method