Quote:
Originally Posted by Natsheh
Yeah i am still getting undefined crashes so its best to avoid the first example.
|
It makes perfect sense that you are getting errors using the first code snippet.
PHP Code:
new szName[32];
get_user_name(id, szName[10], charsmax(szName));
szName has 32 cells but in get_user_name you pass szName[10] which will pass cells 10, 11, 12, ...., 31(a buffer with only 22 cells). Your 3rd argument, the buffer size, is charsmax(szName) which will return 31. 31 > 22 so the native will attempt to write up to 31 characters in a buffer that can only hold 22.
This is the same as doing
PHP Code:
new buf[22]
for(int i = 0; i < 32; i++)
{
buf[i] = i
}
__________________