Hi,
i search a solution to get a playername when i use
found this at forum, but it dont workCode:void OnEntityKill(BaseNetworkable entity)
thanks for helpingCode:var player = entity.net.connection.player as BasePlayer;![]()
Playername at OnEntityKill / BaseNetworkable
Discussion in 'Rust Development' started by Terrance, Apr 11, 2018.
-
Code:
void OnEntityKill(BaseNetworkable entity) { if (!(entity is BasePlayer)) return; BasePlayer player = entity as BasePlayer; string name = player.DisplayName; ulong ID = player.UserID; // e.t.c. }
-
thanks, but it dont work
my complete code:
Code:void OnEntityKill(BaseNetworkable entity) { BaseEntity sEntity = entity.GetComponent<BaseEntity>(); // get objectname Vector3 sPosition = entity.transform.position; // get object position if (sEntity.ShortPrefabName == "cupboard.tool.deployed") { if (!(entity is BasePlayer)) return; BasePlayer player = entity as BasePlayer; string name = player.DisplayName; Puts(name.DisplayName + " destroyed a cupboard at " + sPosition.ToString()); } }
Code:error CS1061: Type `string' does not contain a definition for `DisplayName' and no extension method `DisplayName' of type `string' could be found. Are you missing an assembly reference?
-
Here's your problem.
string name = player.DisplayName;
Puts(name.DisplayName + " destroyed a cupboard at " + sPosition.ToString());
You're assigning name = player.DisplayName and then in your Puts you're calling name.DisplayName, which is like trying to call player.DisplayName.DisplayName -
thanks, that failed hard. im blind
fixed it and get this error message:
Code:error CS1061: Type `BasePlayer' does not contain a definition for `DisplayName' and no extension method `DisplayName' of type `BasePlayer' could be found. Are you missing an assembly reference?
-
-
yes. it is player.displayName
-
player.displayName is correct, but it dont work in combination with "BaseNetworkable entity"
now i have found an other solution for my problem and thanks for ur help
@HOUGAN_Y: i use only notepad -
Wulf Community Admin