04.07.2012, 21:05
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;
which in turn is followed by random variables.
I'll probably clean it up one day. Not now.
(*) Example of static locals:
Works absolutely fine.
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
// =============================================================================
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;
}