All pastes #514895 Raw Edit

Anonymous

public lua v1 · immutable
#514895 ·published 2007-05-27 23:45 UTC
rendered paste body
// Select the player spawn pointfunction GM:PlayerSelectSpawn(pl)	local selectedSpawn	local spawnPoints = ents.FindByClass("info_player_start") 	selectedSpawn = spawnPoints[1]	return selectedSpawnend// Execute the first time the player spawnsfunction GM:PlayerInitialSpawn(pl)	pl:PrintMessage(HUD_PRINTTALK, "This server is running AMT's Half-Life 2 Campaign mod.\nType !help in chat for more information.")	pl.cachedSpawns = {}	local numberOfPlayers = table.Count(player.GetAll())		// Decide where to spawn vehicle	if currentMap == "d1_canals_05" || currentMap == "d2_coast_01" then		pl.spawnVehicleOnPlayer = 0	elseif mapSetupTable[currentMap][4] >= 1 then		pl.spawnVehicleOnPlayer = 1	end		// Don't spawn a vehicle, he's the only person	if numberOfPlayers == 1 then		pl.spawnVehicle = 0	end		// Kill silent	if numberOfPlayers > 1 then		pl:KillSilent()		pl.selectedSpawn = nil	endend// Find out if it is safe to spawnfunction GM:PlayerDeathThink(pl)	local numberOfPlayers = table.Count(player.GetAll())		// Check to see how many peeps we got	if numberOfPlayers >= 2 then		for _, playerID in pairs(player.GetAll()) do			if table.Count(playerID.cachedSpawns) > 1 then				pl.selectedSpawn = playerID				pl:Spawn()				GAMEMODE:PlayerSpawn(pl)			end		end	elseif numberOfPlayers == 1 then		pl:Spawn()	endend// Execute this every time a player spawnsfunction GM:PlayerSpawn(pl)	local numberOfPlayers = table.Count(player.GetAll())		// Move player to cached spawn point if selected spawn is player	if pl.selectedSpawn:IsPlayer() then		selectedPlayer = pl.selectedSpawn		pl:SetPos(selectedPlayer.cachedSpawns[table.Count(selectedPlayer.cachedSpawns) - 1])		table.remove(selectedPlayer.cachedSpawns, table.Count(selectedPlayer.cachedSpawns) - 1)	end		// If there is only one person, than respawn that player on last cached spawn	if numberOfPlayers == 1 then		if table.Count(pl.cachedSpawns) > 0 then			pl:SetPos(pl.cachedSpawns[table.Count(pl.cachedSpawns)])		end	end		// Give player any weapons they may have had	if pl.deathWeapons != nil then		for _, deathWeapon in pairs(pl.deathWeapons) do			pl:Give(deathWeapon)		end	else		for weaponCount = 1, mapSetupTable[currentMap][1] do			pl:Give(weaponsTable[weaponCount])		end		if currentMap == "d1_canals_06" then			pl:Give("weapon_physcannon")		end	end			// Decide what vehicle needs to be spawned	if mapSetupTable[currentMap][4] == 1 then		vehicleName = "airboat"		vehiclesOnMap = ents.FindByClass("prop_vehicle_airboat")	elseif mapSetupTable[currentMap][4] == 2 then		vehicleName = "airboat_gun"		vehiclesOnMap = ents.FindByClass("prop_vehicle_airboat")	elseif  mapSetupTable[currentMap][4] == 3 then		vehicleName = "jeep"		vehiclesOnMap = ents.FindByClass("prop_vehicle_jeep")	end		// Check to see if this is the first time they get the vehicle	if pl.spawnVehicle == 1 then		if pl.spawnVehicleOnPlayer == 1 then			newVehicle = vehicles.PlayerSpawn(pl, vehicleName, pl:GetPos() + pl:GetAngles():Forward() * 150, pl:GetAngles():Up())		elseif pl.spawnVehicleOnPlayer == 0 then			newVehicle = vehicles.PlayerSpawn(pl, vehicleName, vehiclesOnMap[1]:GetPos() + vehiclesOnMap[1]:GetAngles():Right() * 180, vehiclesOnMap[1]:GetAngles():Up())		end		masterVehicleList[pl:UserID()] = newVehicle	else		masterVehicleList[pl:UserID()] = nil	end		// Give the player ammo	pl:GiveAmmo(40/hl2c_difficulty, "Pistol")	pl:GiveAmmo(40/hl2c_difficulty, "SMG1")	pl:GiveAmmo(40/hl2c_difficulty, "AR2")	pl:GiveAmmo(12/hl2c_difficulty, "Buckshot")	pl:GiveAmmo(12/hl2c_difficulty , "357")	pl:GiveAmmo(12/hl2c_difficulty, "XBowBolt")		// Set the player model	GAMEMODE:PlayerSetModel(pl) 		// Nocollide with other players for 5 seconds	pl:SetCollisionGroup(1)	timer.Simple(5, pl.SetCollisionGroup, pl, 5)	pl.selectedSpawn = nilend