Problem is that sometimes you are replacing one character with two characters, and let's say a player has a name of length 32 which is max, but 5 of the chars are ', then you need length 37 to store the replaced version.
easy fix is to change szName[33] (which should be 32 anyways) to szName[64] but this will sometimes clip the player's name if you try to set his name to the newly generated name, since it's too long for the game
also, you must never return a string in AMXX
you must pass the array via reference which will edit the original array
PHP Code:
public using_the_stock(id) {
new theName[64];
get_user_name_ex(id, theName, charsmax(theName));
}
stock get_user_name_ex(id, szName[], len)
{
get_user_name(id, szName, len);
replace_all(szName, len, "'", "\'");
replace_all(szName, len, "^"", "\^"");
replace_all(szName, len, ".", "");
}
__________________