SA-MP Forums Archive
Modular scripting question related to hooks - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Modular scripting question related to hooks (/showthread.php?tid=654519)



Modular scripting question related to hooks - Stefand - 30.05.2018

Hello,

So I am making a modular gamemode, I have my #includes sorted in the appropriate order and every .pwn has an ongamemodehook to tell me if its properly included but the output is not in the same order as my #includes list.

My console output:
Код:
core/player/textdraws.pwn loaded
core/player/dialogs.pwn loaded
core/player/login.pwn loaded
core/admin/functions.pwn loaded
core/server/anticheat.pwn loaded
core/server/economy.pwn loaded
core/server/stocks.pwn loaded
core/timers/onesecond.pwn loaded
core/server/textdraws.pwn loaded
core/server/publics.pwn loaded
core/admin/bans.pwn loaded
core/player/playerdata.pwn loaded
core/factions/factiondata.pwn loaded
core/faction/commands.pwn loaded
While my #includes are in this order:
Код:
//Server
#include "core/server/textdraws.pwn"
#include "core/server/publics.pwn"

//Admin
#include "core/admin/bans.pwn"

//Player
#include "core/player/data.pwn"

//Factions
#include "core/factions/data.pwn"
#include "core/factions/commands.pwn"

//Player

#include "core/player/textdraws.pwn"
#include "core/player/dialogs.pwn"
#include "core/player/login.pwn"

//Admin
#include "core/admin/functions.pwn"

//Vehicles

//Server (with player data variables)
#include "core/server/anticheat.pwn"
#include "core/server/economy.pwn"
#include "core/server/stocks.pwn"

//Timers
#include "core/timers/onesecond.pwn"
Does the console order matter? Why does it load not the same as the script order?


Re: Modular scripting question related to hooks - GTLS - 30.05.2018

Includes are not actually loaded within .amx. Their code is. Console's order does not thing any thing bad but only that include was loaded first than other, Like even though ban is included before OneSecond, OneSecond include code was added before Ban. Probably because function requiring OneSecond was called before Ban's members or simply, Ban was longer to read than OneSecond. So while Ban was still getting read, other smaller includes got included first.


Re: Modular scripting question related to hooks - Stefand - 30.05.2018

Quote:
Originally Posted by GTLS
Посмотреть сообщение
Includes are not actually loaded within .amx. Their code is. Console's order does not thing any thing bad but only that include was loaded first than other, Like even though ban is included before OneSecond, OneSecond include code was added before Ban. Probably because function requiring OneSecond was called before Ban's members or simply, Ban was longer to read than OneSecond. So while Ban was still getting read, other smaller includes got included first.
Aha but upon compiling it maintains the list of #includes? Because I cant have some stuff compiling in a different order else it fucks up


Re: Modular scripting question related to hooks - GTLS - 30.05.2018

Quote:
Originally Posted by Stefand
Посмотреть сообщение
Aha but upon compiling it maintains the list of #includes? Because I cant have some stuff compiling in a different order else it fucks up
Upon compiling, all codes (And I mean all declarations and functions) of Includes which are used for GM, will be added to .amx. Dont worry nothing will get messed up. Thats the way Pawn compiler works. When you include a code, it will be stacked above the main GM's files, I dont think It would mess up anything.


Re: Modular scripting question related to hooks - Stefand - 30.05.2018

Alright thanks mate.


Re: Modular scripting question related to hooks - Stefand - 04.06.2018

Quote:
Originally Posted by ******
Посмотреть сообщение
What sort of hooks?
Код:
==========core/vehicles/data.pwn file===========
#include <YSI\y_hooks>

hook OnGameModeInit()
{
	print("core/vehicles/data.pwn loaded");
}

==========core/player/data.pwn file===========
#include <YSI\y_hooks>

hook OnGameModeInit()
{
	print("core/player/data.pwn loaded");
}