• Welcome to ForumKorner!
    Join today and become a part of the community.

Sourcepawn TUT 1

kehran

User is banned.
Reputation
0
First off, what the heck is sourcepawn?
Pawn is a scripting language used to embed functionality in other programs. That means it is not a standalone language, like C++ or Java. And SourcePawn is the version of Pawn used in SourceMod such as CSS.

Second, what must i have to code in sourcepawn?
well, you wont need much, a simple text editor, i suggestion notepad++, and a compiler, which i will provide below.

Programs:
Notepad++
Compiler (Web based)

Now that we know what sourcepawn is and what it is used for we can continue. Lets not break the tutorial Tradition and start with the "Hello World" plugin.

first open the text editor of your choice, im going to use notepad++. In notepad++ go to file, then new. it should open a new blank page. On this blank page we will right the code.

Code:
#include <sourcemod> // This line includes all of the scripting inside sourcemod.inc when compiled
//note anything with //infornt is marked as a comment and is not included in the code

//this is our first real coding below, it just give info on the plugin, who made it, the name, ect
public Plugin:myinfo = 
{
	name = "Hello World!",
	author = "Epicity",
	description = "Tutorial #1",
	version = "1.0",
	url = "http://thediscussionzone.com"
}

//this says when the plugin starts or loads, do the following.
public OnPluginStart()
{
// This creats the command hello, ingame you would type /hello, or !hello
	RegConsoleCmd("hello", HelloWorld); //the second part you see is HelloWorld after a comma, this is used for things such as public action.
}

public Action:HelloWorld(client,args) //see this is the public action, its basically saying, take the command !hello from above, and when its executed, do the following.
{ // "\n" is basically a line break.
	PrintToChatAll("Hello world! \n This is my first SourcePawn plugin!") //this is saying when !hello is executed, the plugin will print to chat what ever is inside the quotes (viewable by everyone)
	return Plugin_Continue;
}

now all you need to do is compile this, and place it in the plugin folder of you server, now when you type !hello or /hello ingame it will say what you placed inside the quotes :)
 

tehexmen

Member
Reputation
0
Hah, nice find. There is also pawn for SA:MP. It's actually a C++, only modificatedor something... I coded few servers with SA:MP Pawn last summer
 

GameOver

User is banned.
Reputation
0
Great work, nice tutorial. Thanks for share! Keep working.
 
Top