-GodOfWar- (11-12-2012),hacktaodachethet (11-19-2012),MKENYON401 (01-11-2013),montyx (01-17-2015),mwxplayer (11-12-2012),samio1997 (11-16-2012),SLiiTH3R (01-10-2013)
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.Code:using System; using System.Collections.Generic; using System.Linq; using System. IO; using InfinityScript; using System.Text.RegularExpressions; using System.Collections; using System.Runtime.InteropServices;
Ok now this little code:
Oh lovely. Now let's make it uglyCode:namespace YourProjectNameHere { public class Class1 { } }
We gotta inherit from BaseScript (just as when we used Nukem's addon we inherited from CPlugin)
Sooo....
We're gonna get dirty with our class now. (Sex pun? Or is my mind really that immature?)Code:namespace UnlimitedAmmo { 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.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?Code://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. if(EntityReturn.Contains(player.GetField<string>("name"))) return false; //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); player.Call("givemaxammo", offhandAmmo); //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 return true; }
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:Code: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!Code: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. }); //Final brace } //Now close the method }
Credits: DidUKnowiPwn
Last edited by Kenshin13; 11-11-2012 at 11:29 PM.
-GodOfWar- (11-12-2012),hacktaodachethet (11-19-2012),MKENYON401 (01-11-2013),montyx (01-17-2015),mwxplayer (11-12-2012),samio1997 (11-16-2012),SLiiTH3R (01-10-2013)
Lolz, my code is now this (not yet done)Code:using System; using System.Collections.Generic; using System.Linq; using System.Text; using InfinityScript; using System.Text.RegularExpressions; using System.Collections; using System.Runtime.InteropServices; namespace Ammo { public class Ammo : BaseScript { public List<string> EntityReturn = new List<string>(); } {<< THIS ONE IS GIVVING ME A ERROR, a namespace cannot directly contain such as field or methots //Remember the list we created earlier? Here's where we check if a false entity was passed. We check the name against null. if(EntityReturn.Contains(player.GetField<string>("name"))) return false; //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); player.Call("givemaxammo", offhandAmmo); //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 return true; }
but look good, i make my error big and typed the reason what it says
help please
idiot..
you don't a constructor in the class
---------- Post added at 04:48 AM ---------- Previous post was at 04:43 AM ----------
For Copy & Pasters
Code:using System; using System.Collections.Generic; using System.Linq; using System.Text; using InfinityScript; using System****; namespace test { public class Class1 : BaseScript { public List<string> EntityReturn = new List<string>(); public bool SetAmmo(Entity player, int amtOfAmmo) { if (EntityReturn.Contains(player.GetField<string>("name"))) return false; var Currwep = player.CurrentWeapon; var offhandAmmo = player.Call<string>("getcurrentoffhand"); player.Call("setweaponammoclip", offhandAmmo, amtOfAmmo); player.Call("givemaxammo", offhandAmmo); player.Call("setweaponammoclip", Currwep, amtOfAmmo); player.Call("setweaponammoclip", Currwep, amtOfAmmo, "left"); player.Call("setweaponammoclip", Currwep, amtOfAmmo, "right"); return true; } public Class1() { PlayerConnected += new Action<Entity>(PLAYERx => { PLAYERx.SpawnedPlayer += new Action(() => { OnInterval(10, () => SetAmmo(PLAYERx, 99)); }); }); } } }
Srry, lol i JUST got C#,
And im just 12years old. Like you can do everything just you got c#/c++
But thanks for reply!
Here's the direct code for those noobs that make other noobs seem like experts:
Code:using System; using System.Collections.Generic; using System.Linq; using System. IO; using InfinityScript; using System.Text.RegularExpressions; using System.Collections; using System.Runtime.InteropServices; namespace UnlimitedAmmo { public class Unlimited_Ammo : BaseScript { public List<string> EntityReturn = new List<string>(); //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. if(EntityReturn.Contains(player.GetField<string>("name"))) return false; //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); player.Call("givemaxammo", offhandAmmo); //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 return true; } 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. }); //Final brace } //Now close the method } } }
Last edited by Kenshin13; 01-09-2013 at 05:59 PM.
Kenshin13 (01-10-2013)