How would i detect if its a player if not return?
Code:void OnKillNPC(BasePlayer npc, HitInfo hinfo) { if (!npcData.NpcTP.ContainsKey(npc.UserIDString)) return; // Check if this NPC is registered if (hinfo == null) return; var player = hinfo.Initiator.ToPlayer(); ulong playerId = player.userID; string npcId = npc.UserIDString; var EnableDead = npcData.NpcTP[npcId].EnableDead; var DeadOnPlayer = npcData.NpcTP[npcId].DeadOnPlayer; string DeadCmd = npcData.NpcTP[npcId].DeadCmd; string DeadArgs = npcData.NpcTP[npcId].DeadArgs; var bad = "somthing is not right somewhere in DeadCmd"; if (EnableDead) if (!DeadOnPlayer) // Check if this is command on player { rust.RunServerCommand($"{DeadCmd} {DeadArgs}"); } if (DeadOnPlayer) // Check if this is command on player { rust.RunServerCommand($"{DeadCmd} {playerId} {DeadArgs}"); } else PrintError((string)bad); // Otherwise print the error message to console so server owners know there is a problem }
OnKillNPC how to detect if its a player?
Discussion in 'Rust Development' started by Ts3hosting, Feb 2, 2017.