@@ -25,6 +25,7 @@ local table_RemoveByValue = table.RemoveByValue
2525local table_Copy = table .Copy
2626local table_Add = table .Add
2727local table_insert = table.insert
28+ local table_isArray = table .isArray
2829local string_find = string.find
2930local string_lower = string.lower
3031local hook_Run = hook .Run
@@ -1032,36 +1033,46 @@ function BaseClass:GetRelationship(value, default)
10321033end
10331034
10341035function BaseClass :HasTeam (value )
1035- local value = value
1036- if self .data .team ~= nil and value ~= nil then
1037- if isstring (value ) then
1038- return table_HasValueBySeq (self .data .team , value )
1036+ if self .data == nil or self .data .team == nil or value == nil then
1037+ return false
1038+ end
1039+
1040+ if isstring (value ) then
1041+ return table_HasValueBySeq (self .data .team , value )
1042+ end
1043+
1044+ if isentity (value ) then
1045+ if isfunction (value .IsPlayer ) and value :IsPlayer () then
1046+ if table_HasValueBySeq (self .data .team , ' player' ) then
1047+ return true
1048+ else
1049+ return bgNPC :GetModule (' team_parent' ):HasParent (value , self )
1050+ end
1051+ elseif value .isBgnActor and ((isfunction (value .IsNPC ) and value :IsNPC ()) or (isfunction (value .IsNextBot ) and value :IsNextBot ())) then
1052+ local actor = bgNPC :GetActor (value )
1053+ if actor then value = actor end
10391054 end
1055+ end
10401056
1041- if isentity (value ) then
1042- if value :IsPlayer () then
1043- if table_HasValueBySeq (self .data .team , ' player' ) then
1044- return true
1045- else
1046- return bgNPC :GetModule (' team_parent' ):HasParent (value , self )
1047- end
1048- elseif value .isBgnActor and (value :IsNPC () or value :IsNextBot ()) then
1049- local actor = bgNPC :GetActor (value )
1050- if not actor then return false end
1051- value = actor :GetData ().team
1057+ if istable (value ) then
1058+ if value .isBgnClass and isfunction (value .GetData ) then
1059+ local data = value :GetData ()
1060+ if istable (data ) and istable (data .team ) then
1061+ value = data .team
10521062 end
10531063 end
10541064
1055- if istable (value ) then
1056- if value .isBgnClass then value = value :GetData ().team end
1065+ if not table_isArray (value ) then
1066+ return false
1067+ end
10571068
1058- for i = 1 , # self .data .team do
1059- for k = 1 , # value do
1060- if self .data .team [i ] == value [k ] then return true end
1061- end
1069+ for i = 1 , # self .data .team do
1070+ for k = 1 , # value do
1071+ if self .data .team [i ] == value [k ] then return true end
10621072 end
10631073 end
10641074 end
1075+
10651076 return false
10661077end
10671078
0 commit comments