2. What you are trying to do is programming and you should probably look into Python eventually. You could totally learn it.
My main point is to help you to unable someone to create a great scenario (because my skills aren't perfect and I prefer to play someone's else mod if it's better than mine).

I don't see cities() or headcities() anywhere on that line, but I'll get to work making you a method for checking number of cities for the target player. I'll include the operator() method in the Custom module.
This is the code I'm currently using (or I would if I reinstall cIV).