Page 1 of 1

Advanced Teleporter troubles

Posted: Sat Oct 03, 2009 7:10 pm
by Fiodis
I need a teleporter from location A to location B, but there isn't a clear route between the two. So I use the kill-and-forced-respawn type teleporter:
Hidden/Spoiler:
[code] local matrixofunit = GetEntityMatrix(GetCharacterUnit(person))
KillObject(person)
local guy = GetCharacterUnit(person)
SelectCharacterClass(guy, "imp_inf_engineer")
SpawnCharacter(guy, matrixofunit)[/code][/size]
Obviously an event (OnObjectKill, a lever object) triggers this. The beginning goes ObObjectKill(lever, person), so person is the one who kills the lever. My problem is that it doesn't work, and I get a CTD with nothing in the error log about it. Thoughts? I'm certain it's the SelectCharacterClass that's the problem....but the three stock scripts that the Example Finder dredged up weren't much help.

I'm having quite a lot of trouble with LUA lately. :wink:

Re: Advanced Teleporter troubles

Posted: Sun Oct 04, 2009 12:38 pm
by [RDH]Zerted
Characters aren't ingame objects, units are. Kill the player's unit not his character.

You (attempt to) kill the player's unit then try to use it. It's dead and gone, don't use things that are destroyed. SelectCharacterclass works on characters not units.

Third, unless you want to force the player to become an engineer, there is no need for the SelectCharacterClass statement. If you just respawn the character, it will respawn as its last selected unit class unless the class's memory pools are full.