Code:void OnPlayerLoot(PlayerLoot inventory, BasePlayer target) { if (TeamData.ContainsKey(target)) inventory.Clear(); }Code:[Error] Failed to call hook 'OnPlayerLoot' (InvalidCastException: Cannot cast from source type to destination type.)
Solved Stop looting of other players? (C#)
Discussion in 'Rust Development' started by PsychoTea, Nov 15, 2015.
-
-
-
Code:
void OnPlayerLoot(PlayerLoot inventory, BasePlayer target) { if(TeamData.ContainsKey(target)) target.inventory.Strip(); }
-
May be I try:
Code:inventory.entitySource.ToPlayer().EndLooting();
-
May be BasePlayer not BasePlayer? or i'm don't know in what's problem -
Code:inventory.entitySource.ToPlayer().EndLooting();
Code:BasePlayer player = inventory.GetComponent<BasePlayer>();if (player == null) return;player.EndLooting();
-
Code:
[Error] Failed to call hook 'OnPlayerLoot' (InvalidCastException: Cannot cast from source type to destination type.)
EDIT: I rename hook toCode:void OnPlayerLoot(PlayerLoot inventory, BaseEntity entity)
Last edited by a moderator: Dec 21, 2015 -
Code:
void OnPlayerLoot(PlayerLoot inventory, BaseEntity entity) { if (entity is BasePlayer) { BasePlayer target = entity.ToPlayer(); if (TeamData.ContainsKey(target)) { target.EndLooting(); inventory.Clear(); PrintToChat(target, "Your inventory grabbed"); } } }
-
Code:BasePlayer target = inventory.GetComponent<BasePlayer>();