Script organization
#1

Hello everyone.
I just wanted to hear how you organize your scripts.
I am in the process of starting a whole new gamemode.
I want my script to be spread into different filterscripts.
But there are some custom-made functions, that I would like to use throughout all the scripts.
Should I just put those functions in a seperate .pwn and include it in ann the scripts?
Or should I just keep the entire script in one?
Reply
#2

here:
http://forum.sa-mp.com/forumdisplay.php?f=84
Reply
#3

Quote:
Originally Posted by StreetGT
View Post
Mind reading his question..

OT: I usually put them at the bottom of the script.
Reply
#4

Quote:
Originally Posted by sim_sima
View Post
Hello everyone.
I just wanted to hear how you organize your scripts.
I am in the process of starting a whole new gamemode.
I want my script to be spread into different filterscripts.
But there are some custom-made functions, that I would like to use throughout all the scripts.
Should I just put those functions in a seperate .pwn and include it in ann the scripts?
Or should I just keep the entire script in one?
If you want to spread your code in different files (for example to work with it more easily), I recommend you to create includes with hooked callbacks. When I was a complete newbie at scripting I opened this thread asking if that is a good option and ****** said it is. Filterscripts have the advantage of you being able to load and unload them while the server is running, but there's a limit in the number of them you can use at the same time.

If you have your own custom functions and you want to use them in different filterscripts, make them public and use CallRemoteFunction.
Reply
#5

So the best idea is to keep it all in one script?
What about making the different systems in different files, like having the main gamemode with the login/register system and so on in one file, and the house system in another file, and the vehicle system in a third file etc., and then #include the house and vehicle system in the gamemode before compiling?
Reply
#6

Quote:
Originally Posted by sim_sima
View Post
So the best idea is to keep it all in one script?
Like Gryphus One said, it's better to have them loaded in filterscripts, using remote callbacks. That way, you can reload parts of your mode without having to restart your server.

Normally, I'd keep it within one script because it's best to have everything I need in one huge file without having to dig through others. If I feel that I need to separate it, I'll use a modular method or filterscripts.
Reply
#7

Quote:
Originally Posted by Emmet_
View Post
Like Gryphus One said, it's better to have them loaded in filterscripts, using remote callbacks. That way, you can reload parts of your mode without having to restart your server.

Normally, I'd keep it within one script because it's best to have everything I need in one huge file without having to dig through others. If I feel that I need to separate it, I'll use a modular method or filterscripts.
Yea. The modular method is having the different systems spread in different .pwn files, and then #includ it into the gamemode, right?
Reply
#8

Quote:
Originally Posted by sim_sima
View Post
Yea. The modular method is having the different systems spread in different .pwn files, and then #includ it into the gamemode, right?
yup, you should REALLY take a look into y_master. stay dry if you hate reading https://sampforum.blast.hk/showthread.php?tid=475106
Reply
#9

Quote:
Originally Posted by Ada32
View Post
yup, you should REALLY take a look into y_master. stay dry if you hate reading https://sampforum.blast.hk/showthread.php?tid=475106
but if I simply #include the script files together, I don't need all that hook stuff, do I?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)