[RESOURCE] Boilerplate GSC code for your first script
-
I was going around the forums and stuff, and realized there isn't too much resources for newbies to learn GSC, and one fantastic thing in the world of programming are boilerplates, which save you alot of time,
so thought I would share a boilerplate for anyone who wants to start a script
#include maps\_utility; #include common_scripts\utility; #include maps\_zombiemode_utility; init() { thread onPlayerConnect(); } onPlayerConnect() { for(;;) { level waittill( "connecting", player ); player thread onPlayerSpawned(); } } onPlayerSpawned() { self endon( "disconnect" ); for( ;; ) { level waittill( "connected", player ); } }
-
- You mentioned zombies in the title but apart from the include it's the same for both multiplayer and zombies so maybe remove that and remove the ZM in the title?
- You should always keep the same syntax. Using
onConnect
at first and then using upper case forOnPlayerSpawned
doesn't make sense, choose one or the other for all functions - Personal preference but I don't see why you name it
onConnect
instead ofonPlayerConnect
to keep a similar syntax/logic and make it easier to read and understand:onPlayerReload, onPlayerChat
etc.
Other than that it's nice to have this here, I always come back to my old scripts for such things and having boilerplates ready is nice.
Also apart from the includes this boilerplate works for all 4 Plutonium games -
Resxt Thx ! I am still learning gsc myself as I just recently got to it more seriously other than writing just simple box patch functions, these will be useful, I'll make sure to update my post too !
As for the syntax yeah this is a bad habit I developed while working on multiple programming projects and languages, Unity is one such example where they love capitals lol
-
AlexInVr I do a lot of C# as well so it's a bad habit I have but at least I'm consistent with it
It's better to be wrong everywhere rather than randomly switching and having no pattern -
Resxt I agree with that definitly !