Skip to content
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Donate
Collapse

Plutonium

  1. Home
  2. BO1 Modding Releases & Resources
  3. [RESOURCE] Boilerplate GSC code for your first script

[RESOURCE] Boilerplate GSC code for your first script

Scheduled Pinned Locked Moved BO1 Modding Releases & Resources
5 Posts 2 Posters 531 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • AlexInVrundefined Offline
    AlexInVrundefined Offline
    AlexInVr
    wrote on last edited by AlexInVr
    #1

    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 );
    	}
    	
    	
    }
    
    
    
    
    1 Reply Last reply
    3
    • Resxtundefined Offline
      Resxtundefined Offline
      Resxt
      Plutonium Staff
      wrote on last edited by
      #2
      • 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 for OnPlayerSpawned 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 of onPlayerConnect 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

      AlexInVrundefined 1 Reply Last reply
      1
      • Resxtundefined Resxt
        • 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 for OnPlayerSpawned 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 of onPlayerConnect 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

        AlexInVrundefined Offline
        AlexInVrundefined Offline
        AlexInVr
        wrote on last edited by AlexInVr
        #3

        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

        Resxtundefined 1 Reply Last reply
        0
        • AlexInVrundefined AlexInVr

          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

          Resxtundefined Offline
          Resxtundefined Offline
          Resxt
          Plutonium Staff
          wrote on last edited by
          #4

          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

          AlexInVrundefined 1 Reply Last reply
          1
          • Resxtundefined Resxt

            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

            AlexInVrundefined Offline
            AlexInVrundefined Offline
            AlexInVr
            wrote on last edited by
            #5

            Resxt I agree with that definitly !

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Donate