How to divide gamemode in INCLUDES?
#1

Hello, i was feeling to divide the gamemode i made in modules, its around 1.5k lines for now, from scratch, and i'm working on it and want to finish it, it requires long coding, so i was thinking to make it fully modular.


I want to divide the coding among different pwns that will be placed in INCLUDES folder of PAWNO..


But when i do, either the command doesn't work or it shows some error while compiling..


#include "filename.pwn" is the method i use..

I made a simple command kill and it didn't work..
Reply
#2

This is not a common idea , You can also use FilterScripts to do that...

Also you can control them when you are admin (rcon logined) with "/rcon loadfs FILTERSCRIPT_NAME" and "/rcon unloadfs FILTERSCRIPT_NAME" example: /rcon loadfs minigame_01
Reply
#3

Quote:
Originally Posted by taktaz
View Post
This is not a common idea , You can also use FilterScripts to do that...

Also you can control them when you are admin (rcon logined) with "/rcon loadfs FILTERSCRIPT_NAME" and "/rcon unloadfs FILTERSCRIPT_NAME" example: /rcon loadfs minigame_01
No,that's a bad idea.

@OP: It's called modular,you may want to use y_hooks.
and,It's easy. You should look at some gamemodes in here for your example.
What's the error?
Reply
#4

Quote:
Originally Posted by ******
View Post
5) Don't use monolithic callbacks. Use libraries like y_commands and y_dialogs to avoid having to put everything under `OnPlayerCommandText` and the like. This is yet another way of ensuing that all related code appears in a single file. As a good rule-of-thumb files should be no more than 1000 lines long, and functions 100 lines. As verc said, for other callbacks you can split them up with y_hooks.
I didn't use y_hooks or any other hook method and my code ended up like this:
Forexample, if the module file's name is WeaponShop
PHP Code:
forward WS_OnGameModeInit();
public 
WS_OnGameModeInit()
{
    
//code

And then in the main game mode file
PHP Code:
public OnGameModeInit()
{
    
WS_OnGameModeInit();

Is this a bad idea??

@OP, don't put your module files in includes folder, put them in a child directory in gamemodes folder.
Reply
#5

Any specific reason?
Reply
#6

Why people work with modules ? I't just a spare of time but memory is the same.
Reply
#7

Quote:
Originally Posted by [HLF]Southclaw
View Post
Here are a couple of gamemodes that follow a pretty standard module layout:

https://github.com/Southclaws/ScavengeSurvive - quite an old gamemode, code is split based on either whether it applies to player accounts, player characters or the game world. It's a good starting point but quite old so it has gathered quite a few hacks and workarounds in terms of layout that I never got around to fixing.

https://github.com/Southclaws/samp-sandbox - a much newer project that's quite young. Here I'm experimenting with some newer ways of splitting code as well as making heavy use of dependencies as packages, making each unit individually testable.

Pawn and SA:MP lives in this "bubble" where standard, logical practices don't seem to pierce. My advise is to look at some other projects in other programming languages on GitHub - you don't need to know the language, just look at how the files are structured.
The second project is super clean and easy to understand, it makes me want to learn SA:MP development, especially with how well commented it is. On the other hand, SS is very bloated and daunting to somebody who doesn't know a whole lot and with it being the primary example of modular development the good practices inside it don't reach as many people.
Reply
#8

I'm working on my first gamemode, so i doubt the gamemode is going to be very less optimized and eat up alot of RAM and CPU..

Maybe i'll drop the plan and work on another..




And I couldn't get your point, look at other languages, don't really know what it has to do with PAWN.




I'm a rookie, just scripting everyday and making 10 threads in the scripting help section at a time, don't really have a deep knowledge, but I'm sure i can get good at it if I try. Thanks for sparing your valuable time and guiding me, Southclaw.
Reply
#9

I could have divided it in different filterscripts, but it would come up with an error or timewaste at the end when I'll work on /STATS command, either i'll have to gather the information from MySQL, writing cache_get_content_int, else, all I can do is write it in a single gamemode or in the form of INCLUDES.


and @******, it doesn't always make it simple, I feel like you haven't checked California Cops and Robbers gamemode, it contains many features, but if you make a change, something else will get bugged, and it's divided into multiple INCLUDES in the form of .pwn files, which are included in the gamemode.



DISCLAIMER: I'm not insulting him or dishonouring his work, he has added alot of features in it, even I love those features.
Reply
#10

As i told it's going to be a CnR gamemode, with a very few maps(hardly 450 objects as a grand total, dynamic ones) in the beginning, but later i would implement some maps as if demanded by the donors. The server is going to be a for a long term.. but I hope sa-mp retains the players back it lost..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)