ID:264306
 
Code:
mob/Player
proc
Village_Members(village)
var/list/villagers = new
for(var/mob/M)
if(M.Village == village) villagers+=M
return villagers


Owners/verb
Define_Kage()
set category = "Owner"
var/list/Villages[] = list("Leaf"="Hokage","Sand"="Kazekage","Mist"="Mizukage",\
"Cloud"="Raikage","Rock"="Tsuchikage","Rain"="Amekage",\
"Sound"="Otokage","Waterfall"="Waterfall Hero")
var/V = input("Which village?","") in Villages
if(Kages["[Villages[V]]"] != "<i>none</i>")
switch(alert("There currently is a [Villages[V]]. Replace?","Confirmation","No","Yes"))
if("No") return
var/mob/M = input("Promote who to [Villages[V]]?","Define [Villages[V]]") in Village_Members(V)
M.Rank = "[Villages[V]]"
Kages["[Villages[V]]"] = M
world<<"<center>[M] is now the [Villages[V]]</center>"
Save_Lists()


Problem description:

runtime error: Cannot modify null.Rank.
proc name: Define Kage (/mob/Player/Owners/verb/Define_Kage)
usr: Mizukouken Ketsu (/mob/Player)
src: Mizukouken Ketsu (/mob/Player)
call stack:
Mizukouken Ketsu (/mob/Player): Define Kage()
Oh wow nevermind... I figured out what was going on. xD My 'Village' var wasn't equalling the village selection from the list :) So the Village_Members() proc was returning an empty list (aka null).
Add a cancel button to the input so it accepts null values.
var/mob/M = input("Promote who to [Villages[V]]?","Define [Villages[V]]") as null|anything in Village_Members(V)


Also, you should always do a safety check after an input() like so:

if(M)
You really should use datums to handle villages, so much cleaner.
In response to Andre-g1 (#2)
For others, it might help, but not for me :) Even if they leave, they'll still get the rank and when they log in again, they'll get all the benefits :) Behold! The power of lists! >:O