Change character class on spawn [Solved]
Posted: Sat May 09, 2015 6:53 am
Hi! I want to change character class when he is spawning. I tried this code, but it doesn't work:
What am I doing wrong? I will be grateful if you can help me.
EDIT
I tried this code:
It doesn't work. But it works only if I change GetCharacterTeam(character) == IMP to GetCharacterTeam(character) == ALL. Of course, after that I need to spawn as Alliance to respawn as a Darth Vader. What am I doing wrong?
Double posting is against the RULES; please EDIT your post instead -Staff
Code: Select all
OnCharacterSpawn(function(character)
if GetCharacterTeam(character) == IMP and GetReinforcementCount(IMP) == 1 then
SelectCharacterClass(character,"imp_hero_darthvader")
end
end)
EDIT
I tried this code:
Code: Select all
vaderspawn = true
OnCharacterSpawn(function(character)
if GetCharacterTeam(character) == IMP and vaderspawn and GetReinforcementCount(IMP) == 1 then
local loc = GetEntityMatrix(GetCharacterUnit(character))
AddReinforcements(IMP, 1)
KillObject(GetCharacterUnit(character))
SelectCharacterTeam(character, IMP)
SelectCharacterClass(character,"imp_hero_darthvader")
SpawnCharacter(character, loc)
vaderspawn = false
end
end)
Double posting is against the RULES; please EDIT your post instead -Staff