Modular/part script
#1

Hi,

Lately I've been interested in a modular/part-by-part script. Basically, my interpretation of that is this:

You have say five files:

Main script (Main commands, main everything)
Business script (Business commands, everything to do with businesses)
House script (House commands, everything to do with houses)
Factions script (Factions commands, everything to do with factions)
Admin script (Admin commands, everything to do with admins)

So basically, how would I make it so that I could have all of those scripts seperate but functioning as one server?

So like within Main script I'd have:

pawn Code:
#include business-script
#include house-script
#include factions-script
#include admin-script
And then let's say we have a function:
pawn Code:
CreateBusiness(ecetra)
^ Within business-script, how would I make that usable within the main script?

Another example would be let's say using an enum such as;
pawn Code:
BusinessInfo[ecetra][ecetra]
^ From business-script and using it within the main script.

How is this possible? Also, could someone tell me the proper name for it? I have searched within the forums and believe me, I have searched, yet there is nothing there that helps me with this. If there are any tutorials or whatever, I'd like to see them, if you guys can help me or tell me, I'd be very appreciative.
Reply
#2

I need help here. Anybody?
Reply
#3

You could use those as Filter-Scripts not really sure as an include rather than saving folders of separate pieces.
Reply
#4

Yeah how can I do this as filterscripts Akira? Thanks for replying too.
Reply
#5

Quote:
Originally Posted by SilencedPistol
View Post
Yeah how can I do this as filterscripts Akira? Thanks for replying too.
-
You could make them separate like I said. One filterscript have all commands and saving files for business/houses/etc. Then when it goes down to the complexity put that into the game-mode.
Reply
#6

no includes would be much better suited

when you include a file it puts the whole script in where that include line is, so by creating a variable in an include you can use it in the main script

Reply
#7

Don't use that method however, otherwise your main script will be dependent on your module's data and it can be mixed very easily.

Each module should be completely dependent upon themselves. In other words, if I were to run that module with another script (or by itself entirely with little boilerplate code) it should run. So, each module should contain hooked functions to handle triggers (callbacks). Every internal function and data (as should be with any include) should be declared as static. There should be an API to communicate between the module and your main script, i.e. functions. These functions should include means of getting the private (static) data from the file to the other (getter/setter functions).

I was debating writing a full mode taking use of modules to release so people better understood the design process. May do so now..
Reply
#8

@Bakr - You have it spot on (Encapsulation)

My DayZ server is built completely modular just for you interest here is an example of what it looks like.

pawn Code:
// Gamemode includes
// Systems
#include "systems\togglecontrollableex.pwn" // Infinte health protection
#include "systems\dynamicarea.pwn"          // Dynamic area sub-streamer
#include "systems\dynamiccp.pwn"            // Dynamic CP sub-streamer
#include "systems\alltextures.pwn"          // Texture reference
#include "systems\pb.pwn"                   // Progress bar
#include "systems\other\stockfunctions.pwn" // Common stock functions
#include "systems\other\vdamage.pwn"        // Vehicle Damage functions
#include "systems\other\sscanfuser.pwn"     // Custom specifier as a "u" specifier replacement

#include "systems\pause.pwn"                // Pause system

#if defined USE_COLLISIONS
    #include "systems\onplayershoot.pwn"        // Detects when a player shoots
    #include "systems\interactiveobjects.pwn"   // Interactive (shootable) objects
#endif

// GeoIP
#include "systems\geoip.pwn"                // GeoIP

// Gamemode systems

// Textdraws
#include "gamemode\textdraws\huddraws.pwn"          // Hud draws on right of screen
#include "gamemode\textdraws\logintextdraw.pwn"     // Shows login textdraw
#include "gamemode\textdraws\radar.pwn"             // Radar (map)
#include "gamemode\textdraws\alivetime.pwn"         // Alive time textdraw
#include "gamemode\textdraws\blooddraws.pwn"        // Shows blood left

