13.10.2018, 19:25
Even tho i don't like modular scripting, when you reach almost 1000+ dynamic objects in your map, you can't put them all in a single gamemode.
Would be confusing and stupid. So i work in this way:
Main gamemode:
In bank.pwn:
Then, on the main gamemode, at OnGameModeInit:
To call them.
That's how i do. Another example, random spawns:
This is LEO's random spawn coordinates:
And again on main gamemode, to call them:
Hope you got the idea.
I just noticed a thing (tho i don't need to do it), if in a separate .pwn you put any default callback (such as OnPlayerConnect, OnPlayerDeath and so on.) and meantime you have that callback in your main gamemode, script won't compile because callback X is already defined.
However don't need this. I use external .pwn files just to store stocks, custom callbacks, objects and everything NOT related to default Sa-Mp callbacks. Then i call them in my gamemode whenever i want.
Would be confusing and stupid. So i work in this way:
Main gamemode:
pawn Код:
#include "/Objects/bank.pwn"
pawn Код:
stock CreateBankObjects()
{
//Code objects
}
pawn Код:
CreateBankObjects();
That's how i do. Another example, random spawns:
This is LEO's random spawn coordinates:
pawn Код:
new Float:RandomCopSpawns[][4]=
{
//Coordinates
}
pawn Код:
new randi = random(sizeof(RandomCopSpawns));
SetPlayerPos(playerid, RandomCopSpawns[randi][0],RandomCopSpawns[randi][1],RandomCopSpawns[randi][2]);
I just noticed a thing (tho i don't need to do it), if in a separate .pwn you put any default callback (such as OnPlayerConnect, OnPlayerDeath and so on.) and meantime you have that callback in your main gamemode, script won't compile because callback X is already defined.
However don't need this. I use external .pwn files just to store stocks, custom callbacks, objects and everything NOT related to default Sa-Mp callbacks. Then i call them in my gamemode whenever i want.