ID:158717
 
in my game you can make a "Team" and the team needs to be able to be ranked, any suggestions?



heres my code:

mob
var
team_name = ""
team_leader = 0
team_co_leader = 0
team_member = 0
team_rank = ""
in_team = 0
level = 0

var
list/
teams = list()
mob
verb
Create_team()
set category = "team"
if(usr.level >= 100)
var/list/L
L = list("font size")
if(usr.in_team)
usr << "<b>You are already in a team!"
return
switch(alert("Are you sure that you want to create a team?","","Yes","No"))

if("Yes")
goto Create

if("No")
return

Create
var/new_team_name = input("What do you want to call your team?","") as text
if(!new_team_name)
alert("team Name may not be blank.")
return
for(var/X in L)
if(findtext(new_team_name,X))
alert("You canno't change your font size!")
return
if(lentext(new_team_name) > 1000)
alert("Your team name is too long!")
goto Create
usr.team_name = new_team_name
usr.team_leader = 1
usr.team_rank = "Leader"
usr.in_team = 1
world << "<b><font color = aqua>team Info: [usr] has created the team [usr.team_name]!"
teams.Add(usr.team_name)
usr.Give_team_Verbs()
else
usr << "<b>You must be over level 100 to own a team!"

mob/team_Leader
verb
team_Invite()
set category = "team"
var/list/Menu = list()
for(var/mob/M in world)
if(!M.client) continue
if(M.name != usr.name)
if(!M.in_team)
Menu.Add(M)

var/mob/M = input("Who do you want to invite to the team?","") as null | anything in Menu
if(!M)return
if(istype(M,/mob))
switch(alert(M,"Do you want to join [usr]'s team?","","Yes","No"))
if("Yes")
M.team_name = usr.team_name
M.team_member = 1
M.team_rank = "Member"
M.in_team = 1
M.Give_team_Verbs()
world << "<b><font color = aqua>team Info: [M] has joined the team [usr.team_name]!"
if("No")
usr << "[M] has declined your team Invite"
return
team_Boot()
set category = "team"
var/list/Menu = list()
for(var/mob/M in world)
if(!M.client) continue
if(M.name != usr.name)
if(M.in_team)
if(M.team_name == usr.team_name)
Menu.Add(M)
var/mob/M = input("Who do you want to boot from the team?","") as null | anything in Menu
if(!M)return
if(istype(M,/mob))
if(M.team_leader)
alert("You cannot boot the leader!")
return
switch(alert("Are you sure you want to boot [M] from the team?","","Yes","No"))
if("Yes")
world << "<b><font color = aqua>team Info: [usr] has booted [M] from the team [usr.team_name]!"
M.leaveteam()
M.team_name = "None"
M.team_leader = 0
M.team_co_leader = 0
M.team_member = 0
M.team_rank = ""
M.in_team = 0
if("No")
return
Change_Rank()
set category = "team"
var/list/Menu = list()
for(var/mob/M in world)
if(!M.client) continue
if(M.name != usr.name)
if(M.in_team)
if(M.team_name == usr.team_name)
Menu.Add(M)

var/mob/M = input("Who's rank do you want to change?","") as null | anything in Menu
if(!M)return
if(istype(M,/mob))
if(M.team_leader)
alert("You cannot change the leader's rank!")
switch(input("What rank do you wish to give [M]?")in list("Co-Leader","Member","Custom","Cancel"))
if("Co-Leader")
M.team_co_leader = 1
M.Give_team_Verbs()
M.team_rank = "Co-Leader"
if("Member")
M.team_member = 1
M.leaveteam()
M.Give_team_Verbs()
M.team_rank = "Member"
if("Cancel")
return
Custom_Rank()
set category = "team"
var/list/Menu = list()
for(var/mob/M in world)
if(!M.client) continue
if(M.name != usr.name)
if(M.in_team)
if(M.team_name == usr.team_name)
Menu.Add(M)

var/mob/M = input("Who's rank name do you want to change?","") as null | anything in Menu
if(!M)return
if(istype(M,/mob))
var/ID=input("What do you want to rename [M]'s rank name to?")as text
M.team_rank=ID
team_Announce(T as text)
set category = "team"
var/list/L
L = list("font size")
if(lentext(T) > 400)
alert("Your message must be less than 400 characters!")
return
for(var/X in L)
if(findtext(T,X))
alert("You can not change your font size.")
return
for(var/mob/X in world)
if(X.team_name == usr.team_name)
X << "<font size=2><font color = silver><b><center>[usr] would like to announce to the team:<center><br>[T]"

mob/team_Verbs
verb
team_Say(T as text)
set category = "team"

var/list/L
L = list("font size")

if(lentext(T) > 300)
alert("Your message must be less than 300 characters!")
return
for(var/X in L)
if(findtext(T,X))
alert("You can not change your font size.")
return
for(var/mob/X in world)
if(X.team_name == usr.team_name)
X << "<b><font color = yellow>(team Say)([src.team_rank])[src.name]: [T]"


team_Who()
set category = "team"
var/tmp/C = 0
usr << "<font size=1><b><font color=silver><center>---------------------team WHO------------------------"
for(var/mob/M in world)
if(M.in_team)
if(M.team_name == usr.team_name)
C += 1
usr << "<font size=1><b><font color=red>[M.name]([M.key])([M.team_rank])"
usr << "<b><font color = red>[C] team Members Online!"
usr << "<font size=1><b><font color=silver><center>---------------------team WHO------------------------"

team_Leave()
set category = "team"
switch(alert("Are you sure you want to leave the team [src.team_name]?","","Yes","No"))
if("Yes")
src.leaveteam()
world << "<b><font color = aqua>team Info: [usr] has left the team [usr.team_name]!"
src.team_name = ""
src.team_leader = 0
src.team_co_leader = 0
src.team_member = 0
src.team_rank = ""
src.in_team = 0
if("No")
return

mob
proc
Give_team_Verbs()
if(src.team_leader)
src.verbs += typesof(/mob/team_Leader/verb)
src.verbs += typesof(/mob/team_Verbs/verb)
if(src.team_co_leader)
src.verbs += typesof(/mob/team_Leader/verb)
src.verbs += typesof(/mob/team_Verbs/verb)
if(src.team_member)
src.verbs += typesof(/mob/team_Verbs/verb)
leaveteam()
src.verbs -= typesof(/mob/team_Leader/verb)
src.verbs -= typesof(/mob/team_Verbs/verb)
That's some horrible code (not that I've read it all; but I did catch f.ex. abuses of goto,name, and the code seems larger than it should be) AND design. Such a design of teams really needs to be implemented as an object (most notably a datum) - keeping track of the team's properties via vars on every mob in it is dreadful. If you're interested in more info about using your own, 'custom' objects to represent stuff (teams in this case), you can read these links:
http://www.byond.com/docs/guide/chap18.html
http://www.byond.com/docs/ref/info.html#/datum
http://www.byond.com/members/ DreamMakers?command=view_post&post=35530
Also, here are some posts I've made on a similar subject to help you come up with a better design that makes more sense, if you're so inclined:
[link], [link], [link]

Not sure what's really your exact question here though, and "how do i assign a var to somthing that a player makes??" [sic] is vague, though I could always answer like this, which I assume isn't all that helpful:
var/MyVar = something the player made.
e.g.
mob/player
var/obj/myObj
verb/Create_Obj()
src.myObj = new /obj(src.loc)