Gamemode Script Layout
#20

I tend to layout gamemode projects by seperating the files into folders. The folders symbolize a library or a 'class' of related methods. The rough idea is as follows:
  • <mode>.pwn (Link all the modules together, delegate responsibilities to <module>.pwn)
  • <mode>.h (Define your global constants, enumerations and forward functions. Variables)
  • version.in (Optional. SVN repository input file, allows for revision numbers to be generated to version.h which <mode>.h can include)
  • compile.bat (Optional. Runs some extra compiling procedures such as getting SVN revision number and authors)
  • modules\
    • modules.def (Optional. Define your scoping definitions here if you like using them, Module1::, Module2:: etc)
    • <module>\
      • <module>.h (Define your module constants, enumerations and forward functions. Variables)
      • <module>.pwn (Your module core logic, written as if it were a library for use by your handler. Variables)
      • events.pwn (Custom events/callbacks defined by your module. Code is very specific to the gamemode (messages etc.), generally not able to be re-used.)
      • handlers.pwn (Handle SA:MP and other 'external' callbacks using your module)
  • scriptfiles\ (List of scriptfiles ready to be dumped on the server)
    • something.cfg
    • users.db
The .h files are included before all .pwn files in <mode>.h, <mode>.pwn (your compile file) includes <mode>.h. This resolves any undefined variable issues. You should be very careful with manipulating variables directly and try abstract the problem to a method. Methods do not need to be pre-declared unless they have tags.

Where variables are declared varies on your laziness. Ideally I believe the variables should be static and declared in their <module>.pwn file (to allow more general variable names without conflicts, and to discourage manipulating a variable outside of it's "module logical domain"). Use of static can cause undeclared variable compile errors due to file-level symbol hiding. This can be resolved by using getter/setter type methods (which are better theoretically)

A core module can be created for stuff that is unique to the gamemode or cannot be classified into a general purpose library.
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: 15 Guest(s)