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

nebie in need of a tut or something


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
svendude
Member
Join Date: Aug 2004
Old 08-28-2004 , 20:15   nebie in need of a tut or something
Reply With Quote #1

doese any1 know where to go to learn how to write .sma files? the 3 tuts on that "small scriptint tutorials" didn't help =(
svendude is offline
Send a message via Yahoo to svendude
Peli
Veteran Member
Join Date: Mar 2004
Location: San Diego, CA
Old 08-28-2004 , 23:22  
Reply With Quote #2

Hehe , you shouldn't be learning how to make a .SMA file , you probably want to learn Small , the language of AMXX plugins. Best ways to learn :
1. Read some tutorials , first to atleast know basic stuff
2. Read easy plugins and try to figure out what is what and how they did it
3. Ask questions and try to change code
Peli is offline
Send a message via MSN to Peli
svendude
Member
Join Date: Aug 2004
Old 08-29-2004 , 00:18  
Reply With Quote #3

i know the basics, i looked at a few plugins, and wats the dif between .sma and small?

oh and i don't understand a few things so im looking for an easy to understand tut =/
svendude is offline
Send a message via Yahoo to svendude
johnjg75
Veteran Member
Join Date: Mar 2004
Location: Delaware
Old 08-29-2004 , 00:21  
Reply With Quote #4

the difference from amxx(not sma) and small is nothing really just has different functions which are defined in the include files, BAILOPAN's fuction reference is a good way to see what things you can use in ur plugins, im gonna go get the turtorial that tought me amxx here in a sec
__________________
johnjg75 is offline
Send a message via AIM to johnjg75 Send a message via MSN to johnjg75 Send a message via Yahoo to johnjg75
Peli
Veteran Member
Join Date: Mar 2004
Location: San Diego, CA
Old 08-29-2004 , 00:21  
Reply With Quote #5

.SMA is a file type lol , thats what plugins are before they are compiled then they become .AMX , SMALL is the language.
Peli is offline
Send a message via MSN to Peli
johnjg75
Veteran Member
Join Date: Mar 2004
Location: Delaware
Old 08-29-2004 , 00:30  
Reply With Quote #6

Quote:
Welcome to the beginning of what will hopefully be a series of lessons in amx
scripting, I noticed there are hardly any tutorials for this around and me being
a n00b its hard to learn the language , So i will write these lessons from
a n00bs point of view which will hopefully help alot of people who like me
cant find a tutorial for amx .
In this lesson you will learn the VERY basics of amx ( just about what i know at the moment hahaha ) and how to print some text to the Screen so everyone can see it .
You no doubt already know what amx is and that small is very similar to C etc etc so ill get straight to the lesson :-)

First off i'll show you how to "comment" things out of your script. What this means is anything inside a "comment" will not interfere with your script
and can only be viewed in the .sma file.

/* <<This Starts the comment
*/ <<This ends the comment

So a comment in an actual script would look like this
/*
Hey im in a comment and can only be seen in the sma file :-D
How cool is that!? (Not Very haha)
*/

Most Programmers Usually put a comment at the top of their script to give general information about what it does and variables you can change
OK, so we know what a comment is... lets get down to the scripting!!
The first thing you want in your script is this
Code:
#include <amxmod>
#include <amxmisc>
What this does is include these 2 files and what it generally means is you have more commands to use!!

The next step is
Code:
public plugin_init() { }
What This does is actually load the plugin and whatever you put in between the { } brackets is what is executed when the plugin loads
so lets REGISTER the plugin with the server with the command
Code:
register_plugin("Plugin Name","Version of Plugin","Name of Creator")
The Quotes are very important here! and you would of course input your own Information like so
Code:
register_plugin("Tutorial","1.0","TrIpWiRe")
So to load your plugin and register it with the server you put it together and get the following....

Code:
#include <amxmodx> #include <amxmisc> public plugin_init() {     register_plugin("Tutorial","1.0","TrIpWiRe) }

Ok, So we have a plugin and its registered, But wait... it does absolutely.... nothing , So lets make it do something!
What we are going to do is CREATE a command that we can use on the server by using this command
Code:
register_concmd("Name of Command","Function it applies to", Access level,"Text that appears in amx_help")
Ok so your probably thinking "eh? whats he talkin about :/" So lets go through it, "Name of Command" is what you want to make your plugin respond to
for example if you type amx_slap Trip in the console window it would slap a user named trip, the amx_slap is the Name of the command, so you could name yours amx_trip and
then whenever you type that in the console it executes the "Function it applies to" part . If your still confused, take a look at the example below and then re-read this
to clear up any problems

Code:
register_concmd("amx_helloworld","myfunction", -1," : Outputs Hello World to the main screen")

