Gamemode.IsSpawnpointSuitable
From GMod Wiki
Event Hook | |
Hook Name | IsSpawnpointSuitable |
Syntax | GM:IsSpawnpointSuitable( Player player, Entity spawnpointent, Boolean bMakeSuitable ) |
Description | Determine whether a spawn-point is suitable or obstructed |
Returns | Boolean |
Lua State | |
BBCode | [b][url=wiki.garrysmod.com/?title=Gamemode.IsSpawnpointSuitable]Gamemode.IsSpawnpointSuitable [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] |
Examples
Description | Function that finds a random suitable info_player_start, or makes a spawn suitable if it reaches the last iteration of the for loop |
---|---|
Used on | |
Code | function GM:FindSuitableSpawn() local SpawnEnts = ents.FindByClass("info_player_start") for i=0, 6 do local RandomSpawn = math.random(#SpawnEnts) if (self:IsSpawnpointSuitable( pl, SpawnEnts[RandomSpawn], i==6)) then return SpawnEnts[RandomSpawn] end end return SpawnEnts[RandomSpawn] end |
Output | Entity info_player_start |