View Single Post
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 10-11-2020 , 07:21   Re: Rank System [ Ranks | Levels | EXP ]
Reply With Quote #9

Quote:
Originally Posted by Napoleon_be View Post
For example this is hardcoding your array size:

PHP Code:
new szName[32];
get_user_name(idszName31); 
This is just a simple example, if you declare your arrays globaly and need to retrieve the array size multiple times, you should use charsmax() instead of hardcoding the array size everytime. When using charsmax(), you only have to change the array size (if u ever have to) and everything will be fine.

For example, if szName[32] ever becomes szName[64], you have to redo every single line where you used that array.

charsmax() fixes this problem.

PHP Code:
new szName[32];
get_user_name(idszNamecharsmax(szName)); 
charsmax is the same as sizeof() - 1. The function itself says it, maximum characters available for the array.
Well, thanks i understand but what is better sizeof() -1 or charsmax()
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
Supremache is offline