Gamemode Script Layout
#3

I have kind of the same problem where all variable declarations are scrambled. I try to use static locals(*) where possible, but that doesn't always cut it. I also do include lots of stuff, and in fact I created a whole folder structure for it. I also always seem to code with the thought in mind that I might actually release the script one day and that it thus must be somewhat noob friendly.

At the top of my GM I define general settings like #undef MAX_PLAYERS, #define LOCALHOST and stuff like that, followed by my list of files;

pawn Код:
// =============================================================================
// Variable Declarations

#include "../src/def/colors.txt"                    // Color definitions
#include "../src/def/sound_otb.txt"                 // Various sound ids
#include "../src/def/forward.txt"                   // Forward declarations for public functions
#include "../src/def/trucking.txt"                  // Coordinates for trucking pickup and dropoff
#include "../src/def/bcases.txt"                    // Coordinates for briefcase locations
#include "../src/def/unsafepass.txt"                // List of unsafe passwords (used during registration)
#include "../src/def/var/fishlist.txt"              // List of fish and rarity

#include "../src/def/enum/player/flags.txt"         // Player boolean values and stock functions
#include "../src/def/enum/player/timers.txt"        // Variable to store player timers

#include "../src/def/enum/global/textdraw.txt"      // Various general textdraws
#include "../src/def/enum/global/checkpoints.txt"   // Checkpoint definitions
#include "../src/def/enum/global/dialogs.txt"       // Dialog definitions
#include "../src/def/enum/global/skills.txt"        // Skill definitions

#include "../src/func/pinfo.txt"                    // PlayerInfo enum
#include "../src/func/pstats.txt"                   // PlayerStats enum
#include "../src/func/hinfo.txt"                    // HouseInfo enum
#include "../src/func/insurances.txt"               // Insurances enum and stock functions

// =============================================================================
which in turn is followed by random variables.

I'll probably clean it up one day. Not now.


(*) Example of static locals:
pawn Код:
public OnPlayerUpdate(playerid)
{
    if(IsPlayerNPC(playerid)) return 1;

    // ----- OnPlayerHealthChange -----
    static
        Float:oldHealth[MAX_PLAYERS];
       
    GetPlayerHealth(playerid, PlayerStats[playerid][pHealth]);

    if(PlayerStats[playerid][pHealth] != oldHealth[playerid])
    {
        OnPlayerHealthChange(playerid, PlayerStats[playerid][pHealth], oldHealth[playerid]);
        oldHealth[playerid] = PlayerStats[playerid][pHealth];
        return 1;
    }
    // -----
    return 1;
}
Works absolutely fine.
Reply


Messages In This Thread
Gamemode Script Layout - by MP2 - 04.07.2012, 20:36
Re: Gamemode Script Layout - by Kyle - 04.07.2012, 20:38
Re: Gamemode Script Layout - by Vince - 04.07.2012, 21:05
Re: Gamemode Script Layout - by ReneG - 04.07.2012, 22:30
Re: Gamemode Script Layout - by TheChaoz - 05.07.2012, 02:23
Re: Gamemode Script Layout - by MP2 - 05.07.2012, 03:13
Re: Gamemode Script Layout - by [ABK]Antonio - 05.07.2012, 03:51
Respuesta: Gamemode Script Layout - by TheChaoz - 05.07.2012, 04:36
Re: Gamemode Script Layout - by Vince - 05.07.2012, 07:53
Re: Gamemode Script Layout - by MadeMan - 05.07.2012, 16:58
Re: Gamemode Script Layout - by AndreT - 07.07.2012, 15:25
Re: Gamemode Script Layout - by Finn - 07.07.2012, 16:46
Re: Gamemode Script Layout - by Lorenc_ - 07.07.2012, 17:49
Re: Gamemode Script Layout - by ReneG - 07.07.2012, 18:01
Re: Gamemode Script Layout - by Y_Less - 07.07.2012, 23:19
Re: Gamemode Script Layout - by DeathTone - 07.07.2012, 23:22
Re: Gamemode Script Layout - by MP2 - 08.07.2012, 01:37
Re: Gamemode Script Layout - by JoBullet - 08.07.2012, 02:42
Re: Gamemode Script Layout - by MP2 - 08.07.2012, 02:53
Re: Gamemode Script Layout - by Simon - 08.07.2012, 06:23
Re: Gamemode Script Layout - by iggy1 - 08.07.2012, 09:35
Re: Gamemode Script Layout - by eesh - 09.07.2012, 05:47
Re: Gamemode Script Layout - by DiDok - 10.07.2012, 11:01
Re: Gamemode Script Layout - by Ada32 - 04.03.2014, 02:19
Re: Gamemode Script Layout - by ColeMiner - 04.03.2014, 11:05
Re: Gamemode Script Layout - by Ceathor - 11.03.2014, 09:39
Re: Gamemode Script Layout - by [HLF]Southclaw - 11.03.2014, 09:48
Re: Gamemode Script Layout - by ColeMiner - 11.03.2014, 10:35
Respuesta: Re: Gamemode Script Layout - by Gryphus One - 12.03.2014, 02:53
Re: Gamemode Script Layout - by ColeMiner - 12.03.2014, 17:35
Respuesta: Re: Gamemode Script Layout - by Gryphus One - 13.03.2014, 00:19
Re: Gamemode Script Layout - by Bertie - 29.07.2014, 19:49
Re: Gamemode Script Layout - by Y_Less - 29.07.2014, 20:50
Re: Gamemode Script Layout - by Bertie - 29.07.2014, 21:59
Respuesta: Re: Gamemode Script Layout - by Gryphus One - 29.07.2014, 23:45

Forum Jump:


Users browsing this thread: 8 Guest(s)