ID:166105
 
I have sum sort of problem with my kagesystem. I just made my own kagesystem and i want to add sum sort of limit to it. When you make someone Hokage, that no-one else can become Hokage to. So it's actually to put a limit that their can only be 1 kage in each village. Please someone help me!!!!

thx
var/village_one_kage
In response to Ripiz
What should i do with that var? cuz i'm no expert coder. Where should i add it and how do i make it excecute itself. Please explain. Can u reply with an exapmle of hokage for leaf village please
In response to Krayzy
if(villages.leaf.hokage) return
villages.leaf.hokage = someone


?
In response to DivineO'peanut
do i need to replace that someone with a key?
In response to Krayzy
so here is an example of my code. Its for leaf village only. I have this for all vilages.

mob/Admin
verb
MakeKage(mob/M in world)
set category = "Staff"
if(M.Kage == 0)
if(M.rank == "ANBU")
if(M.Village == "Leaf")
M<<"You have been promoted to the rank Hokage!"
M.Kage = 1
world<<"[M] is now Hokage M.rank = "Kage"
M.Rank2 = "Hokage"
src.verbs += typesof(/mob/kage/verb)
else
M<<"You need atleast to be ANBU to become Kage!"
else
M<<"This person is already Kage!"


I need a system based on this code to have only 1 kage per village. In this case only 1 Hokage for leaf village.
You can always contact through msn at: [email protected]
In response to Krayzy
mob/Admin
verb
MakeKage(mob/M in world)
set category = "Staff"
if(M.Kage == 0)
if(M.rank == "ANBU")
if(M.Village == "Leaf")
if(world.LeafKage == 0)
M<<"You have been promoted to the rank Hokage!"
M.Kage = 1
M.LeafKage = 1
world<<"[M] is now Hokage"
M.rank = "Kage"
M.Rank2 = "Hokage"
src.verbs += typesof(/mob/kage/verb)
else
M<<"Already have a Leaf Kag."
else
M<<"You need atleast to be ANBU to become Kage!"
else
M<<"This person is already Kage!"


world
var
LeafKage = M.LeafKage
mob
var
Kage = 0
rank = "ANBU"
Rank2 = "Leaf ANBU"
LeafKage = 0
In response to Black Ice Inc.
1) Use <DM></DM> for codes

2) Using ==0 and ==1 instead of if(var) & if(!var)... can lead into disaster (especially if the variable was defined as null at first). Learn about boolean shortcuts

3) Instead of making multiple different variables, it wiould be simpler to use a list to contain it (..well, not realy simpler, just help reduce the variable usage, which is great if you're using a HTML-based edit command)

4) You posted "world.LeafKage".. what's wrong with it? 2 things: 1) world. doesn't need to be there, unless it's in the /world dantum. 2) The variable you showed is under /mob as well...

- GhostAnime
Krayzy wrote:
I have sum sort of problem with my kagesystem. I just made my own kagesystem and i want to add sum sort of limit to it. When you make someone Hokage, that no-one else can become Hokage to. So it's actually to put a limit that their can only be 1 kage in each village. Please someone help me!!!!

I suggest you create a /Village datum. This datum would contain the framework for the information that a village should contain: village's name, village kage, etc.

A simple demonstration might be as such:
[Edit: Added comments]
/Village    // A Village datum
var
name = "Hidden Something" // datums don't come with names!
mob/kage = null // Only one mob/kage per village, yes

proc
// SetKage fails if there is no newKage, or
// if there is a current kage and overwrite is set to 0.
SetKage(mob/newKage, overwrite=0)
if(!newKage || (kage && !overwrite))
return 0
else
kage = newKage
return 1

// New(n) merely sets the village name to n.
New(newName)
if(newName) name = newName

// Beginning declarations of some villages....
var/Village
hiddenLeaf = new("Hidden Leaf")


The /Village datum has two defined variables there; it stores its name and a kage in the form of a /mob.

The function that I created for the village is a simple proc to set a new kage. You call it via the following format: [village].SetKage([mob], [overwrite?]), where [village] is a reference to the village to set the new kage, [mob] is the mob to set as kage, and [overwrite?] is a value to determine whether the current kage should be overwritten if it exists. If it evaluates to false, the current kage will remain kage upon a call to the function. If it's true, then the kage will be set to newKage no matter what, assuming that newKage is not null.

In /Village/New(), I've defined it as taking one argument, a new name. If you call New() with an argument it will set the name to the argument. Note that I've not done any forcible type-checking, you can do that as needed and/or desired to ensure that it runs smoothly in the event of the unexpected.

A few lines down I declared a global variable of the type /Village, being a new instance of the type. I assume that you are going to merely define a per-village for Naruto, so there isn't such a need of a dynamic village list; you can just as well declare each village as I have done for the Hidden Leaf.

Each /Village, having only a single variable for kage, will be unable to store multiple kages, being the problem you identified with your current system. I hope this helps, in such a case.

Hiead