DarkRP Help, Making job line up.

Hi, i am trying to start a script that is a lineup for if the job is full, you will be added to a lineup. When someone switches jobs, the next person will slide in. I am having trouble on trying to find a spot to start. I am having trouble wrapping my mind around determining what line to move forward when a person switches jobs. Eg. If i were a CP and i switch jobs, it doesnt know what job actually i switched from.

I saw this hook.

teamChanged( number before, number after ).

But im still having the same problem. How would i give each team an invidual line, BUT when a new job gets added it will ad a line to that job? IM STUCK!

Despite the fact that your post is only partially understandable.

This is how I would do it.
-I would setup a table for queue and then I would add all jobs to it using a loop
-Once someone tries to change a job, I would add a function call in the function that is responsible for returning if the player can join or not
-The function would add the player to the table in the area named same as the team he tries to join
-I would make a 2nd function hooked to teamChanged and run the function for selecting a random (or first) value in the table (in the area named after the last team the player who changed it was) then use the random value (which is a playerdata) and do Player:SetTeam(lastteam).

In other words, setting players team would look like this:
–I’ll FINISH it in 20 mins, let me get to school first haha, it’s 7 AM