@@ -54,7 +54,7 @@ public Plugin:myinfo = {
5454 name = " Admin Tools" ,
5555 author = " Chanz, Berni" ,
5656 description = " Collection of mighty admin commands" ,
57- version = " 1.4 " ,
57+ version = " 1.5 " ,
5858 url = " http://bcserv.eu/"
5959}
6060
@@ -140,6 +140,7 @@ new g_iMap_SpawnPoints[MAX_TEAMS];
140140new bool :g_bClient_PointActivated [MAXPLAYERS +1 ];
141141new Float :g_flClient_PointSize [MAXPLAYERS +1 ];
142142new bool :g_bClient_IsBuried [MAXPLAYERS +1 ];
143+ new bool :g_bClient_HadFirstSpawn [MAXPLAYERS +1 ];
143144
144145// M i s c
145146
@@ -185,7 +186,7 @@ public OnPluginStart()
185186 g_cvarMpTimelimit = FindConVar (" mp_timelimit" );
186187
187188 // Event Hooks
188-
189+ PluginManager_HookEvent ( " player_spawn " , Event_PlayerSpawn , EventHookMode_Post , false );
189190
190191 // Library
191192
@@ -267,6 +268,11 @@ public OnClientPostAdminCheck(client)
267268 Client_Initialize (client );
268269}
269270
271+ public OnClientDisconnect (client )
272+ {
273+ g_bClient_HadFirstSpawn [client ] = false ;
274+ }
275+
270276/* *************************************************************************************
271277
272278
@@ -1819,9 +1825,11 @@ public Action:Command_Respawn(client, args) {
18191825 tn_is_ml
18201826 );
18211827
1828+ // Remove players that are not in the right teams, to prevent ghost spawning.
1829+ // Example: Respawning a spectator is a bad idea.
18221830 for (new i = 0 ; i < target_count ; ++ i ) {
18231831
1824- if (! Client_IsValid (target_list [i ]) || GetClientTeam (target_list [i ]) <= 1 ){
1832+ if (! g_bClient_HadFirstSpawn [ client ] || ! Client_IsValid (target_list [i ]) || ! IsClientInGame ( client ) || GetClientTeam (target_list [i ]) == TEAM_SPECTATOR ){
18251833
18261834 new j = i ;
18271835 for (; j + 1 < target_count ; ++ j ) {
@@ -1847,6 +1855,7 @@ public Action:Command_Respawn(client, args) {
18471855 AdminToolsShowActivity (client , Plugin_Tag , " Respawned target %s " , target );
18481856 return Plugin_Handled ;
18491857}
1858+
18501859public Action :Command_Team (client , args ) {
18511860
18521861 if (args != 2 ) {
@@ -2836,6 +2845,17 @@ public Action:Command_Deprecated(client,args){
28362845 E V E N T S
28372846
28382847**************************************************************************************/
2848+ public Action :Event_PlayerSpawn (Handle :event , const String :name [], bool :dontBroadcast ){
2849+
2850+ new client = GetClientOfUserId (GetEventInt (event , " userid" ));
2851+ if (! Client_IsValid (client )) {
2852+ return Plugin_Continue ;
2853+ }
2854+
2855+ g_bClient_HadFirstSpawn [client ] = true ;
2856+ return Plugin_Continue ;
2857+ }
2858+
28392859public Action :Event_CommandEvent (Handle :event , const String :name [], bool :dontBroadcast ){
28402860
28412861 new String :eventName [MAX_NAME_LENGTH ];
@@ -3326,12 +3346,21 @@ stock CS_GetSpawnPointCount(team)
33263346 return count ;
33273347}
33283348
3329- stock RespawnPlayer (client ){
3330-
3331- if (GetEngineVersion () == Engine_CSS && g_bExtensionCstrikeLoaded ) {
3349+ stock RespawnPlayer (client )
3350+ {
3351+ new EngineVersion :engineVersion = GetEngineVersion ();
3352+ if (engineVersion == Engine_CSS && g_bExtensionCstrikeLoaded ) {
33323353 // TODO Make it work in all games
33333354 CS_RespawnPlayer (client );
33343355 }
3356+ // TODO: This maybe break at some day, but Synergy is 19 and we respawn players with DispatchSpawn in this game.
3357+ else if (engineVersion == EngineVersion :19 ) {
3358+
3359+ if (IsPlayerAlive (client )) {
3360+ ForcePlayerSuicide (client );
3361+ }
3362+ DispatchSpawn (client );
3363+ }
33353364 else {
33363365 ThrowError (" This plugin does not support RespawnPlayer on this game" );
33373366 }
@@ -3411,18 +3440,24 @@ stock Client_Initialize(client)
34113440 // Functions
34123441
34133442
3414- /* Functions where the player needs to be in game
3443+ /* Functions where the player needs to be in game */
34153444 if (! IsClientInGame (client )){
34163445 return ;
34173446 }
3418- */
3447+
3448+ if (! IsPlayerAlive (client )) {
3449+ return ;
3450+ }
3451+
3452+ g_bClient_HadFirstSpawn [client ] = true ;
34193453}
34203454
34213455stock Client_InitializeVariables (client )
34223456{
34233457 // Client Variables
34243458 g_bClient_PointActivated [client ] = false ;
34253459 g_bClient_IsBuried [client ] = false ;
3460+ g_bClient_HadFirstSpawn [client ] = false ;
34263461}
34273462
34283463
0 commit comments