GoldenEye: Source Forums

  • April 24, 2024, 10:28:32 am
  • Welcome, Guest
Advanced search  


Pages: [1]   Go Down

Author Topic: [TUTORIAL] [BEGINNER] SourceMod  (Read 30774 times)

0 Members and 1 Guest are viewing this topic.


  • GES Plugin Coder
  • Secret Agent
  • **
  • Posts: 74
  • Reputation Power: 0
  • Anthony has no influence.
  • Offline Offline
« on: February 27, 2010, 06:33:40 am »

Hey guys,

This is my first of tutorials, just an explanation of the language syntax followed by a "Hello World!" :)

  • SourceMod plugins are compiled SourcePawn scripts. I actually created and somewhat actively support Superhero: Source and War3Source, which are both SourceMod plugins. The plugins are loaded with a SourceMM plugin called SourceMod. SourceMod provides native functions as well as an extensive extension interface. To compile a SourcePawn script:
    Windows: Open command prompt, press Start->Run and type "cmd" without quotes and press enter.
    cd C:/path/to/scripting/directory/
    spcomp.exe spscript.sp

    Linux: Open terminal.
    cd /home/user/path/to/scripting/directory/
    ./spcomp spscript.sp

    Please reference the following sites for more information: -
    Please be logical before asking questions about these instructions.

  • SourcePawn is a typeless 32-bit language. There are only a small amount of datatypes, which can be an advantage. Get to know Handle, Cell, String (BYTE), Float, and bool. Please watch for a future tutorial for a further explanation on these types and their abilities.

  • The Source Engine can be manipulated in various ways. For example, events are fired throughout gameplay. For example, if you were designing a plugin for logging statistics, you could listen on the event player_death to track the circumstances of the death. This will be touched on more in the event tutorial that I will one day right.

  • How do I write a SourcePawn script? What programs do I need?
    You don't need anything other than an operational Source Dedicated Server and a text editor. For advanced development, you can reference an extension tutorial to expand SourceMod with additional C++ interfaces. I probably won't write a tutorial on this any time soon unless there is a significant amount of interest. ( This can be expressed via the positive karma I will receive in comment form :P )
    As noted before, you need a text editor. You may experience issues if you aren't working with the UTF-8 format. I wouldn't worry much, I, however, personally recommend either Notepad++ or PSPad. I am not certain that either of these will run in Linux, but give it a shot.

  • Lets do this! What's next?
    What would a rookie tutorial be without a "Hello World!"?
    Open up the text editor of your choice and create the following file called helloworld.sp in the scripting directory:
Code: [Select]
#include <sourcemod> // This line tells the compiler (spcomp) to include all of the scripting inside of in the includes folder
// This line is a comment, as you can see from above this is denoted with a "//" preceding text that should be ignored by the compiler.

public OnPluginStart()
// In a string, which is a series of letters, the character '\' is treated as something called an escape character.
// The symbol that precedes the '\' denotes the type of escape sequence. When typing '\n' the compiler will see: Create new line. This is similar to the BR tag in HTML.
// Notice that the PrintToServer function AUTOMATICALLY adds an '\n' at the end of your input string, there is no need for one at the end.
PrintToServer("Hello world! \n Anthony is so nice, he wrote this crazy wicked tutorial for SourceMod plugins!");

Was that so hard? See the beginning of this tutorial and compile this bad boy. Drag the output file (helloworld.smx) into the plugins directory, located inside the sourcemod directory.
Restart your server and you will see this wonderful tutorial make you smile :)

Please ask questions or make comments within this thread. If your issue is SourceMod specific, but unrelated to this thread, feel free to create a thread in the correct sub-forum. Personal Messages are typically ignored unless they are just that... "personal."
I'm done. Enjoy.


  • Retired Developer
  • GE:S Fanatic
  • *****
  • Posts: 2,505
  • Reputation Power: 1
  • InvertedShadow has no influence.
  • Offline Offline
« Reply #1 on: March 02, 2010, 01:01:51 am »

That's pretty interesting, I hope people will jump up on this.


  • Agent
  • *
  • Posts: 1
  • Reputation Power: 0
  • faerachnidendro has no influence.
  • Offline Offline
    • Higher Dimensions Gaming
« Reply #2 on: September 06, 2015, 02:57:24 pm »

Excuse the necro, but I am pretty damn keen to get in on this...

Sourcemod and metamod installed, time to get some python hours under my belt, lua's gotten boring.
« Last Edit: September 07, 2015, 11:13:29 pm by faerachnidendro »
Pages: [1]   Go Up