Gamemode.PlayerSpawnNPC

From GMod Wiki

Jump to: navigation, search
Event Hook
Hook NamePlayerSpawnNPC
SyntaxGM:PlayerSpawnNPC( Player ply, String npc, String weapon )
DescriptionCalled when a player spawns an NPC
ReturnsBoolean
Lua StateNewerServer.png
BBCode[b][url=wiki.garrysmod.com/?title=Gamemode.PlayerSpawnNPC]Gamemode.PlayerSpawnNPC [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]


Examples

DescriptionBlocks the spawning of the npc_antlion NPC, and tells the player that the he's not allowed to spawn it.
Used onNewerServer.png
Code
function NPCSpawn( pl, npc_type, npc_weapon )
 
    if npc_type == "npc_antlion" then -- checks if it's an antlion
 
	pl:PrintMessage(HUD_PRINTCENTER,"You're not allowed to spawn Antlions!"); -- Prints it to the player's chat
 
	return false; -- We return false to block the spawning, it's true by default.
    end
 
end
 
hook.Add( "PlayerSpawnNPC", "playerSpawnNPCTest", NPCSpawn );
OutputN/A


Additional Notes

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox