OnNPCClassSelect: Difference between revisions
No edit summary |
No edit summary |
||
Line 5: | Line 5: | ||
desc=This function is called when server grants a class to NPC to select for spawning. This function is called not when npc selects a class, but rather when a class is presented to npc.| | desc=This function is called when server grants a class to NPC to select for spawning. This function is called not when npc selects a class, but rather when a class is presented to npc.| | ||
params=<syntaxhighlight lang="lua">NoParams</syntaxhighlight>| | params=<syntaxhighlight lang="lua">NoParams</syntaxhighlight>| | ||
retvals=Return true if [[RequestSpawn]] was used or you do not want to spawn npc in this class. Then the program will not send another 'request for spawn' to server. If you return 0, the call will be passed to plugins and if all plugins return 0, then a 'request for spawn' will be send to server.| | retvals=Return '''1''' (return true is bugged as of dec.2023. fixed in next version) if [[RequestSpawn]] was used or you do not want to spawn npc in this class. Then the program will not send another 'request for spawn' to server. If you return 0, the call will be passed to plugins and if all plugins return 0, then a 'request for spawn' will be send to server.| | ||
example=<source lang="lua"> | example=<source lang="lua"> | ||
function OnNPCClassSelect() | function OnNPCClassSelect() |
Latest revision as of 15:14, 25 December 2023
This function was added in v1.6 beta 4 patch2 and will not work on previous versions.
Description:
This function is called when server grants a class to NPC to select for spawning. This function is called not when npc selects a class, but rather when a class is presented to npc.
Parameters:
NoParams
Return Values:
Return 1 (return true is bugged as of dec.2023. fixed in next version) if RequestSpawn was used or you do not want to spawn npc in this class. Then the program will not send another 'request for spawn' to server. If you return 0, the call will be passed to plugins and if all plugins return 0, then a 'request for spawn' will be send to server.
Important Note:
The npc's team, color and weapons are set according to the classes value, before the function is called.
Example
function OnNPCClassSelect() { if(GetPlayerSkin(GetMyID())==1) //cop skin in some class RequestSpawn(); else RequestClass(CLASS_NEXT); return 1 }
Related Functions
The following functions may be helpful as they relate to this function in one way or another.