View Single Post
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 10-11-2020 , 06:47   Re: Rank System [ Ranks | Levels | EXP ]
Reply With Quote #9

Quote:
Originally Posted by Supremache View Post
Well, It's beta version and started to learn the scripting before some months but it's okay i learning everyday new thing and i'm happy when some one support me and provide me some suggestions..

But i want to ask about what do you mean about hardcoded ? I think my plugin is so easy and I have put "Rank Name" beside "EXP" for being easy for who want to editing them.
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.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be