In case Your wondering the -1 refers to the access level, -1 means there is no access level to it so everybody can use it... If you did the following...

Code:
register_concmd("amx_helloworld","myfunction", ADMIN_VOTE," : Outputs Hello World to the main screen")

... then only people with the access level Admin_vote ( defined in users.ini ) could use the command. And last but not least the text that appears in amx_help... if you type amx_help in the console window it
will come up with a bunch of commands you can use and some info about them, this is where the "text that appears in the amx_help" part comes in , it is placed in the info next to the "Name of the Command".
So now that you have your command your going to need to make it do something, this is where your "myfunction" comes in because when you type the command, in this case amx_helloworld, it looks for "myfunction in the script and executes whats in it.
This is how it is set out

public myfunction(id,level,cid) { }

OK so lets go through this shall we, the id is the nunber given to a player when the connect to your server, this will always only go up to 32 because thats the max players
you can have on a server at any one time, level is the access level we put in earlier in the "register_concmd" and cid even I arent sure about so sorry guys and girls, i just know they have to be there!
Inside this function we are going to check the access level of the person trying to use it and then hopefully, print the text!!
...So inside the function we put...
Code:
if(!cmd_access(id,level,cid,1)) {
	return PLUGIN_HANDLED
	}
What this does is if the client trying to use the command doesnt have the access level we put in PLUGIN_HANDLED stops the plugin from going any further
so next we need to type...

Code:
client_print(0,print_center,"This is my first plugin!! HELLO WORLD!")
return PLUGIN_HANDLED
Again with the "return PLUGIN_HANDLED" You ask, well yes this is needed to effectively "end" the plugin so it doesnt carry on. But ok lets explain this client_print part!
First off the 0 means that it will print it to any player, living or dead or spectator, everyone!,print_center will print the text to the center of the screen and the part in quotes is the text that will be printed :-D
SO!! the full script would look something like this!

Code:
/* 
Made by TrIpWiRe
Version: 1.0
Use this at your own risk!
*/

#include <amxmodx>
#include <amxmisc>

public plugin_init() {
	register_plugin("Tutorial","1.0","TrIpWiRe")
	register_concmd("amx_helloworld","myfunction", ADMIN_VOTE," : Outputs Hello World to the main screen ")
	}

public myfunction(id,level,cid) {
	if(!cmd_access(id,level,cid,1)) {
		return PLUGIN_HANDLED
		}
	client_print(0,print_center,"This is my first plugin!! HELLO WORLD!!")
	return PLUGIN_HANDLED
	}

So, Save this as a .sma file (HelloWorld.sma for example) and find in your amxx folder where it says "scripting" as a folder name, put your .sma file in there, (make sure you have some sort of command prompt in here as well that you can just double click on and it will already start in this directory)
then type in the command prompt "sc Helloworld.sma". If all has been done correctly it should compile fine and in your "scripting" directory should be a nice shiny Helloworld.amx . Upload this to your server, update your plugins.ini with the line Helloworld.amx at the end and then change the map on your server!!
When the new map loads type in what you chose for the "name of the command" and your text should appear!! ( In this case amx_helloworld )
Good luck everyone and happy coding!!
__________________
johnjg75 is offline
Send a message via AIM to johnjg75 Send a message via MSN to johnjg75 Send a message via Yahoo to johnjg75
Votorx
Senior Member
Join Date: Jun 2004
Old 08-29-2004 , 00:59  
Reply With Quote #7

Lol, couldn't you have just given him the link?
__________________
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
johnjg75
Veteran Member
Join Date: Mar 2004
Location: Delaware
Old 08-29-2004 , 02:22  
Reply With Quote #8

well it was an amx tutorial do i edited it some n i didnt feel like using my space to upload it and i made it easier to read with code and small tags so it was like a 4 vs 1 situation
__________________
johnjg75 is offline
Send a message via AIM to johnjg75 Send a message via MSN to johnjg75 Send a message via Yahoo to johnjg75
svendude
Member
Join Date: Aug 2004
Old 08-29-2004 , 03:40   woohoo!
Reply With Quote #9

yay thx that helped!... now if only i can find an advance tut thats readable! there really arn't enough tuts... i think i'll write one when i learn =D
svendude is offline
Send a message via Yahoo to svendude
Peli
Veteran Member
Join Date: Mar 2004
Location: San Diego, CA
Old 08-29-2004 , 03:44  
Reply With Quote #10

Here are some tutorials for Small / Amxx scripting :
1. AMXX Scripting Tutorial by BAILOPAN ( Basic )
2. Scarzzurs AMXX Scripting Tutorial ( Kinda Advanced )
3. Official Small Tutorial ( Advanced )
Good luck.
Peli is offline
Send a message via MSN to Peli
Reply



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 02:20.


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