How do I start a modular project?
#1

Hello SA-MP community,

I've been reading a lot about modular programming in SA-MP lately and it would be great if I could use it in my current project. However, I can't seem to find a clear tutorial on how to start from point zero to a full organized project. I'm new to PAWNO scripting and this is the first gamemode I'm creating, so any clear advice is very much appreciated.

I've been struggling with the following points.
- A clear tutorial to start from zero to a full stack project.
- How do global variables work? How do I embed those into the mail file? What are common mistakes?
- What plugins/compilers should I use to do so? What are it's advantages against the other?
- An example Roleplay script that's organised in a modular way.
- How do you organise different types of functions and commands? (stock, forward, public, zCMD)
- If you're using a text editor like for ex. Atom; how do you compile your total project to an .amx?

I've been working on a roleplay gamemode from scratch since a few days now (and completely new). It has for example a bank and payday system. How would I organise this? Do I for example put all the code concerning the bank system in a seperate file? What do I do if I want to reach that code from another file (ex. payday system)?

Since I am a beginner I'm really in search of a clear explanation and a step-to-step guide on setting up an hook-system.

Thanks in regards,

Josh
Reply
#2

Quote:
Originally Posted by Josh_Lotus
Посмотреть сообщение
PAWNO scripting
Pawn scripting. Pawno is an editor.

All files are still included into the main gamemode and you can access functions and global variables across those files without problems, provided they aren't declared 'static'. Static functions and static globals are only visible to the file they have been declared in. This is comparable to 'private' keyword in OO languages where private variables can only be used inside the class they've been declared in.

Public functions should only be used for callbacks. That includes the default callbacks, functions that are called by timers and certain specific callbacks that are called by plugins. For a function to be stock, it should be able to be used by anyone in any script. That means that it should be a stand-alone function that does not depend on gamemode specific variables to work.

As far as modules are concerned: they should be able to be disabled and enabled without affecting anything else. If this is not possible then I like to consider this a "core" module: without it the gamemode cannot function. You can, for example, create a module "House" which stores their locations, their prices, all the necessary commands, etc. A module is usually built by hooking into the existing callbacks (see ALS hook method). In OnGameModeInit, for example, you may wish to create icons or pickups. But these shouldn't be added if the module isn't enabled.

Compiler: there is only one compiler. Or actually two if you count Zeex' fixes. The compiler (pawncc.exe) can be invoked manually or through an editor, with the right parameters. More information can be found in the manual (pawn-lang.pdf).

Plugins: there are several plugins you may wish to use. I consider the most useful and commonly used ones to be Sscanf, Streamer and MySQL, but there are other ones that you may find useful such as MapAndreas or FileManager.
Reply
#3

Hello Josh!

You can use y_hooks for hooking the files and making a modular script or you can just do it the old way.
PR-RP is a modular script (the old way) and there is Scavenge and survive (y_hooks) even its probably old a year or two but it's a good script.
Reply
#4

if somebody create his channel for teaching sa-mp scripting we will really get help no channel on ******* for scripting i ruqest a genus scripter that he create his channel on ******* plz plz plz he will also earn from it
Plz Hlep new scripters by videos
Reply
#5

Quote:
Originally Posted by Vince
Посмотреть сообщение
Pawn scripting. Pawno is an editor.

All files are still included into the main gamemode and you can access functions and global variables across those files without problems, provided they aren't declared 'static'. Static functions and static globals are only visible to the file they have been declared in. This is comparable to 'private' keyword in OO languages where private variables can only be used inside the class they've been declared in.

Public functions should only be used for callbacks. That includes the default callbacks, functions that are called by timers and certain specific callbacks that are called by plugins. For a function to be stock, it should be able to be used by anyone in any script. That means that it should be a stand-alone function that does not depend on gamemode specific variables to work.

As far as modules are concerned: they should be able to be disabled and enabled without affecting anything else. If this is not possible then I like to consider this a "core" module: without it the gamemode cannot function. You can, for example, create a module "House" which stores their locations, their prices, all the necessary commands, etc. A module is usually built by hooking into the existing callbacks (see ALS hook method). In OnGameModeInit, for example, you may wish to create icons or pickups. But these shouldn't be added if the module isn't enabled.

Compiler: there is only one compiler. Or actually two if you count Zeex' fixes. The compiler (pawncc.exe) can be invoked manually or through an editor, with the right parameters. More information can be found in the manual (pawn-lang.pdf).

Plugins: there are several plugins you may wish to use. I consider the most useful and commonly used ones to be Sscanf, Streamer and MySQL, but there are other ones that you may find useful such as MapAndreas or FileManager.
Thanks for your response, it made things a little more clear. However, about the modules there's something still unclear for me. How would those 'hooks' look like (scriptwise)? Do you know any good examples of a roleplay script that is working with ALS hooks?
Reply
#6

Quote:
Originally Posted by Runn3R
Посмотреть сообщение
Hello Josh!

You can use y_hooks for hooking the files and making a modular script or you can just do it the old way.
PR-RP is a modular script (the old way) and there is Scavenge and survive (y_hooks) even its probably old a year or two but it's a good script.
Hello there, thanks for the response. I can't seem to find the script online. Are you sure it has been released?
Reply
#7

Can someone tell me a step-to-step guide on starting a modular project? I can't find a clear tutorial on the web.
Reply
#8

https://github.com/Southclaw/ScavengeSurvive

The PR-RP one got deleted because it was released without the owners permission.

Here is a tutorial for modular programming : https://sampforum.blast.hk/showthread.php?tid=597338
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)