A Scripting Guide!
#1

This is a basic guide to scripting, and no, not with learning how to modify text in Godfather! It's a guide to guides and it includes a few useful tips, plugins/includes list of which I use all of the time, and some more!

The guide is in the .rar file, as well as some useful files and an unreleased script! I've included the basic text file below, to save time.

Quote:

Hello Potential Scripter,

I am Calgon, I have written this guide to explain how easy scripting is, and how I can crush your life desires and aspirations within the next few minutes.

Scripting for SA:MP is an easy task; so easy in fact that those who don't natively speak English can easily master in the PAWN language.

What is PAWN?
Pawn is the language that is used to communicate between the SA:MP virtual machine and the clients. Pawn is a 32-bit programming language, with a syntax similar to C. Pawn was created in 1998 (when it was known as "SMALL"), which later became "Pawn" in March 2005. Pawn is used for several other games, however it's primarily known for its use within San Andreas Multiplayer.

Can I use alternative languages to script for SA:MP servers?
Yes, you can. There are wrappers for both LUA and C++, however they're not exactly 100% stable, it's ideal to remain using the PAWN language, until/if ever there's a built-in native wrapper for alternate languages, which doesn't seem like it'll ever happen.

Show me yours ways?!
My ways are pretty logical and easy. The most useful utilities are easily found as includes, plugins, filterscripts and of course, the native functions that are built in to SA:MP.

- Incognito's Streamer (it's a plugin, include provided as it includes native functions and some stocks, etc)
-- A streamer is used to create objects, depending on how close the player is to where the object should be spawned at, SA:MP supports creating objects soley for both players (which is how this streamer works) and all players (static). I have included the .dll (Windows) and the .so (Linux).

- Useful Functions / Include
-- I created this include with useful functions, that will come in extremely handy for scripters, I hope you extract the code from my include as I've just bunched a load of code I've had to create and some other useful code by others. I bunched SSCANF's scripted version in, as that's better than the plugin IMO.

- foreach
-- Created by ******, the most useful include EVER. This creates fast, efficient and effective loops around players, with such a simple snippet of code (foreach(Player, i)) whereas using another method (commonly known using (for(new x..)) which is quite a bit slower.

- SII
-- This was created by [DRuG]Slick, it's a caching file-writing/reading system which loads/saves data to/from files, however it stores the data in variables/enums to save the effort of writing/reading to files every single time you want to execute an action. This is slower than the commonly known raw method, but it makes scripting so much easier.

- DINI
-- This was created by DracoBlue, this doesn't cache, however it's a file-writing/reading system which is extremely noob-friendly, the previous Vortex script I created used DINI and DJSON (got to the stage of migrating/processing all code over to DJSON)

- DJSON
-- This was creatred by DracoBlue, this is like SII, however it uses the more common JSON encoding methods, that are becoming ever more popular, even ******** have started to use JSON (http://graph.********.com/frederick.wright2) and PHP natively include JSON libraries within their code now. This is ideal for making a filebased interactive system (so you could make a UCP, providing you host it locally)

- MYSQL
-- This was created by StrickenKid, MySQL has been popular for quite some time, some huge social networking websites (********, *******, habbo hotel and more) use this method to store/load data, it's ideal for making UCPs and interactive features, you could easily create a UCP using PHP, PHP natively includes MySQL. The .dll (Windows) and the .so (Linux) have been included too. I'm not so keen on this method, I've always preferred filebased structures, this is also very complex - this guide will not overview this system.

Can you link me to a few guides?
Yes, of course. Here are a few useful links:

- PAWN language guide
-- http://www.compuphase.com/pawn/Pawn_Language_Guide.pdf
--- This overviews plenty of compiler issues, the language syntax, and plenty of of useful features/code you can learn from.

- Initialisers
-- https://sampwiki.blast.hk/wiki/Keywords:Initialisers
--- One useful thing about SA:MP is that there's plenty of initialisers, you can create so many alternate variables with so many alternate initialisers.

- Scripting Functions
-- https://sampwiki.blast.hk/wiki/Category:Scripting_Functions
--- This includes a list of what is available in the a_samp include.

- A few general tutorials
-- https://sampwiki.blast.hk/wiki/Category:Tutorials
--- This list of tutorials is moderately useful to creating basic features.

- Carlito's Roleplay
-- http://forum.sa-mp.com/index.php?topic=91010.0
--- One of my greatest learning experiences was fiddling with Carlito's Roleplay.

- Experimental Gamemode Script (included in /gamemodes)
-- I have created a basic script to mess around with, I've included it as it could be useful as a general base script to start "working on scratch from."

- "Fast Commands"
-- https://sampwiki.blast.hk/wiki/Fast_Commands
--- This basically includes a tutorial on how to write commands with dcmd and zcmd, using zcmd is not only easier, but it's also faster.

- MySQL Example Script
-- http://forum.sa-mp.com/index.php?topic=158587.0
--- Created by myself; this is an extremely useful example script that you can work on from, using MySQL.

- ARPC
-- http://forum.sa-mp.com/index.php?topic=122810.0
--- Created by myself; this is a useful utility (if you can't block remote RCON), passwords aren't all that secure, however it's a good idea on how to work on creating random strings (function I created with help from Popz ages ago).

Summary
This guide was created to basically show the essentials, I believe I've done a moderately good job at doing that, thanks for reading!

All the best,
Calgon/FreddoX!

The guide is available from here.
Reply
#2

Why isn't he releasing it? Anyway, nice job.
Reply
#3

Quote:
Originally Posted by [HiC
TheKiller ]
Why isn't he releasing it? Anyway, nice job.
I would've released the script properly, but I haven't really fully finished it, it's a good base to work from though IMO.

Thanks for the kind words.

EDIT: Apologies for the minor grammar issues, I wrote it in Notepad++ in a rush to hand it to an MSN contact.
Reply
#4

Nice work
Reply
#5

Really nice guide Freddo [BINMAN]
Reply
#6

Quote:
Originally Posted by ViruZZzZ_ChiLLL
Really nice guide Freddo [BINMAN]
Thank you for the bold and italics!
Reply
#7

Awesome, this will help newbies very much!
Reply
#8

I think my original guide from NGG forums died lol........Re-DLing
Reply
#9

I Sense A Sticky Note On This )
Reply
#10

Why was Stricken's MySQL plugin mentioned and not G-Stylez?

I'd also recommend mentioning Incognito's IRC plugin (the only one in existence), GVars, SScanf 2.0, Zcmd, and Whirlpool? Those are the pinnacle of existing plugins/includes available to coders.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)