Gamemode by include
#23

Quote:
Originally Posted by Dayrion
View Post
Hello. I'm wondering if it's not better to make a gameode with only include.
Example:
- MainFolder
-- Players
--- VariablesSaveLoading
--- Other
-- Vehicle
...
And all of them included in one gamemode.
Here is an example of how I lay things out

Code:
- {Name of Project} (Folder)
    - Config ( Core )
        - base.pwn ( Global Definitions, MySQL, Server Settings )
        - macros.pwn ( Global Macros for shortcuts like FUNCTION: and PUBLIC: )
        - plugins.pwn ( Global Plugin Definitions )
    - Player ( Module ) // The Prefix will be PD for PLAYER_DATA the name of the ENUM ( E_PLAYER_DATA )
        - init.pwn ( Includes, Initialize and Deinitialize functions )
        - config.pwn ( Enums, Definitions, Variables )
        - functions.pwn ( IsPlayerLoggedIn, etc )
        - database.pwn ( DB Functions / Threaded Query )
        - callbacks.pwn ( Prefixed Names, PD_OnPlayerConnect )
        - dialogs.pwn ( Functions / Responses )
        - textdraws.pwn ( Functions / Callbacks )
        - commands.pwn ( Player / Admin Commands )
        // You can just add a file for each section, pickups / objects, etc
 
     bootstrap.pwn // includes all modules and core files, so main gamemode only needs to include this file.
I hope this helps, I find this method to work the best for me, since I know whats in the file just by the name of it.

As for your mysql idea I find this to be a better way.

Code:
#define 	ENVIORNMENT 		        ( 0 ) 		// 0 - Production, 1 - Local Development, 2 - Remote Development

#define 	MYSQL_REMOTE_HOST 		"xxx.xxx.xxx.xxxx"
#define    	MYSQL_REMOTE_USER 		"server_name"
#define 	MYSQL_REMOTE_PASS 		"server_password"
#define 	MYSQL_REMOTE_TABLE 		"server_table"

#define 	MYSQL_LOCAL_HOST 		"xxx.xxx.xxx.xxxx"
#define    	MYSQL_LOCAL_USER 		"server_name"
#define 	MYSQL_LOCAL_PASS 		"server_password"
#define 	MYSQL_LOCAL_TABLE 		"server_table"

#define 	MYSQL_PRODUCTION_HOST 	"xxx.xxx.xxx.xxxx"
#define    	MYSQL_PRODUCTION_USER 	"server_name"
#define 	MYSQL_PRODUCTION_PASS 	"server_password"
#define 	MYSQL_PRODUCTION_TABLE 	"server_table"


// Now depending on how much you care, not that it makes much difference that you should, you can either use #if and #endif
// or you can a switch statment, I prefer swtich as it looks cleaner, and I love clean code.

new 
	database_connection
;

stock mysql_connect_ex()
{
	switch( ENVIORNMENT )
	{
		case 0: database_connection = mysql_connect( MYSQL_PRODUCTION_HOST, MYSQL_PRODUCTION_USER, MYSQL_PRODUCTION_PASS, MYSQL_PRODUCTION_TABLE );	
		case 1: database_connection = mysql_connect( MYSQL_LOCAL_HOST, MYSQL_LOCAL_USER, MYSQL_LOCAL_PASS, MYSQL_LOCAL_TABLE );
		case 2: database_connection = mysql_connect( MYSQL_REMOTE_HOST, MYSQL_REMOTE_USER, MYSQL_REMOTE_PASS, MYSQL_REMOTE_TABLE );
	}

	return database_connection;
}
Reply


Messages In This Thread
Gamemode by include - by Dayrion - 22.02.2017, 12:48
Re: Gamemode by include - by jlalt - 22.02.2017, 12:53
Re: Gamemode by include - by Dayrion - 22.02.2017, 13:17
Re: Gamemode by include - by jlalt - 22.02.2017, 13:25
Re: Gamemode by include - by Dayrion - 22.02.2017, 14:52
Re: Gamemode by include - by jlalt - 22.02.2017, 14:57
Re: Gamemode by include - by PrO.GameR - 22.02.2017, 19:44
Re: Gamemode by include - by iKarim - 23.02.2017, 06:13
Re: Gamemode by include - by Sew_Sumi - 23.02.2017, 06:20
Re: Gamemode by include - by Yashas - 23.02.2017, 06:52
Re: Gamemode by include - by iKarim - 23.02.2017, 19:41
Re: Gamemode by include - by Dayrion - 23.02.2017, 23:47
Re: Gamemode by include - by Sew_Sumi - 24.02.2017, 00:50
Re: Gamemode by include - by iKarim - 24.02.2017, 05:17
Re: Gamemode by include - by DRIFT_HUNTER - 24.02.2017, 05:24
Re: Gamemode by include - by Sew_Sumi - 24.02.2017, 05:35
Re: Gamemode by include - by Gammix - 24.02.2017, 07:34
Re: Gamemode by include - by Dayrion - 24.02.2017, 10:21
Re: Gamemode by include - by DRIFT_HUNTER - 24.02.2017, 14:28
Re: Gamemode by include - by patrickgtr - 24.02.2017, 14:32
Re: Gamemode by include - by iKarim - 24.02.2017, 14:59
Re: Gamemode by include - by Dayrion - 01.03.2017, 22:27
Re: Gamemode by include - by azzerking - 01.03.2017, 23:41
Re: Gamemode by include - by Dayrion - 02.03.2017, 12:52
Re: Gamemode by include - by azzerking - 02.03.2017, 18:00
Re: Gamemode by include - by renatog - 02.03.2017, 19:50
Re: Gamemode by include - by Dayrion - 02.03.2017, 20:15
Re: Gamemode by include - by renatog - 02.03.2017, 20:58
Re: Gamemode by include - by Mauzen - 03.03.2017, 03:46
Re: Gamemode by include - by Y_Less - 03.03.2017, 10:25
Re: Gamemode by include - by RyderX - 03.03.2017, 10:49

Forum Jump:


Users browsing this thread: 7 Guest(s)