SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 02/04/2016, 01:53 PM   #1
Uberanwar
Gangsta
 
Uberanwar's Avatar
 
Join Date: May 2012
Location: Malaysia
Posts: 824
Reputation: 62
Default Q: Scripting practice

Hey everyone!
I was wondering if I make some includes, such as cmds.inc which contains the commands of the script, stocks would have its include too. Is that a good practice?
Uberanwar is offline   Reply With Quote
Old 02/04/2016, 01:55 PM   #2
introzen
Gangsta
 
introzen's Avatar
 
Join Date: Aug 2008
Posts: 774
Reputation: 30
Default Re: Q: Scripting practice

Quote:
Originally Posted by Uberanwar View Post
Hey everyone!
I was wondering if I make some includes, such as cmds.inc which contains the commands of the script, stocks would have its include too. Is that a good practice?
I believe it is. I do this all the time to keep track of everything. I haven't run into any trouble because of that yet.

I hate when you enter a gamemode and /everything/ is in the same file.

My includes:
pawn Code:
#include <a_samp>
#include <a_mysql>
#include <timec>
#include <streamer>
#include <strreplace>
#include <foreach>
#include <proxdetector>
#include <whirlpool>
#include <mysqlsettings>
#include <sscanf2>
#include <zcmd>
#include <colors>
#include <playerinfo>
#include <factioninfo>
#include <buildinginfo>
#include <vehicleinfo>
#include <weaponinfo>
#include <stocks>
#include <dialogs>
#include <loginquery>
#include <admincommands>
#include <playercommands>
#include <factioncommands>
#include <buildingcommands>
#include <mapping>
#include <crashdetect>
#include <anticheat>
#include <hitbox>
#include <actors>
__________________
"No problem can be solved from the same level of consciousness that created it." - Albert Einstein
introzen is offline   Reply With Quote
Old 02/04/2016, 02:49 PM   #3
AndySedeyn
High-roller
 
AndySedeyn's Avatar
 
Join Date: Feb 2014
Location: Belgium
Posts: 1,330
Reputation: 681
Default Re: Q: Scripting practice

Modular programming: http://forum.sa-mp.com/showthread.php?t=597338
I have not seen a modular gamemode yet where the modules are put in .inc files or even in the include folder. I have no idea whether doing so is a bad practice (I doubt it is).

My layout:
Code:
\project_folder\gamemodes\
	gamemode.pwn
	gamemode.amx
	\project_folder\gamemodes\modules\
		\project_folder\gamemodes\modules\player\
			core.pwn
			connect.pwn
			disconnect.pwn
			spawn.pwn
And I include them like this:
PHP Code:
#include "modules\player\core.pwn"
#include "modules\player\connect.pwn"
#include "modules\player\disconnect.pwn"
#include "modules\player\spawn.pwn" 
It's easy for me to distinguish libraries from gamemode modules doing it like this and I believe that's the only reason why it is done like this.

I could also put my modules in the include folder and include them like so:
PHP Code:
#include <modules\player\core.pwn>
#include <modules\player\connect.pwn>
#include <modules\player\disconnect.pwn>
#include <modules\player\spawn.pwn> 
AndySedeyn is offline   Reply With Quote
Old 02/04/2016, 04:29 PM   #4
Vince
Spam Machine
 
Vince's Avatar
 
Join Date: Sep 2007
Location: Belgium
Posts: 10,977
Reputation: 2649
Default Re: Q: Scripting practice

Code should be grouped by purpose, not by type. The idea behind splitting it up is to not have to look at code you're not currently working on.

Also I do not work out of the pawno/include folder. I leave that folder as it is so it can be overwritten as a whole during updates. I create a "source" folder in the root of the server directory and work from there. So a typical include line can look like:
PHP Code:
#include "..\source\3rd_party\plugins\sscanf.inc" 
or
PHP Code:
#include "..\source\minigames\stadium.inc" 
__________________
Vince is offline   Reply With Quote
Old 02/04/2016, 04:34 PM   #5
Floriian
Little Clucker
 
Join Date: Jun 2015
Posts: 10
Reputation: 7
Default Re: Q: Scripting practice

Code:
#include <scrp/inc/a_mysql>
#include <scrp/inc/CarPrice>
#include <scrp/inc/CameraMover>
#include <scrp/inc/easyDialog>
#include <scrp/inc/fixchars>
#include <scrp/inc/GetVehicleSpeed>
#include <scrp/inc/izcmd>
#include <scrp/inc/progressbar>
#include <scrp/inc/sscanf2>
#include <scrp/inc/streamer>

#include <scrp/server/define.pwn>
#include <scrp/server/enums.pwn>
#include <scrp/server/forwards.pwn>
#include <scrp/server/pragma.pwn>
#include <scrp/server/objects.pwn>
#include <scrp/server/stock.pwn>
4ever
__________________
Sorry for my bad english!I ****** translator forum!I'm Hungarian
Floriian is offline   Reply With Quote
Reply

Thread Tools
Display Modes

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Just practice Razturach Scripting Help 6 01/12/2015 11:14 AM
[GameMode] DMP [Deathmatch Practice] RedFusion Gamemode Scripts 18 21/05/2014 01:32 PM
Target practice script MarkJames Scripting Help 1 01/08/2013 11:41 PM
What are your views on this method/practice? [rep++] Hoborific Scripting Help 18 18/02/2012 05:24 PM


All times are GMT. The time now is 02:33 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.