Need help with GetCharacterTeam() [Solved]
Posted: Mon Mar 08, 2021 1:48 pm
I'm working on a lua function and I'm currently struggling with the correct usage of GetCharacterTeam().
The base of the code looks like this:
The above code works fine, now here's the part where I'm messing up. I want the code to only execute when the object is in the opposing team as the attacker. I tried several approaches with GetCharacterTeam() and GetObjectTeam(), but I'm pretty sure I'm not using the function correctly. I tried it like this:
then I tried it like this:
and like this:
This is the error I'm getting:
The base of the code looks like this:
Code: Select all
OnObjectDamage
(
function(object,attacker)
if attacker == nil then return end
if not IsCharacterHuman(attacker) then return end
ScriptCB_SndPlaySound("sound")
end
)Code: Select all
if GetCharacterTeam(object) == 1 and GetCharacterTeam(attacker) == 1 then return end
if GetCharacterTeam(object) == 2 and GetCharacterTeam(attacker) == 2 then return end
if GetCharacterTeam(object) == 0 then return end
Code: Select all
if GetCharacterTeam(attacker) == if GetCharacterTeam(object) or if GetCharacterTeam(object) == 0 then return endCode: Select all
attackerTeam = GetCharacterTeam(attacker)
objectTeam = GetCharacterTeam(object)
if attackerTeam == objectTeam or if objectTeam == 0 then return end
Can anyone tell me how to implement this code corretly so it checks if the object that gets hit is on the enemy team?CallProc failed: bad argument #1 to `GetCharacterTeam' (number expected, got userdata)
stack traceback:
[C]: in function `GetCharacterTeam'
(none): in function <(none):91>