GSC API Guide
-
Hello,
So I am pretty new to this Plutonium stuff, but I have been messing around with console commands and I have some 'big' plans for a custom Gun Game server for me and my gf but in order to do that I need some knowledge gaps filled in.
I am aware that there are these scripts called "gsc scripts" that we can add to our /storage/t5/scripts directory, and these will run as soon as a game is launched (like running map mp_nuked). I made this simple test_script.gsc that looks like this:
main() { print("YO"); self thread MessagePrinter(); } MessagePrinter() { while (1) { if(self MeleeButtonPressed()) { print("IN MESSAGE PRINTER!!!"); wait 1; } wait 0.05; } }
With this, I get many log messages in the console like this:
Pretty exciting huh? Well... I have bigger goals than this. And also, the log message prints whether or not I am pressing the melee button so there's that. I guess for some reason
self MeleeButtonPressed()
is resolving to True even though I have not pressed anything.-
What is the purpose of this github repo? It seems to be a TON of scripts for T5, but are we supposed to have all of these downloaded and put into our local script directory? Or are these just examples to reference?
-
Where can I find an API for all the different listener methods there are in gsc scripts? For instance, I have seen some scripts with functions like this:
OnPlayerSpawned() { self thread GiveMoney(); }
I assume this method will be called when any player spawns into the game? Where can I find the docs on what exactly these key words mean?
I have a lot of programming experience as I code full time for a living, so I will just need a bit of direction here and I will be off scripting away!
Maybe if someone is willing to explain this over a discord call that would be better. Let me know.
Thanks!
-
-
You can do a lot with GSC.
-
so is there any API guides out there for gsc?
-
sjakedude https://www.3dmappers.com/kunena/tutorials-and-helpful-information/1517-gsc-language-reference This is for T7 but most of it will apply to T5.
The purpose of the t5-scripts repo is to make easily accessible all the scripts the base game uses. You do not need to have them installed as they are just dumped from the game's files so they are always available to be referenced in your scripts.
I recommend perusing the t5-scripts repo to make it easier to learn the syntax and structure of scripts by example.
As for your script you made a mistake in that self does not exist or rather it references the level entity instead of any player entity. You can get the players in a server with the getPlayers() function and it returns an array of players you can call functions on.
If you have further questions you can ask here or dm me on discord JezuzLizard#7864
-
JezuzLizard Hey thank you so much, this is super helpful information. I will add you on discord, but I probably wont bother you a ton as you have given me a lot to work with. Thanks again
-
The best would be to use the modding channels on our Discord, which is meant for real time chat and has some useful resources pinned and people who can help as well. Most of them only look at the Discord server and rarely/never talk about modding on the forum