// Systems
#include "gamemode\systems\swim.pwn"                // Swimming include
#include "gamemode\systems\clock.pwn"               // Game clock (includes weather)
#include "gamemode\systems\surfcheck.pwn"           // Anti car surf
#include "gamemode\systems\fpspingkicker.pwn"       // FPS and ping updater / kicker
#include "gamemode\systems\throw.pwn"               // Generates throw frames for objects
#include "gamemode\systems\serverstats.pwn"         // Server statistic tracking / saving
#include "gamemode\systems\areas.pwn"               // Dynamic areas (** This is kind of messy right now**)
#include "gamemode\systems\movegates.pwn"           // Movable gates include

#if defined USE_COSTUME
    #include "gamemode\costume\costume.pwn"          // Costume system
#endif

// Environment
#include "gamemode\env\antigbug.pwn"                // Anti car G-bug
#include "gamemode\env\antidb.pwn"                  // Anti drive-by
#include "gamemode\env\rangetags.pwn"               // Ranged nametags when aiming
#include "gamemode\env\dynamicobjects.pwn"          // Dynamic object map

// Player stuff
#include "gamemode\player\achieve.pwn"              // Achievement system
#include "gamemode\player\defecate.pwn"             // Shitting on system
#include "gamemode\player\playeractions.pwn"        // Special player actions
#include "gamemode\player\firstperson.pwn"          // First person
#include "gamemode\player\experience.pwn"           // Experience system
#include "gamemode\player\statistics.pwn"           // Saves player position every 5 minutes
#include "gamemode\player\extstats.pwn"             // Extended statistics
#include "gamemode\player\killspree.pwn"            // Kill spree system
#include "gamemode\player\logindata.pwn"            // Records data about each login
#include "gamemode\player\sniperdot.pwn"            // Sniper dot for player
//#include "gamemode\player\vipsystem.pwn"            // VIP saving system



// Effects
#include "gamemode\effects\blood.pwn"               // Blood death animation
#include "gamemode\effects\bleeding.pwn"            // Blood trails
#include "gamemode\effects\damagedraws.pwn"         // Shows when a player is damaged

// Data
#include "gamemode\data\classes.pwn"                // Availible classes
#include "gamemode\data\validnames.pwn"             // Valid names
#include "gamemode\data\spawnspots.pwn"             // Spawn spots
#include "gamemode\data\removebuilding.pwn"         // Remove buildings

// Admin stuff
#include "gamemode\admin\report.pwn"                // Report system
#include "gamemode\admin\bansys.pwn"                // Ban system
#include "gamemode\admin\admincommands.pwn"         // Admin commands
#include "gamemode\admin\userinfo.pwn"              // Edit the user system data
#include "gamemode\admin\playerinfo.pwn"            // Displays player info for admins

// Gamemode commands
#include "gamemode\commands\usercommands.pwn"       // User Commands
#include "gamemode\commands\animations.pwn"         // Adds animation commands

// Major systems
#include "gamemode\npc\npcmodule.pwn"               // NPC Module
#include "gamemode\items\itemsystem.pwn"            // Item system
#include "gamemode\vehicles\vehiclesys.pwn"         // Vehicle System
#include "gamemode\vehicles\lastdriver.pwn"         // Keep track of a vehicles last driver
#include "gamemode\gangs\gangsystem.pwn"            // Gang system
#include "gamemode\gameloop\gameloop.pwn"           // Main game update loop


// Other stuff
#include "gamemode\other\svehicles.pwn"             // Special vehicles
#include "gamemode\other\balloon.pwn"               // Air balloon
#include "gamemode\other\stuff.pwn"                 // Stuff include
#include "gamemode\other\cameras.pwn"               // Cameras
#include "gamemode\other\trailer.pwn"               // Attached trailer
#include "gamemode\other\topbar.pwn"                // Top info bar
#include "gamemode\other\sweeper.pwn"               // Streetsweeper
Reply
#9

The advantage to using filterscripts instead of includes is that you're able to modify the code in real-time whenever you want without restarting the server. However, this comes with the cost of using remote functions or PVars.
Reply
#10

Quote:
Originally Posted by SuperViper
View Post
The advantage to using filterscripts instead of includes is that you're able to modify the code in real-time whenever you want without restarting the server. However, this comes with the cost of using remote functions or PVars.
y_master!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)