View Single Post
Author Message
LynX
Veteran Member
Join Date: Oct 2004
Old 10-19-2004 , 09:54   Amx Mod X scripting tutorial
Reply With Quote #1

Well, this is my tutorial on scripting plugins for Amx Mod X.
I made this tutorial to make a life easier for n00bs who are
just getting used to small and amx mod x. Now, let's get going:


To make an plugin, just create a new document (preferably notepad or wordpad document),
and change his extension to .sma file. That's it. After that, open i. Windows will ask you
which program to use for opening it. You choose Notepad or Wordpad ( you can choose Word,
or any other text writing program, thought).After that, you get a textual window opened
(don't worry, it's sill in Graphical User Interface).

The first thing you should want to do in your plugin is to make an copyright/
credits/guide on using your plugin, etc.

Now, that function can be called by two ways. First is used exceptionaly for this. You write it like
this : */

Now, it should look like this:

-----------------------

*/
blah, blah, blah
/*

-----------------------


Notice that you close it with this : /*

Also notice that between these two signs you CAN write anything you want.
It doesn't affect on plugin and it will be "jumped" by compiler. Alright, after
your "I-don't-know-what-and-I-don't-want-to-know", the most important part of plugin comes
to your service. Now, after that YOU MUST include modules that your plugin will be pulling off
functions that your task ingame works perfectly. It should look like this:



-----------------------

*/
blah, blah, blah
/*

#include <amxmodx>
#include <fun>
#include <cstrike>

-----------------------



For this example, I've chosen to include amx mod x module ( that's the main one,
you should ALWAYS include it). I've also chosen to include fun and cstrike module.
Why?
Because, fun module has capatibilty of changing health, armor, speed, and giving you
noclip and godmode. In this tutorial plugin, I will make godmode on player.
I've chosen cstrike module, also why? Because, he has some functions that I could use,
for example, I will change player's model, and that's function is usefull in this example
plugin. And if you want to know which modules to include, you should open scripting/include
folder of Amx Mod X directory. You should open them all in your searching for functions
that you would use in plugin. You must have an idea what your plugin should do, or, it
could get nasty when searching throught all that functions.

Now, the next thing in plugin you should write is "public plugin_init()" function.
It's necesarry to get your plugin working. You can put it at begining or ending of plugin.
We'll put it forward this time. And, there is one more thing. When making that function, no,
in fact, all functions get opened by braces. For your safety of your nerves, you should always
make them like this in example. And one more function that is useful is "//"
The function of this is similar as "*/ ; /*". But, with this one
you can directly post comments on line of plugin:



------------------------

*/
bljuh, bljuh, bljuh
/*

#include <amxmodx>
#include <fun>
#include <cstrike>


public plugin_init() //this function calls another functions inside of it, just continue looking

{ // without this, your functions won't work

register_plugin("Example_tut_plugin","1.0","L enux, dish washer") // first function is for name of plugin, second for version of plugin, and third one for plugin's author name
register_clcmd("Bind_this_sentence","model_hp _change") // first function is that client will write in console, or bind it to key, and second is the function you make, continue looking

} // you close it with this brace

-------------------------


Just remember, when putting braces, the begining and ending brace should be "in same level",
so not that first brace is in first position of line, and second brace on downer line is at fifth position.
Also, the functions between braces should begin exactly on same position as "l" of "plugin_init()",well, at least I do that, and every plugin compiles

Also, then next thing you should start with is writing function of "register_clcmd" function.
Now, let's get to it:



-------------------------

*/
bljuh, bljuh, bljuh
/*

#include <amxmodx>
#include <fun>
#include <cstrike>


public plugin_init() //this function calls another functions inside of it, just continue looking

{ // without this, your functions won't work

register_plugin("Example_tut_plugin","1.0","L enux, dish washer") // first function is for name of plugin, second for version of plugin, and third one for plugin's author name
register_clcmd("Bind_this_sentence","model_hp _change") // first function is that client will write in console, or bind it to key, and second is the function you make, continue looking

} // you close it with this brace

public model_hp_change // notice that you can put anything on place of "model_hp_change" function

{ // braces!

cs_set_user_model(id,"models/player/super_tutorial_man.mdl") // this function is pulled from cstrike module, you should put your destination in "" signs, in this example, destination is bogus
set_user_health(id,240) // function called from fun module, notice that 240 is maximum hp that will show correctly in Half-Life

return PLUGIN_HANDLED // this function should be always leveled below functions in same spot of line below them

} // kh, kh, brace!

-------------------------

This would be an ending of first of three tutorials for Amx Mod X I will write.
Remember that you can also make other functions and put it on same client command (clcmd), like this:


--------------
register_clcmd("C4","donut_function")
register_clcmd("C4","donut_explosion")
--------------


Ok, so, this would be it. Any questions?[/small]
LynX is offline
Send a message via ICQ to LynX