1. hello can somebody assisst me, if it possible, to make a different between all NPCPlayerApex.
    i want to track all different npc below:

    assets/prefabs/npc/scientist/scientist.prefab
    assets/prefabs/npc/scientist/scientist_gunner.prefab
    assets/prefabs/npc/scientist/scientistjunkpile.prefab
    assets/prefabs/npc/scientist/scientistpeacekeeper.prefab

    if i use :
    Code:
    if (entity is NPCMurderer)
    {
    .........
    }
    it works and i can track murderer

    if i use :
    Code:
    if (entity is NPCPlayerApex)
    {
    ..........
    }
    it works too and i can track all scienist, but how i can track they different

    like this:
    Code:
    if (entity is NPCScientistpeacekeeper)
    if (entity is NPCScientistjunkpile)
    if (entity is NPCScientist_gunner)
    but it will dont work
     
  2. Can't you just make compare on prefab?
    Code:
    if(entity.PrefabName.Equals("assets/prefabs/npc/scientist/scientist_gunner.prefab"))
     
  3. yes thanks this work how i use it

    edit:

    i use now this and it works for me
    Code:
        if(entity.PrefabName.Equals("assets/prefabs/npc/murderer/murderer.prefab")) { Your Code }
        else if(entity.PrefabName.Equals("assets/prefabs/npc/scientist/scientist.prefab")) { Your Code }
        else if(entity.PrefabName.Equals("assets/prefabs/npc/scientist/scientist_gunner.prefab")) { Your Code }
        else if(entity.PrefabName.Equals("assets/prefabs/npc/scientist/scientistjunkpile.prefab")) { Your Code }
        else if(entity.PrefabName.Equals("assets/prefabs/npc/scientist/scientistpeacekeeper.prefab")) { Your Code }
        else if(entity.PrefabName.Equals("assets/prefabs/npc/bandit/guard/bandit_guard.prefab")) { Your Code }
     
    Last edited by a moderator: Aug 24, 2018
  4. use 'switch'
     
  5. Wulf

    Wulf Community Admin

    entity.ShortPrefabName would be better too, which you would then use just "murderer", "scientist_gunner", etc.
     
  6. i am very new to this all and i learn by self, thanks i would try it

    ok thanks i try it, too
     
  7. Any difference performance wise @Wulf or is it just sugar?
     
  8. Wulf

    Wulf Community Admin

    A shorter string to check, so I imagine so.
     
  9. C# Switch Examples - Dot Net Perls

    Ex:
    Code:
    var a = "Oxide";switch(a)
    {
          case "Rust": // if 'a' is "Rust"
                      <Magic>
                       break;}
     
  10. thx again to all i have now this and it works too

    Code:
                var i = entity.ShortPrefabName;            switch(i)
                
                    {
                        case "murderer":
                            Puts( "Zombie" );
                            break;                    case "scientist":
                            Puts( "Scientist" );
                            break;                    case "scientiststationary":
                            Puts( "Scientiststationary" );
                            break;                    case "scientist_gunner":
                            Puts( "Scientist - Gunner" );
                            break;                    case "scientistjunkpile":
                            Puts( "Scientistjunkpile" );
                            break;                    case "scientistpeacekeeper":
                            Puts( "Scientistpeacekeeper" );
                            break;                    case "bandit_guard":
                            Puts( "Bandit - Guard" );
                            break;                }
     
  11. And its smarter
     
  12. That makes sense unless they are matched on address pointer, I don't know much about C# comparisons tho.