Brand new
Hey everyone,
This is my first time to these forums and am going to make an attempt at learning amxx coding. I dont know anything about coding so i was wondering where the best place to start would be. If i learn enough im looking at major plugins in the far future. As i said im just looking for the best thing to start me off. Any help is appreciated. Savior |
I have a good mood so I decided to say all the basics here.
1) You should know what you are trying to do. This one is probably self explaining ;) 2) You can write plugins for AMXX in the Small(C) scripting language. If you want to read about the technical stuff, you will find it somewhere on http://www.compuphase.com/small.htm (the docs) 3) When you write a plugin in the SmallC language, save it as a .sma file. Then you have to compile it. The "compiler", that is the program that compiles your plugin, checks whether the syntax of what you wrote is correct, and checks the language grammar and stuff. Then it generates something that is easy for AMXX to load and run (a .amxx file). You can not turn a .amxx file back to a .sma file without a lot of skill, effort and guessing, so better keep your sma files in a safe place. 4) Let's start with an example plugin: Code:
If you copy-and-paste this into a new .sma file, save it in the scripting subdirectory of your AMXX tree, run amxxsc.exe filename.sma , it should produce filename.amxx, which you can put into the plugins directory and add into plugins.ini as usual. Let's examine what the plugins does: The compiler skips blank lines. So the first actual line is #include <amxmodx> This basically tells the compiler what is possible and what not in the world of AMXX. The next line is Code:
The next line is: Code:
Ok, this plugin should only load and do nothing. So, let's add something funky: We want it to print "Hello world!" on load!!! (elite) So, the command to print something into AMXX's logs is log_amx. We can try to add: Code:
Code:
Ok, we have a plugin that logs something. But that's still pretty boring. We should try to make some fun of some players! Let's say, we want a plugin that tells the players all the time that they can have god mode if they write something into the console. Let's say, every minute. But when they write the command, it kills them! MWAHAHAHAH! Ok, let's start like this again: Code:
Code:
Code:
It start's with a /* . This tells the compiler that it should ignore everything, until it finds a */ . Ok, so the compiler doesn't see the code until the line native set_task(blablabla); . So what's it for? It tells the human readers what the function does. It's a so called comment. There are two kinds of comments: multi-line comments and single-line comments. The /* stuff */ comment is a multi line comments. The more common comment is the other one: Code:
Code:
1) Float:time Float: tells the compiler that the parameter is not a whole number. We will talk about this later. the next parameter is const function[] . This is a string parameter. You can pass text to it, not only numbers. const tells the compiler that the function does not modify the parameter, and [] indicates the string property in this case. Let's ignore the next 3 parameters, and go to flags: flags[]="" . This is also a string. The const is lacking, but the function does not modify it anyway, someone forgot the const, although it's actually not needed at all. Anyway, this has to be a string parameter again because there is [] . What is ="" ? It tells the compiler that if you don't specify the parameter, the default value will be "", which is an empty string. So, what does this parameter do? Let's look at the comment again. It specifies the behaviour of the task. Ok, let's forget about this, and return to our plugin: We did: Code:
We set the last parameter to "b". In the set_task comment, it says, that "b" is a looping task. So it goes on forever. Ok, so now, we have made a task that is called every minute. But, what does it do? It calls the show_message function. So, we need to write it! Code:
Let's add this to the end of plugin_init (before the } and after set_task): Code:
Ok, so AMXX will want to call the gimme_god function.. So what will we need? Exactly, to write a public function! Code:
So the plugin should look like this in the end: Code:
Ok, this was a mini tutorial, I have done my best, but I want to stop now and I hope you have understood something :D Also, I haven't tested this, so I'm not 100% sure whether it works. You can find more here: http://amxmodx.org/doc/ under the Scripting Tutorial section. :D :D :D Good luck :D :D :D |
Thanks for your time PM, your tutorial will be put to great use :)
|
On another note where can i get every command from?
Also, Am i allowed to open up other peoples amx scripts and read them and try incorporate it into my own, and give credit to the original author? |
here you can get the functions:
http://amxmodx.org/funcwiki.php further more they're declared in the includes as well (\addons\amxmodx\scripting\include\) and yes, you can read and use other people's plugins as a reference, but you have to mention the original authors. |
|
Avalanche posted a nice link but you might also want to search "Scripting Tutorial" and you will find some other nice ones.
|
erhm... stickey has the link to the tutorials :D
|
Yea but trust me , there are some that were not posted. I read them myself when I started scripting. But I guess it doesn't matter , you can just search google for some Small tutorials.
|
.sma
I like the Tutorial Help..its awsome, just cant figure out how to create a .sma file :?: well plz post reply thanks
|
| All times are GMT -4. The time now is 19:17. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.