diff --git a/ZombieRiot/scripting/Medic.sp b/ZombieRiot/scripting/Medic.sp index 3694f7fa..0dc3641b 100644 --- a/ZombieRiot/scripting/Medic.sp +++ b/ZombieRiot/scripting/Medic.sp @@ -18,7 +18,7 @@ new Handle:gShowInChat = INVALID_HANDLE; new Handle:gMaxTimeUse = INVALID_HANDLE; new gPlayerMoney; -new gUsedMedic[ 33 ]; +new gUsedMedic[ MAXPLAYERS + 1 ]; public Plugin:myinfo = @@ -66,12 +66,17 @@ public OnMapStart() } public Action:Event_PlayerSpawn( Handle:event, const String:name[], bool:dontBroadcast ) { - if( GetConVarInt( gPluginEnabled ) == 1 ) - { - new id = GetClientOfUserId( GetEventInt( event, "userid" ) ); + if( GetConVarInt( gPluginEnabled ) == 1 ) + { + new id = GetClientOfUserId( GetEventInt( event, "userid" ) ); + if (!IsValidClient(id)) + { + return Plugin_Handled; + } - gUsedMedic[ id ] = 0; - } + gUsedMedic[ id ] = 0; + } + return Plugin_Handled; } public Action:Command_Medic( id, args ) { @@ -169,3 +174,13 @@ stock AttachClientIcon( index ) TE_WriteNum( "m_iAttachToClient", index ); TE_SendToAll(); } + + +stock bool IsValidClient(int client) +{ + if (client > 0 && client <= MaxClients && IsClientConnected(client) && IsClientInGame(client)) + { + return true; + } + return false; +}