• 3 Vote(s) - 4.33 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Release [CODE][TUT]Boxes
#1
I made this tutorial for @SaviouR9966 and offcourse any other people who needs it
Well most of the people know this info already, but for the new people:
I made some basic commands to help you making carepackage boxes.
First of all the basics on making a plugin:
1 Make a new project in visual studio.
2 Make 2 classes, Extensions.cs and Boxes.cs
3 Copy and paste the code from this to extensions.cs topic made [email protected]master131
4 Put those parts of code in Boxes.cs
Code:
using System;

using Addon;

namespace Addon
{
    public class Boxes : CPlugin // Always use : CPlugin behind your class name
    {

Add the even onchatsay to make some usefull commands for making boxes.
Code:
public override ChatType OnSay(String Message, ServerClient Client, bool Teamchat)
        {

Than add the chatcommands :
Code:
if (Message == "!noclip") // This will let you fly through walls
            {
            Client.Other.NoClip = !Client.Other.NoClip; // Smart code from koro35
            return ChatType.ChatNone;

            }
            if (Message == "!pos") // This will let you fly through walls
            {
             ServerPrint(Client.Name + "is on the position X: " + Client.OriginX + " Y: " + Client.OriginY + " Z: " + Client.OriginZ); // Serverprints the coords
             TellClient(Client.ClientNum, "You are on the position X: " + Client.OriginX + " Y: " + Client.OriginY + " Z: " + Client.OriginZ, true); // Send a message to client
            return ChatType.ChatNone;
            }
        }//This will end the event

Than add the event OnMapChange.
Code:
public override void OnMapChange() // The event OnMapChange
        {
Add this line of code to make a string called map
Code:
string map = GetDvar("mapname");
Than add your map you want
Code:
if (map == "mp_dome") // In this case I use dome to close the stairs to the dome
Now place the boxes code.
Code:
{
                Entity domeleft = SpawnModel("script_model", "com_plasticcase_trap_friendly", new Vector(462f, 108f, -220f)); //Creates an entity named domeleft and spawns a model on the coordinates 462f, 108f, -220f
                Entity domeright = SpawnModel("script_model", "com_plasticcase_trap_friendly", new Vector(-373f, -103f, -220f)); //Creates an entity named domeright and spawns a model on the coordinates -373f, -103f, -220f
                Extensions.CloneBrushModelToScriptModel(domeleft, Extensions.FindAirdropCrateCollisionId()); // Makes the entity domeleft solid
                Extensions.CloneBrushModelToScriptModel(domeright, Extensions.FindAirdropCrateCollisionId()); // Makes the entity domeright solid
            }
        }
    }
}
Be sure to place the } when needed (Everytime you open one, you also have to close it)

5 Save the project
6 Go to Project > <yourprojectname> properties
7 Click on Application.
8 Set the Netwerk framework to 3.0
9 Than compile it
USEFULL FOR COMPILING:
http://www.itsmods.com/forum/Thread-How-...noobs.html

Final code if you or me did something wrong:
Code:
using System;

using Addon;

namespace Addon
{
    public class Boxes : CPlugin // Always use : CPlugin behind your class name
    {
        public override ChatType OnSay(String Message, ServerClient Client, bool Teamchat)
        {
if (Message == "!noclip") // This will let you fly through walls
            {
            Client.Other.NoClip = !Client.Other.NoClip; // Smart code from koro35
            return ChatType.ChatNone;

            }
if (Message == "!pos") // This will let you fly through walls
            {
             ServerPrint(Client.Name + "is on the position X: " + Client.OriginX + " Y: " + Client.OriginY + " Z: " + Client.OriginZ); // Serverprints the coords
             TellClient(Client.ClientNum, "You are on the position X: " + Client.OriginX + " Y: " + Client.OriginY + " Z: " + Client.OriginZ, true); // Send a message to client
            return ChatType.ChatNone;
            }
} // This } will end the event

        public override void OnMapChange() // The event OnMapChange
        {
            string map = GetDvar("mapname");
            if (map == "mp_dome") // In this case I use dome to close the stairs to the dome
            {
                Entity domeleft = SpawnModel("script_model", "com_plasticcase_trap_friendly", new Vector(462f, 108f, -220f)); //Creates an entity named domeleft and spawns a model on the coordinates 462f, 108f, -220f
                Entity domeright = SpawnModel("script_model", "com_plasticcase_trap_friendly", new Vector(-373f, -103f, -220f)); //Creates an entity named domeright and spawns a model on the coordinates -373f, -103f, -220f
                Extensions.CloneBrushModelToScriptModel(domeleft, Extensions.FindAirdropCrateCollisionId()); // Makes the entity domeleft solid
                Extensions.CloneBrushModelToScriptModel(domeright, Extensions.FindAirdropCrateCollisionId()); // Makes the entity domeright solid
            }
        } // This will end the event
    }
}

