Should I make handlers?
#1

My server will be using a lot of gamemodes which will be constantly changing and using the same commands. I didn't even mind it before because I thought I could use FS instead but now I need some opinions.

Should I use command handlers?

With command handlers I mean a script out of the main GMs but integrated with this. Also, how can I use these handlers or scripts without placing them in the includes folder (because I'd like to add them in a folder like ...\serverfolder\handlers\handler.pwn)?

pawn Код:
#include "Vehicles.pwn" // this would normally read it from the includes folder
how can I do something like:

pawn Код:
#include handler "commands.pwn" // it would read it directly from the handlers folder
Reply
#2

Quote:
pawn Код:
#include "Vehicles.pwn"
This would actually read the "Vehicles.pwn" file in the same folder as the file you're compiling.

pawn Код:
#include "handlers/commands.pwn"
This would include commands.pwn in the handlers folder which is in the same folder as the file you're compiling.

Using handlers is really only useful in my opinion IF you're developing with other developers on SVN, or your file is really massive and is becoming a pain in the ass to work with. If your files are small then you may find having multiple files to be annoying.
Reply
#3

A few people I code with have complained about my source method, but IMO having them in multiple files makes it easier to track your functions, callbacks and other stuff. Also, if you make a coding error that cripples the compiler, just remove an include and you'll find where the problem is.

I agree with Simon too.

Код:
///////////////////////////////////////////////////////////////////////////////
//zz      	Gamemode Layout - Coding File Structure      	  xx//
///////////////////////////////////////////////////////////////////////////////
// AdrenalineX3.pwn - Main racing functions
// Commands.pwn - All commands
// DataArrays.pwn - Data storage variables
// Elements.pwn - Created objects, race lists, testdraws, housing
// RacingFunctions.pwn - AdrenalineX functions (IsVehicleTiny, IsRimsVehicle)
// SAMPFunctions.pwn - SA-MP functions (IsSkinValid, strtok, sscanf)
// Synced.pwn - SA-MP Callbacks
// Unsynced.pwn - Code awaiting rewritting
///////////////////////////////////////////////////////////////////////////////
Reply
#4

Ok my bad:

Quote:
Originally Posted by SAWC™
pawn Код:
#include "commands.pwn" // this would normally read it from the includes folder
how can I do something like:

pawn Код:
#include handler "commands.pwn" // how can I do this (reading from "serverfolder\handler\" instead of "includes\handler\") ?????
Reply
#5

Put your main script in the server folder.

Put your "commands.pwn" in a "handler" folder, the handler folder is in the "server" folder.

Put "#include handler\commands.pwn" in your main script...

edit:

I think it should actually be #include "handler\commands.pwn" (quotes should be around the including files), not sure if that makes any difference.. but that's how it is in the gamemode I'm working on.
Reply
#6

Someone has asked a question like that recently: Function calls from other directories
Reply
#7

Quote:
Originally Posted by Simon
Put your main script in the server folder.

Put your "commands.pwn" in a "handler" folder, the handler folder is in the "server" folder.

Put "#include handler\commands.pwn" in your main script...
That's it!

Thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)