fixing some indexes out of bounds

This commit is contained in:
jenz 2024-02-23 20:01:24 +01:00
parent 226cf3319b
commit 2d661b5a30

View File

@ -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 =
@ -69,9 +69,14 @@ public Action:Event_PlayerSpawn( Handle:event, const String:name[], bool:dontBro
if( GetConVarInt( gPluginEnabled ) == 1 )
{
new id = GetClientOfUserId( GetEventInt( event, "userid" ) );
if (!IsValidClient(id))
{
return Plugin_Handled;
}
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;
}