Thread: (Request) Lua request.
View Single Post
Old 04-04-2015, 08:31 PM   #4
R00Kie
Kawaii! ルーキー
Lua Team
Wiki Team
Fortress Forever Staff
 
R00Kie's Avatar
 
Join Date: Jan 2008
Location: Nowhere, Kansas
Class/Position: Random
Gametype: CTF
Affiliations: BiG, Kawaii!, MustacheBrigade, GoodFellas
Posts Rated Helpful 82 Times
FDA, Here's the second part to the lua for spawn point control you asked for.
The starting spawn point should be named spawn0. All the others in different arenas should be named spawn1, spawn2, ect. The players can switch between arenas with the '!arena [number]' chat command. For example !arena 3 will put them in arena 3 and continue to spawn them there until they change their arena. If you have more or less than 6 arenas then change the ARENA_NUM variable to how many you have. If you have any issues, send me a PM.
Code:
player_table = {}
ARENA_NUM = 6 -- Increase this number if you want more spawn points.

function player_connected( player )
	player_table[player:GetId()] = { arena = 0 }
end

base_spawn = info_ff_teamspawn:new({ arena_number = 0, validspawn = function(self,player)
	return player:GetTeamId() == Team.kRed or player:GetTeamId() == Team.kBlue and self.arena_number == player_table[player:GetId()].arena
end })

-- For setting a spawnpoint Use spawn1, spawn2, ect.
-- Use Spawn0 as the inital spawn point.
for i = 0, ARENA_NUM do
	_G["spawn"..i] = base_spawn:new({ arena_number = i })
end

function player_onchat( player, chatstring )
	local player = CastToPlayer( player )

	-- string.gsub call removes all control characters (newlines, return carriages, etc)
	-- string.sub call removes the playername: part of the string, leaving just the message
	local message = string.sub( string.gsub( chatstring, "%c", "" ), string.len(player:GetName())+3 )
	
	for i = 1, ARENA_NUM do
		if message == "!arena "..i then
			ChatToPlayer(player, "Sending you to Arena "..tostring(i))
			player_table[player:GetId()].arena = i
			ApplyToPlayer(player, { AT.kRespawnPlayers })
			return false
		end
	end
	return true
end
__________________
Released: [ Island ] [ Rookie ] [ Limbo ] [ Sonic ] [ Tomb ] [ Skydive2 ] [ Bunkerwars ]
Beta: [ Argon ] [ Reflection ] [ Urbantag ]
Lua: [ game_rules ]
R00Kie is offline   Reply With Quote


2 members found this post helpful.