All pastes #150394 Raw Edit

Mine

public lua v1 · immutable
#150394 ·published 2006-08-26 21:11 UTC
rendered paste body
--- [[[ Hockeyzone Script ]]] ------ [[ Includes ]] ------ [[ Globals ]] --------g_arena = nil		-- The global arena class, to avoid having to pass it around functions--- [[ Other Functions ]] ----- IsInGoals = Determines whether the given player is in the goalies for the specified teamfunction IsInGoals(goalie)	-- Get the player's coordinates	local c = goalie:coords()	-- Check his coordinates, based on what team he's on	if (goalie:getTeam().m_name == "Home") then		-- check his coordinates		if (x > 400 and x < 650 and y > 650 and y < 975) then			return true		end				-- He's not in goals		return false	else		if (x > 3200 and x < 3450 and y > 650 and y < 975) then			return true		end				-- He's not in goals		return false	endend--- [[ Event Functions ]] ---function Arena_OnCreate(arena)	-- Set our global value	g_arena = arena	-- Initialize random	math.randomseed(os.time())endfunction Sport_OnGoal(scorer)	-- After a goal we need to warp the teams back to their respective sides	-- Do the Home team first..	local hometeam = team_fromname(g_arena, "Home")			if hometeam:exists() then		-- For every player on the team..		local numgoalies = 0		local lastgoalienotingoals = nil		local lastgoalie = nil		for x = 1, hometeam:num() do			-- If player is a spectator, ignore him			if (curplyr:spectator() == false) then				-- If he is a goalie, we want to warp him near the goals				local curplyr = hometeam:get(x)				if (curplyr:getVehicle():vehicletypeid() > 1500) then					-- Check if he's isn't in goals					lastgoalie = curplyr					if (IsInGoals(curplyr) == false) then						lastgoalienotingoals = curplyr					end					numgoalies = numgoalies + 1					-- warp the goalie to the goals, depending on his team					curplyr:warp(480, 820, 0)				else					-- Otherwise he's another player.. warp him to his side					curplyr:warp(944, 820, 40)				end				-- If we had more than one goalie..				if (numgoalies > 1) then					-- we either change the goalie which isn't in goals...					if (lastgoalienotingoals ~= nil) then						-- ..to a center dude						lastgoalienotingoals:setVehicle(4)						lastgoalienotingoals:warp(944, 820, 40)						-- Inform him what happened						lastgoalienotingoals:message("!You have been forced to a center, only one goalie is allowed.")					else						-- Or we have to change one of the two goalies in goal						-- ..to a center dude						lastgoalie:setVehicle(4)						lastgoalie:warp(944, 820, 40)						-- Inform him what happened						lastgoalie:message("!You have been forced to a center, only one goalie is allowed.")					end				end			end		end	end	-- Now we need to do the away team	local awayteam = team_fromname(g_arena, "Home")			if awayteam:exists() then		-- For every player on the team..		local numgoalies = 0		local lastgoalienotingoals = nil		local lastgoalie = nil		for x = 1, awayteam:num() do			-- If player is a spectator, ignore him			if (curplyr:spectator() == true) then				-- If he is a goalie, we want to warp him near the goals				local curplyr = awayteam:get(x)				if (curplyr:getVehicle():vehicletypeid() > 1500) then					-- Check if he's isn't in goals					lastgoalie = curplyr					if (IsInGoals(curplyr) == false) then						lastgoalienotingoals = curplyr					end					numgoalies = numgoalies + 1					-- warp the goalie to the goals, depending on his team					curplyr:warp(3300, 820, 0)				else					-- Otherwise he's another player.. warp him to his side					curplyr:warp(2900, 820, 40)				end				-- If we had more than one goalie..				if (numgoalies > 1) then					-- we either change the goalie which isn't in goals...					if (lastgoalienotingoals ~= nil) then						-- ..to a center dude						lastgoalienotingoals:setVehicle(4)						lastgoalienotingoals:warp(2900, 820, 40)						-- Inform him what happened						lastgoalienotingoals:message("!You have been forced to a center, only one goalie is allowed.")					else							-- Or we have to change one of the two goalies in goal						-- ..to a center dude						lastgoalie:setVehicle(4)						lastgoalie:warp(2900, 820, 40)						-- Inform him what happened						lastgoalie:message("!You have been forced to a center, only one goalie is allowed.")					end				end			end		end	endend