OnNPCClassSelect: Difference between revisions
No edit summary |
No edit summary |
||
Line 7: | Line 7: | ||
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 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.| | ||
example=<source lang="lua"> | example=<source lang="lua"> | ||
function OnNPCClassSelect() | function OnNPCClassSelect() | ||
{ | { | ||
if(GetPlayerSkin(GetMyID())==1) //cop skin in some class | |||
RequestSpawn(); | |||
} | else | ||
RequestClass(CLASS_NEXT); | |||
return 1 | |||
} | |||
</source>| | </source>| | ||
note=The npc's team, color and weapons are set according to the classes value, before the function is called.| | note=The npc's team, color and weapons are set according to the classes value, before the function is called.| |
Revision as of 08:15, 25 May 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 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.
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.