PDA

View Full Version : Teamspawns won't work.


Bridget
03-07-2010, 02:48 AM
I have a collection which I will store players names in as the game progresses. I have two spawns for each team. One spawn is a regular spawn and the other is a special spawn. They work so that if you're in the collection, you spawn in the special spawn. If you're not in the collection, you default to the regular spawn. Here's the code:

acollection = Collection()

regularspawn = info_ff_teamspawn:New({})
specialspawn = info_ff_teamspawn:New({})

function regularspawn:validspawn(spawn, player)
if(acollection:HasItem(player)) then
return false
end
return true
end

function specialspawn:validspawn(spawn, player)
if(acollection:HasItem(player)) then
return true
end
return false
end

Now, there's a problem with that. Whenever I join my map, it will automatically drop me at a random spawn. Sometimes it drops me at spawns that are named regularspawn and sometimes it drops me at specialspawns, despite not being in the collection. It seems to completely ignore the code. I can pepper the functions with ConsoleToAll('...') for debugging, but every spawn, I don't get any message in my console. Any clue why? Am I typing something incorrectly? I am legitimately stumped. :|

squeek.
03-07-2010, 03:41 AM
1) new({}) might need to be lowercase.
2) You need to add the functions as "members" of the spawns.
3) Name the variable that holds the function "validspawn"

I forget exactly how to reference a function, but it might be something like this:
specialspawn = info_ff_teamspawn:new({ validspawn = specialspawn:validspawn })

This is how spawns are usually done:
spawn_thing = info_ff_teamspawn:new({ validspawn = function(self,player)
if condition then
return true
end
return false
end })

Bridget
03-07-2010, 03:05 PM
I tried both referencing (it requires parenthesizes) and the following. The spawns are correctly named in Valve Hammer, yet the game completely ignores the coding for spawns and places the player at random. I don't get any ConsoleToAll returns.

SpecialSpawn = info_ff_teamspawn:new({ validspawn = function(self, player)
ConsoleToAll('SpecialSpawn call')
if(acollection:HasItem(player)) then
return true
end
return false
end })

squeek.
03-07-2010, 07:47 PM
Try moving it up to the top of the lua or something. Sometimes certain lua errors don't report in the console but will nullify any code below them.