[Tutorial] Using CodeBlocks for PAWN files

Before I begin, make sure you make backups, and track what you do in here. Even though this may look to work, it will have problems if you look at it hard enough. If it causes you trouble, start over. Best bet in many cases.

The language it's using isn't actually PAWN, but it's very close, close enough that it "works". Most people won't notice this but hardcore nit-pickers will notice it.

What this does though is it parses the files in it's projects and can read them to enable the code completion. When you do projects, add all the includes as well to it, and you'll see them all coming up with code completion, but you will also notice some garbage in these, but you'll know which is what and where you should be using whichever.

Download CodeBlocks.


You'll also want to ensure you have the mingw and WxWidget dll requirements from those pages as well.

Once you've installed CodeBlocks, you want to go into the Settings menu, and into Editor. Under this window the first thing you are going to do is go to Syntax Highlighting, Select "Syntax Highlighting for" PASCAL... click filemasks.

In here, remove the
that is in there. This allows for us to hijack *.inc for Pawn, as if we don't do this, PASCAL language highlighting and structure will be default for it.

Now, in that dropdown for "syntax highlighting for", find the "C\C++" selection, and in there under filemasks, add in
*.pwn, *.inc,
Now, on the left in this settings window, scroll down to Code Completion and in "File Extensions to parse as source files" put
Now you are set to make a project, which is the main benefit to this method.

Go File, New, Project. In the next window, select Empty Project, and set the folder to create it in, to your local machines server folder, the one where you use pawncc from. Do it to the folder that the samp-server.exe is in as if you choose anything out of the folder, the tree in the project window will become INCREDIBLY messy.

In there where it says about the compiler, set to No Compiler (It's right at the bottom, and it may complain, just ignore the warnings). Uncheck debug, leave release checked.

Now, in the window, where you come to, to the left there will be "Workspace" with your project under it.

You can have multiple projects open at once, but for learning, stick to the one. This will affect the code completion if you have multiple projects open.

Now, right click workspace, and click Categories and Filetypes. In here, we'll be adding in the various file extensions to be used.

I use Scripts down the bottom for PWN files, and Resources for includes so I can find them easier.

Add *.pwn; to scripts filemasks.

Add *.inc; to resources filemasks.

Right, so now you're ready to add files to your project. You can either select individual files (Which is actually a good idea for beginning) or do recursive additions.

I'd add your gamemode, and your prized filterscripts manually, then add in the includes folder via recursive.

You should now have something resembling this.

As you can see the gamemodes includes and all the rest are neatly arranged and all ready to start opening in multiple tabs edditing with code completion and basic features.

Under Symbols you can find various functions, when you double click on them you will be taken to their section in the file that is selected.

Definitions (Being #Define) turn up in the symbols browser, and are also used by code completion.

So there you have it, CodeBlocks, setup for PAWN. It doesn't compile, but it could... When I was setting NGG up, I had it capable of compiling, and I seem to think it was from the "Other Compiler" option, but it was so long back, and being that compiling really is a secondary purpose, it wasn't needed when using this for it's multiple windows option.

I don't think it's to do with
Goto "Settings->Compiler...->Global compiler settings->*No Compiler*->Toolchain executables" and fix the compiler's setup.
I'm sure it was a flakey method I used to simply "set" the compiler to pawncc with the executable options and the output simply being returned to the window.

Further info
When you exit, CodeBlocks will say it needs to save everything, mainly the project file, but will say about the default layout as well. Save them all.

The file browser will show which files aren't saved by having an exclamation mark next to those who aren't saved.

What I do to have a compiler is simply to have the gamemode/filterscript I am working on, open in pawno sitting in the background and reopening the file and compiling each time I am checking it.

Future additions
If anyone can figure out how to get the compiler working in this again it would be much appreciated, and would be added to the tutorial with credit given for whoever does figure it out. It does work, as all it does is compiles and puts out the errors and information to the output window, which, when you have an error and you have a line reference, if you double click on the line in the compiler output it will put you at that line.

If anyone needs help with anything, or to contribute anything they have found, don't hesitate to drop a line here...

Useful can i do the same in visual studio?

Originally Posted by Sreyas
View Post
Useful can i do the same in visual studio?
From what I've read you can, but it requires more work, in particular you have to make a language file which takes compiling or something stupid.

I always ended up choosing CB because of it's size and ability to be portable.

Like, 100mb, over 1.5 gigs.

Woah nice, should use this rather than notepad++ seems more organized. Nice tutorial!

Originally Posted by Sew_Sumi
View Post
From what I've read you can, but it requires more work, in particular you have to make a language file which takes compiling or something stupid.

I always ended up choosing CB because of it's size and ability to be portable.

Like, 100mb, over 1.5 gigs.
My Visual Studio package has about 50GB ... (including all the packages it needed )

Thanks for the tutorial tho!

Hmm, seems to be way more organized than pawno.

Nice tut.

Forum Jump:

Users browsing this thread: 1 Guest(s)