What it has in it:
Code:
-Hud Elements
-Hud Elem Functions
-Utility Functions (Get number of players, Get Host/Client name, Get Host Number, etc)
-SetClientDvar, iPrintln, iPrintlnBold
-All Client Dpad Button Handling
-Jetpack Mod
-onPlayerSpawned function
-Typewritter Text
I will teach you how to use it now. First add this under the includes:
Code:
using MW2Lib;
Next, where ever your connecting button is, add this:
Code:
Debug.Init();
How to spawn/create a hud element
Since these are Imcsx's hud elements, you're going to have to use HudElem_Alloc() for each element. To create a shader for all clients, this is how I do it.
Code:
//Add this in your form:
public static uint Elem1 = new uint[12];
//Add this function in (It's just a spawn hud function)
public static void CreateShaderElem(int client)
{
uint clientu = Convert.ToUInt32(client);
Elem1[client] = MW2.HudElemAlloc();//Inits the elem in memory
MW2.SetShader(clientu, Elem1[client], MW2.Material.Black, 140, 40, 80, 220, 0, 0, 0, 0, 0, 0, 0, 0);//Creates the elem - Alpha at 0
MW2.SetElement(Elem1[client], MW2.HudTypes.Shader);
}
And this is how to spawn either a text element or a typewritter elem
Code:
//Add these in your form:
public static uint Elem2 = new uint[12];
public static uint Elem2String = new uint[12];
public static void CreateTextElem(int client)
{
uint clientu = Conver.ToUInt32(client);
Elem2[client] = MW2.HudElemAlloc();
Elem2String[client] = MW2.G_LocalizedString("This is the text");//Creates text for elem
MW2.SetText(clientu, Elem2[client], Elem2String[client], 4, 1.7f, 15, 210, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0);
MW2.SetElement(Elem2[client], MW2.HudTypes.Text);
}
And spawning a typewritter text is the same exact way.
How to use ButtonHandling
USE THIS IS A TIMER OR BACKGROUND WORKER!!
Code:
if(Buttons.ButtonPressed(0, Buttons.Buttonz.DpadUp))
MW2.iPrintlnBold(0, "Client 0 is pressing Dpad Up");
if(Buttons.ButtonPressed(4, Buttons.Buttonz.Square))
MW2.iPrintlnBold(4, "Client 4 is pressing Square");
How to use Jetpack in a timer or background worker
Code:
if(Buttons.ButtonPressed(0, Buttons.Buttonz.Cross))
MW2.JetPack(0);// jet pack - client 0
if(Buttons.ButtonPressed(4, Buttons.Buttonz.Cross))
MW2.JetPack(4);//Jet pack - client 4
How to use onPlayerSpawned Function
Code:
//Add this in a backgroundworker or timer
MW2.onPlayerSpawned(0);//0 being the client it's monitoring, you can change.
And you can edit what you would like in the onPlayerSpawned function in the source code of the library.
How to use Hud Element Functions
There are many hud element functions in the library like MoveOverTime, FadeOverTime, ScaleOverTime, etc.
To use these just start by doing this. (I will use MoveOverTime as an example.)
Code:
//MW2.MoveOverTime(uint elem, Int32 time,float x, float y);
MW2.MoveOverTime(Elem1[0], 1, 500, 0);//Moves an element for client 0 to x - 500, y - 0 in 1 second
And most are similar to that sort of syntax.
Anyways... I hope this helps the few that still mod this game... yeah, thank you
Credits:
Code:
Imcsx - Elements, Sv_GameSendServerCommand
SC58 - Client_S
Mango - Addresses
Me - Button Handling, Custom Elements, and Element functions
Credit almightyso
Code:
-Hud Elements
-Hud Elem Functions
-Utility Functions (Get number of players, Get Host/Client name, Get Host Number, etc)
-SetClientDvar, iPrintln, iPrintlnBold
-All Client Dpad Button Handling
-Jetpack Mod
-onPlayerSpawned function
-Typewritter Text
I will teach you how to use it now. First add this under the includes:
Code:
using MW2Lib;
Next, where ever your connecting button is, add this:
Code:
Debug.Init();
How to spawn/create a hud element
Since these are Imcsx's hud elements, you're going to have to use HudElem_Alloc() for each element. To create a shader for all clients, this is how I do it.
Code:
//Add this in your form:
public static uint Elem1 = new uint[12];
//Add this function in (It's just a spawn hud function)
public static void CreateShaderElem(int client)
{
uint clientu = Convert.ToUInt32(client);
Elem1[client] = MW2.HudElemAlloc();//Inits the elem in memory
MW2.SetShader(clientu, Elem1[client], MW2.Material.Black, 140, 40, 80, 220, 0, 0, 0, 0, 0, 0, 0, 0);//Creates the elem - Alpha at 0
MW2.SetElement(Elem1[client], MW2.HudTypes.Shader);
}
And this is how to spawn either a text element or a typewritter elem
Code:
//Add these in your form:
public static uint Elem2 = new uint[12];
public static uint Elem2String = new uint[12];
public static void CreateTextElem(int client)
{
uint clientu = Conver.ToUInt32(client);
Elem2[client] = MW2.HudElemAlloc();
Elem2String[client] = MW2.G_LocalizedString("This is the text");//Creates text for elem
MW2.SetText(clientu, Elem2[client], Elem2String[client], 4, 1.7f, 15, 210, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 0);
MW2.SetElement(Elem2[client], MW2.HudTypes.Text);
}
And spawning a typewritter text is the same exact way.
How to use ButtonHandling
USE THIS IS A TIMER OR BACKGROUND WORKER!!
Code:
if(Buttons.ButtonPressed(0, Buttons.Buttonz.DpadUp))
MW2.iPrintlnBold(0, "Client 0 is pressing Dpad Up");
if(Buttons.ButtonPressed(4, Buttons.Buttonz.Square))
MW2.iPrintlnBold(4, "Client 4 is pressing Square");
How to use Jetpack in a timer or background worker
Code:
if(Buttons.ButtonPressed(0, Buttons.Buttonz.Cross))
MW2.JetPack(0);// jet pack - client 0
if(Buttons.ButtonPressed(4, Buttons.Buttonz.Cross))
MW2.JetPack(4);//Jet pack - client 4
How to use onPlayerSpawned Function
Code:
//Add this in a backgroundworker or timer
MW2.onPlayerSpawned(0);//0 being the client it's monitoring, you can change.
And you can edit what you would like in the onPlayerSpawned function in the source code of the library.
How to use Hud Element Functions
There are many hud element functions in the library like MoveOverTime, FadeOverTime, ScaleOverTime, etc.
To use these just start by doing this. (I will use MoveOverTime as an example.)
Code:
//MW2.MoveOverTime(uint elem, Int32 time,float x, float y);
MW2.MoveOverTime(Elem1[0], 1, 500, 0);//Moves an element for client 0 to x - 500, y - 0 in 1 second
And most are similar to that sort of syntax.
Anyways... I hope this helps the few that still mod this game... yeah, thank you
Credits:
Code:
Imcsx - Elements, Sv_GameSendServerCommand
SC58 - Client_S
Mango - Addresses
Me - Button Handling, Custom Elements, and Element functions
Credit almightyso