If you have any questions just ask.

EDIT:
Usefull code made by @8q4s8
Place this code:
Code:
int ent = 0;
float locationX = Client.OriginX;
float locationY = Client.OriginY;
float locationZ = Client.OriginZ;

After this :
Code:
public class Boxes : CPlugin // Always use : CPlugin behind your class name
    {


Put this on the event OnSay:
Code:
if (Message.ToLower().StartsWith("!box"))
            {
                Entity entdefault = SpawnModel("script_model", "com_plasticcase_trap_friendly", new Vector(locationX, locationY, locationZ));
                Extensions.CloneBrushModelToScriptModel(entdefault, Extensions.FindAirdropCrateCollisionId());
                ent++;
                ServerPrint("Entity ent" + ent + " = SpawnModel(" + "script_model" + "," + "com_plasticcase_trap_friendly" + "," + "new Vector(" + locationX + "f" + "," + locationY + "f" + "," + locationZ + "f" + "))" + ";");
                Client.OriginZ += 40f;
                return ChatType.ChatNone;
            }
else if (Message.ToLower().StartsWith("!ent")) // this is for changing the entity number if you restarted the server or placed a box in the wrong location
            {
                string[] split = Message.Split(' ');
                try
                {
                    ent = int.Parse(split[1]);
                }
                catch
                {
                    return ChatType.ChatContinue;
                }
            }

Writing it to a text file made by @8q4s8 thanks <3
Code:
string map = GetDvar("mapname");
StreamWriter writer = new StreamWriter("C:\\Mw3\\Entity\\" + map + ".txt", true);

                    writer.WriteLine("Entity ent" + ent + " = SpawnModel(" + "script_model" + "," + "com_plasticcase_trap_friendly" + "," + "new Vector(" + locationX + "f" + "," + locationY + "f" + "," + locationZ + "f" + "))" + ";");
                    writer.Dispose();
                    writer.Close();
[Image: b_560_95_1.png]
[Image: hax0r3ez.gif]
[-] The following 6 users say Thank You to 99IRock for this post:
  • 8q4s8, EnVi Sweden Rocks, hillbilly, ltybcs, narkos, SaviouR9966
  Reply
#2
(01-08-2013, 18:44)99IRock Wrote: 1 Make a new project in visual studio.
2 Make 2 classes, Extensions.cs and Boxes.cs
3 Copy and paste the code from this topic made [email protected]master131
4 Put those parts of code in Boxes.cs


If you have any questions just ask.

with the code from step 3: which code there will i copy to the Boxes.cs?
i´m an newbie Tongue
  Reply
#3
Please fix TABs
C++/Obj-C developer. Neko engine wip
Steam: Click
  Reply
#4
Hi!

I don't understand a thing, why there is
CSHARP Code
  1. <img src="images/smilies/smile.gif" style="vertical-align: middle;" border="0" alt="Smile" title="Smile" />


in the comments.... what is this for? It does something in VS? or it is for fun?

Anyway thx for the tut!
  Reply
#5
(01-08-2013, 19:11)narkos Wrote: Hi!

I don't understand a thing, why there is
CSHARP Code
  1. <img src="images/smilies/smile.gif" style="vertical-align: middle;" border="0" alt="Smile" title="Smile" />


in the comments.... what is this for? It does something in VS? or it is for fun?

Anyway thx for the tut!

Lol I think I was doing something with a website or something.
Thanks for reacting, I will remove it Smile
EDIT
It was a smiley it was just Smile , but it showed like that <img src="images/smilies/smile.gif" style="vertical-align: middle;" border="0" alt="Smile" title="Smile" /> ..
but I removed it thanks
narkos Wrote:with the code from step 3: which code there will i copy to the Boxes.cs?
i´m an newbie
Thanks I forgot it to place it.
I edited it.
Place it in the class extensions.cs Wink
[Image: b_560_95_1.png]
[Image: hax0r3ez.gif]
[-] The following 1 user says Thank You to 99IRock for this post:
  • EnVi Sweden Rocks
  Reply
#6
Nice tut, also very useful is this:

CSHARP Code
  1. if (Message.ToLower().StartsWith("!box"))
  2. {
  3. Entity entdefault = SpawnModel("script_model", "com_plasticcase_trap_friendly", new Vector(locationX, locationY, locationZ));
  4. Extensions.CloneBrushModelToScriptModel(entdefault, Extensions.FindAirdropCrateCollisionId());
  5. ent++;
  6. ServerPrint("Entity ent" + ent + " = SpawnModel(" + "script_model" + "," + "com_plasticcase_trap_friendly" + "," + "new Vector(" + locationX + "f" + "," + locationY + "f" + "," + locationZ + "f" + "))" + ";");
  7. Client.OriginZ += 40f;
  8. return ChatType.ChatNone;
  9. }
  10. else if (Message.ToLower().StartsWith("!ent")) // this is for changing the entity number if you restarted the server or placed a box in the wrong location
  11. {
  12. string[] split = Message.Split(' ');
  13. try
  14. {
  15. ent = int.Parse(split[1]);
  16. }
  17. catch
  18. {
  19. return ChatType.ChatContinue;
  20. }
  21. }

CSHARP Code
  1. int ent = 0;
  2. float locationX = Client.OriginX;
  3. float locationY = Client.OriginY;
  4. float locationZ = Client.OriginZ;


You can build your bunkers ingame and copy/paste the console into your plugin.
I hope this will help some people

EDIT: tell me if someone want the ServerPrint write to a text file.
[-] The following 1 user says Thank You to 8q4s8 for this post:
  • 99IRock
  Reply
#7
(01-08-2013, 19:04)SailorMoon Wrote: Please fix TABs
Please click the thank you button Troll
Anyways I will fix it now :p
[Image: b_560_95_1.png]
[Image: hax0r3ez.gif]
  Reply
#8
(01-08-2013, 19:23)8q4s8 Wrote: Nice tut, also very useful is this:

CSHARP Code
  1. if (Message.ToLower().StartsWith("!box"))
  2. {
  3. Entity entdefault = SpawnModel("script_model", "com_plasticcase_trap_friendly", new Vector(locationX, locationY, locationZ));
  4. Extensions.CloneBrushModelToScriptModel(entdefault, Extensions.FindAirdropCrateCollisionId());
  5. ent++;
  6. ServerPrint("Entity ent" + ent + " = SpawnModel(" + "script_model" + "," + "com_plasticcase_trap_friendly" + "," + "new Vector(" + locationX + "f" + "," + locationY + "f" + "," + locationZ + "f" + "))" + ";");
  7. Client.OriginZ += 40f;
  8. return ChatType.ChatNone;
  9. }
  10. else if (Message.ToLower().StartsWith("!ent")) // this is for changing the entity number if you restarted the server or placed a box in the wrong location
  11. {
  12. string[] split = Message.Split(' ');
  13. try
  14. {
  15. ent = int.Parse(split[1]);
  16. }
  17. catch
  18. {
  19. return ChatType.ChatContinue;
  20. }
  21. }

CSHARP Code
  1. int ent = 0;
  2. float locationX = Client.OriginX;
  3. float locationY = Client.OriginY;
  4. float locationZ = Client.OriginZ;


You can build your bunkers ingame and copy/paste the console into your plugin.
I hope this will help some people

how can i make this as an plugin? and this:
CSHARP Code
  1. int ent = 0;
  2. float locationX = Client.OriginX;
  3. float locationY = Client.OriginY;
  4. float locationZ = Client.OriginZ;
is it something i can copy in the sv_config?
  Reply
#9
Noo Tongue, look In my topic at the lower bottom I expained it (where to place it)
place it after
CSHARP Code
  1. public class Boxes : CPlugin // Always use : CPlugin behind your class name
  2. {


@8q4s8 I would like to have that Smile
[Image: b_560_95_1.png]
[Image: hax0r3ez.gif]
  Reply
#10
@99IRock added it to main post there you see where you have to place it and you should maybe watch this tutorial.
Also don't forget to compile it with .NET framework 3.0

http://www.itsmods.com/forum/Thread-How-...noobs.html

he was faster Sad
  Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  Help Code color crosshairs koren30 3 1,676 10-02-2013, 19:26
Last Post: koren30
  Help need help?how to make plugins code hXnarutoXone 12 3,187 09-01-2013, 18:30
Last Post: Bandarigoda123
  Help Need Help with C# code tubwux 2 1,414 08-27-2013, 18:18
Last Post: tubwux
  [Request] Compile this code please dozsa0 4 1,692 08-10-2013, 21:02
Last Post: Nukem
  Compile this code please First_Semyon 12 3,608 08-08-2013, 14:53
Last Post: Bandarigoda123
  Compile please this code First_Semyon 8 2,223 07-28-2013, 01:52
Last Post: First_Semyon
  [Release] Interactive Boxes Yamato 1 1,105 06-29-2013, 18:20
Last Post: DidUknowiPwn
  Code of vector Bloodfocus 1 893 06-23-2013, 11:54
Last Post: Yamato
  Help boxes [HARD] Tony. 3 934 05-16-2013, 18:29
Last Post: DidUknowiPwn
  problem with gsc code CheGuevara 5 1,805 04-20-2013, 15:06
Last Post: Nekochan

Forum Jump:


Users browsing this thread: 1 Guest(s)