This entire piece of code is so confusing and repetitive.
- The player that executes the command is always connected (duh) so that check is completely redundant to begin with.
- If giveplayerid is connected then giveplayerid is obviously not INVALID_PLAYER_ID so that check is also completely redundant.
- You start a loop for sizeof(CarInfo) times, but I have no idea why. The iterating variable (i) isn't even being used.
- Use an array for pCarkey instead of creating five separate attributes.