ID:272612
 
Well, I am making a Bleach game and I want the squads for the shinigami to be seated in order of reiatsu. Reiatsu is just like the clients power. The first two seats are the Captain and lieutenant which I don't want included in the automatic seatings. From the 3rd seat to the 20th seat I want them to go in order 3rd seat having the most reiatsu (power), and 20th seat having the lowest. If all the seats are taken and a new shinigami (A race in Bleach) joins the squad, but doesn't even have enough reiatsu to take someone off the satings, he will be put as an unregistered seat in squad [enter number of the squad here]. There are 13 squads total.

Since people wont be on the game all of the time, I also want to know how would I get the amount of reiatsu the other client had before he logged off, and it auto moving him down a seat if newcomer to the squad had more reiatsu (power).
In order to help make this, we'll probably need to know what the hell a "reiatsu" is. Secondly, you'll need to describe this all better, as what you have is rather vague.
In response to Popisfizzy
Redone the post, hopefully this will make things more clear on what I need help on.
Alright, I started work on this yesterday and just finished it. It's rather large, so I'll seperate it into four parts:
//This creates a master /rank_handler object to handle
//all things rank-related.
var/rank_handler/rank_handler = new

rank_handler
var
list/squads
squad/master_squad/master_squad
const/TOTAL_SQUADS = 13

list/character_list
auto_scan = 1 //Automatically scan for people
//to add to the master squad.
scan_time = 6000 //Scan every ten minutes.

New()
//When this is created, create the squads and
//the master squad.

squads = new(TOTAL_SQUADS)
for(var/a = 1, a <= TOTAL_SQUADS, a ++)
squads[a] = new/squad

master_squad = new

//In addition, create the character list, which
//contains a list of player characters.
character_list = new
spawn() AutoScan()

proc
StarScan()
auto_scan = 1
spawn() AutoScan()

StopScan()
auto_scan = 0

UpdateScanTime(t = 6000)
scan_time = t

AutoScan()
while(auto_scan)

for(var/interim_alias/m in character_list)
if(!auto_scan)
break

sleep(-1)

if(m.reiatsu > master_squad.GetLowBound())
Add(m, master_squad, 0)

sleep(scan_time)

Add(interim_alias/m, squad/s, auto_check = 1)
if(auto_check && m.reiatsu > master_squad.GetLowBound())
//If auto_check is true, then the
//character will automatically be
//checked to see if they should be
//added to the master squad.
master_squad.Add(m)

return 2 //Indicate success if they
//have been added to the
//squad.

return s && s.Add(m) //This will return
//1 if they succeed
//and 0 or null if
//not.


/squad
The /squad datum is used to handle the thirteen squads you mentioned, as well as the master squad (the name I gave to the group with the 18 members + captain + lieutenant). It has basic functionalit you should need, and the master squad is modified appropriately to work as a ranked list.
squad
var
//Negative values indicate no member limit.
member_limit = -1

list/members

proc
Add(interim_alias/m)
if(members && member_limit > 0 && members.len >= member_limit)
//If there are members and there's a
//member limit and there are more
//members than that limit, indicate
//that the proc failed.
return 0

if(!members)
members = new

members += m

return 1 //Indicate success.

Remove(interim_alias/m)
members -= m

if(!members.len)
del m

return 1 //Indicate success.

master_squad
/*
In this datum, the members list will be an
ordered list, with the highest value to the
front.
*/


var
interim_alias
captain
lieutenant

member_limit = 18 //18 members, after the
//captain and lieutenant
//positions.

New()
if(member_limit < 0)
members = new
else if(members > 0)
members = new(member_limit)

Add(interim_alias/m)
/*
Total overwrite of /squad.Add() for this
situtation. Due to the fact that this is
a ranked list, it searches to make sure
the new addition has enough rieatsu or
whatever and then puts them in the proper
position, kicking the last person on the
list.
*/


var/interim_alias/n = members[members.len]
if(m.reiatsu > n.reiatsu)
for(var/a = 1, a <= members.len, a ++)
var/interim_alias/o = members[a]
if(m.reiatsu > o.reiatsu)
members.Insert(a, m)

n.KickFromSquad()

return 1 //Indicate success.

return 0 //Indicate failure.

Remove(interim_alias/m)
..(m)

if(m == captain)
captain = null
if(m == lieutenant)
lieutenant = null

proc
SetCaptain(interim_alias/m)
captain = m

m.current_squad.Remove(m)
m.current_squad = src

SetLieutenant(interim_alias/m)
lieutenant = m

m.current_squad.Remove(m)
m.current_squad = src

GetLowBound()
//Gets the lowest rieatsu or whatever,
//which should be the last character
//in the listing. As the entire list
//might not be filled, this isn't
//a certainty.

. = null
for(var/interim_alias/m in members)
if(. == null)
. = m.reiatsu
else if(m.reiatsu < .)
. = m.reiatsu

/interim_alias
This datum will be used to handle the storing of mob data. Due to the fact that you will likely delete mobs when the player logs out (as BYOND does by default), storing a direct reference to a mob won't work. This will be used in lieu of that.

In addition to that, all interactions between a mob and a squad will be handled, at least by this code, by way of this datum.
interim_alias
var
mob/master

squad/current_squad
reiatsu = 0

New(char_hash)
tag = char_hash
rank_handler.character_list += src

proc
GetCharHash()
return tag

Attach(mob/m)
master = m

master.SetSquad(current_squad)
master.reiatsu = reiatsu

Detach()
master = null

SetSquad(squad/squad)
current_squad.Remove(src)
current_squad = squad

master.SetSquad(squad)

KickFromSquad()
master.KickFromSquad()


/mob
I made modifictiosn to /mob instead of /client so that multiple characters could be controlled by one player.
mob
var
reiatsu = 0
squad/current_squad

interim_alias/alias

Login()
..()
ConnectAlias()

Logout()
DisconnectAlias()

proc
ConnectAlias()
alias = locate(GetCharHash())

if(!alias)
alias = new(GetCharHash())

alias.Attach(src)

DisconnectAlias()
alias.Detach()

GetCharHash()
//This produces a (very likely) unique
//identifier for a character.
if(!(client && client.ckey) && !key)
//If there's no indication that this mob
//is a player character, then don't send
//an identifier.
return 0

var/base = client ? client.ckey : key
base += "/[name]"

return md5(base)

SetSquad(squad/new_squad)
//This exists so you can easily alter other
//values for the squad if you see a need for
//them.

current_squad = new_squad

KickFromSquad()
//This is what happens when they're kicked
//from a squad. In my definition, it's just
//an alias for SetSquad(), where the argument
//is null. I'm sure youll want something more,
//though.

SetSquad(null)