making hooks

Hey guys, I was wondering, How do i make my own hooks?
I am currently working on my own gamemod, and was wondering how to make my own custom hooks.
I want to make a hook which checks if a player changed his job, So how would i do that hook?

Example at the bottom of the page is enough I hope.

Ok, i got another question, instead of opening a new thread, i guess i should just ask it here.
I am now making the jobs part of the gamemod, this is an example of what i have:

Once i get all of the jobs done, How will i be able to go one by one and read them, sorry for the stupid question by the way.
In DarkRP It just loads up all tables, But do you guys know how can you do that?

The best way is to define a global table (or 3 for each realm: sv_gm, cl_gm, sh_gm where gm is shorten gamemodes name) then put all the info into it so it’s easily accesible, like:

sv_gm = {} = {}["Policeman"] =
	name = "blah",
	salary = 1337,
	mdl = "mdl/here.mdl"


About that ‘table loading’, he just created a function called darkRP.createJob (if I remember correctly) that takes a table as an argument and what it does is execute team.SetUp() using info from the table and putting rest of the info that isn’t going to be used until later into a global table called darkRP and to be exact

Sorry if I made it complicated, it’s so damn hot I can’t focus… (damn you spring).

All right, So lets say i got 2 jobs, how will i use each and every one?[1]?
Because if i will have a page presneting all jobs, i wont go and add each job.[“Policeman”] ?

And then if you want different jobs to have different models, you just apply the model via:
player:SetModel([ player.job ].mdl )

It’s really not a big deal, but it looks to me like you lack basic knowledge about how tables function.

Right, so after they change job, How will i define that thier job change?

sorry but why are you using a different table name for server, shared, and client?! I guess it could help a novice programmer keep them conceptually separate but it’s how horrible coding practices and future confusion gets born… he’ll probably endup thinking that if a server and client table have the same name they will also share the same values between server and client.


Aren’t you making a big deal over nothing? Do you really think someone would be that stupid?
All that is just a matter of aesthetics and shouldn’t cause a problem unless you are an idiot.

Anyways, to straighten everything - It doesn’t matter if you keep functions in 3 separate tables or in 1, if it’s easier for you to keep stuff in different tables then do so, if you are planning on releasing the code for others to modify, browse etc. then it’s better to keep your code as readable for others as possible by using the default way of handling stuff.
If you are aiming for the code to be most readable for you only then hell… do whatever works best for you, even if it means naming your variables using your first language.

After making the jobs, how will i ‘set’ it to the player?
ply.Job =[“citizen”]? i mean just so i can go on and continue the function.
Thanks for the help.


You should read this

Wow thanks, Finally got that whole tables thing… :stuck_out_tongue:
Emm as i asked, how should i transfer the data through the ply?

If you are naming your tables after the job ([“Citizen”] = {}) then you can store just the job’s name on player using:

ply.job = "Citizen"

Then you can access any info in that table by doing:[ ply.job ].model

model is just an example.