Small scripting tutorials, and how to fix some common errors
Last Update: August 01, 2004 01:44:16 PM
Note: PM me with comments. Note2: If you have a tutorial you want posted here, PM me with it So you want to start creating plugins. By the time you get here, I assume you know how to compile plugins, the basic syntax of some small commands, and how to declare variables. If you don't know either, I suggest you read some more before you get here. Here are some good things to read to get the basics of Pawn: Tutorial #1 Introduction to Pawn Tutorial #2 Intro to AMX Mod X Scripting Tutorial #3 Pawn Tutorial Pawn Language Documentation (PDF) *Note: This is a little more advanced, I suggest reading it after you learn the basics Tutorials in this thread: Basic Scripting Tutorial (devicenull) SQL Scripting Tutorial (devicenull) Some common errors, and how to fix them. Error: I get no errors, but I get a 0kb output file, and/or the compiler crashes Solution: Somewhere in your code, you forgot to close something. This is usually caused by forgetting to put a " at the end of text, but it can also be caused by forgetting a ) or } Error: warning 202: number of arguments does not match defintion Solution: On the line it says, you don't have enough paramaters. You forgot to put something in, and the compiler noticed. Just go to that line, compare the command you used to the one in the include file. It might be something as simple as you put a period instead of comma. Error: error 035: argument type mismatch (argument X) Solution: One of your arguments is the wrong type. This usually happens when the command is expecting a float, and you gave it an integer (I didn't go over floats here, they can be annoying). Or it could be the command expected a string, and you gave it an integer. |
Let's start off with how to get some arguments from the commandline. We will create a basic amx_kick plugin.
Here's the code for it, I will explain it after. Code:
Code:
Code:
Next, in register_concmd, I tell AmxX that I am creating a new command called "amx_kick2", that it should call "do_kick" when a client uses this command. It also specifys the access level needed (ADMIN_KICK) and the help for the command. You almost always have several of these, and there are different types:
Code:
Code:
Code:
Code:
Code:
Code:
Code:
Code:
Code:
Code:
A note, the "return PLUGIN_HANDLED" prevents Half life from displaying "Command not found". |
NOTE: THIS IS AN OLD VERSION OF SQL, USE SQLX INSTEAD
So, you want to learn how to use SQL in AmxX plugins? To do this, you need the following things
Note: This tutorial is going to be using the 0.20 version of SQL, not the 0.16 version. You can get the include file to look at it from the CVS. And the plugin I will be explaining: A note: In the interest of clarity, I don't tell the user why the plugin didn't work Code:
This really isn't that hard to explain.. Code:
Code:
Code:
Code:
Code:
Code:
Code:
Code:
Code:
Expecting: Use: Int var = dbi_result(result,"fieldname") Float dbi_result(result,"fieldname",Float:var) String dbi_result(result,"fieldname",var,len) Also, dbi_field() works the same way, with the field number instead of the field name Code:
You can get most of this from reading the include file, but some of it is a bit annoying to figure out |
All times are GMT -4. The time now is 01:57. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.