Raised This Month: $12 Target: $400
 3% 

Amx Mod X scripting tutorial


Post New Thread Reply   
 
Thread Tools Display Modes
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
Puntje
Member
Join Date: May 2004
Old 10-19-2004 , 10:41  
Reply With Quote #2

just 1:

can i have a cookie?
Puntje is offline
Send a message via ICQ to Puntje
devicenull
Veteran Member
Join Date: Mar 2004
Location: CT
Old 10-19-2004 , 14:48  
Reply With Quote #3

A few..
This is going to confuse more people then it will help.
Why.. there's a few errors there.. comments are /* comment */ for one
Comments are not functions either
Your totally wrong about needing braces either
Code:
public plugin_init() register_plugin(...)
is perfectly valid. Braces are only needed with multiple line functions

cs_set_user_model has the wrong syntax (it takes a model name, like "gign" , not a path to a model) and wouldn't work anyway (No precache)

public model_hp_change needs () on the end of it, so it becomes
public model_hp_change()

register_clcmd("C4","donut_function")
register_clcmd("C4","donut_explosion")
... Why would you ever do something like that?

Whats wrong with all the ones linked to here?http://forums.alliedmods.net/showthread.php?p=42838
__________________
Various bits of semi-useful code in a bunch of languages: http://code.devicenull.org/
devicenull is offline
Votorx
Senior Member
Join Date: Jun 2004
Old 10-20-2004 , 07:09  
Reply With Quote #4

Lmao, I had a hard time reading that and I know how to script. BTW, public plugin_init() is an exclusive function for amxmodx which is ran on server activation (not sure if you added that)

Quote:
Ok, so, this would be it. Any questions?
Err, that's just the tip of the iceberg buddy.
__________________
Currently Looking for a mod team.
Votorx is offline
Send a message via AIM to Votorx Send a message via MSN to Votorx Send a message via Yahoo to Votorx
LynX
Veteran Member
Join Date: Oct 2004
Old 10-20-2004 , 10:02  
Reply With Quote #5

Oops, sorry. I didn't knew I made such much mistakes . Thanks for pointing that mistakes. I guess learning one day to script doesn't helps.
LynX is offline
Send a message via ICQ to LynX
Isobold
Veteran Member
Join Date: Mar 2004
Old 10-21-2004 , 08:51  
Reply With Quote #6

plz fix these errors at least in your first post, so noobs will not have to search your faults
Isobold is offline
Ronkkrop
Member
Join Date: May 2004
Old 11-29-2004 , 08:59  
Reply With Quote #7

Quote:
register_clcmd("C4","donut_function")
register_clcmd("C4","donut_explosion")
damn you Americans Its Doughnut, not donut
__________________
"I refuse to join any club that would have me as a member."
--Groucho Marx
Ronkkrop is offline
Send a message via ICQ to Ronkkrop Send a message via AIM to Ronkkrop Send a message via MSN to Ronkkrop Send a message via Yahoo to Ronkkrop
LynX
Veteran Member
Join Date: Oct 2004
Old 11-29-2004 , 16:07  
Reply With Quote #8

I'm not american. Lol, it was funny to see that this topic got so responses. I'm gonna write new tutorial, cause I'm pretty much expirienced with AMXX now.
__________________
Current plugin : SoulPunisher anti-cheat
Percentage done : {||--------} 20%

If you think v3x is a PIMP, paste this into your sig!

If you think Bailopan is DA BOMB, paste this into your sig
LynX is offline
Send a message via ICQ to LynX
Rolnaaba
Veteran Member
Join Date: May 2006
Old 07-09-2006 , 23:37   Re: Amx Mod X scripting tutorial
Reply With Quote #9

If you think LynX has a stupid sig, paste this in your sig
lol just playin, but i going to have to agree with other on this
this will probably confuse newbs more than it will help them but good try ;)
__________________
DO NOT PM me about avp mod.

Last edited by v3x; 07-10-2006 at 02:02. Reason: If you think that Rolnaaba has a stupid face, paste this in your sig!
Rolnaaba is offline
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 07-10-2006 , 08:54   Re: Amx Mod X scripting tutorial
Reply With Quote #10

Wow, you bumped a two year post. GJ.
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 14:52.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode