Now, the best part (not really). You can finally learn about a lot of the stuff we used 2 sections ago.
So, 2 sections ago we learned about the wiki and we went over most of it except functions and parameters..
In this section, we learn how to utilize that, let's go!
The basics of functions
So, let's dive right into it and take a look at a function.
function killPlayer(ply, fire)
if fire then
Burn someone, or kill them outright.
Alright! The first part of the function is the word function.. Now this is obviously necessary as it creates it.
The next part we have is killPlayer(ply, fire)
the killPlayer part is basically just our name of it that we use to do it. It can be anything.. literally.
I coulda put lmansdlmnasdnasdlol and it would work fine :D
Next is the (ply, fire)
These are referred to as parameters. You input values into them, so ply is a Player.
In this case, fire is a boolean (true/false). It can technically be anything, but that might break it :P
An example of how we could use this new function we've created is when someone beats the map in deathrun.
In order to achieve this, we will need to use hooks. This will be learned in a later tutorial so I won't include the full code and you'll see the rest later on.
function defined up here....
hook.Add(......., function(ply, ....)
This would light the player on fire, alternatively we could set it to false and it would just kill them
Now, let's go over the stuff like ply:Ignite and ply:Kill
Those are player metas, learned later on but functions that you can use on the player.
We use : to call (use) functions from other places (not in the same file, etc..)
You'll get into it more once we go over more.
For now, that's basically all I have about functions. There's probably more (just ask) and I'll add it.
Let's move on to the Intermediate level! Click me!