What silva said, basicly. First convert the player, then check the counters.
CHL2MP_Player* pHLPlayer = ToHL2MPPlayer(pPlayer);
if ( pHLPlayer )
{
playercountertotal++;
if (pHLPlayer->GetPlayerLives() > 0)
playercounter++;
}
Nuno Silva wrote:
> I'm no pro at Source Modding, but this piece of code looks kind of weird.
> Please notice that i dont do any Source SDK work, so i might be wrong.
>
> How are you getting pPlayer? Because it feels irrational that
> playercounter++ would be >= 2.
>
> Also, what Willem Engel means is that you should do something like this:
>
> if ( pPlayer && ToHL2MPPlayer(pPlayer) &&
> ToHL2MPPlayer(pPlayer)->GetPlayerLives()>= 0 )
>
> Because if ToHL2MPPlayer fails, you'll probably be accessing a null pointer,
> though that may not be the case since you dont mention any crashes.
>
> Also, shouldnt it be > instead of >=?
>
> Sorry if this reply doesnt help much. As i said, i dont code on the SDK
> nowadays. Good luck.
> _______________________________________________
> To unsubscribe, edit your list preferences, or view the list archives, please
> visit:
> http://list.valvesoftware.com/mailman/listinfo/hlcoders
>
_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please
visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders