How to save statistic on player name?
Who can help?
Thanks!
How to save statistic on player name?
Who can help?
Thanks!
PHP Code:
f=openfile("users/stats/"+self.name+".cfg", "write");
fprintln(f, self.stat["rank"]);
fprintln(f, self.stat["xp"]);
fprintln(f, self.stat["needxp"]);
fprintln(f, self.stat["prestige"]);
closefile(f);
Indeed, which is why you should always strip a player's name from any non-alphanumeric symbols. This is the method I use:
Code:filename = sanitizeName( self.name ) + "_data.ini;Code:sanitizeName( str ) { if( !isDefined( str ) || str == "" ) return ""; validchars = "0123456789AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz"; tmpname = monotone( str ); string = ""; prevchr = ""; for( i = 0; i < tmpname.size; i++ ) { chr = tmpname[i]; if( chr == "." ) { if( !string.size ) continue; // avoid leading dots if( chr == prevchr ) continue; // avoid double dots } else if( chr == "[" ) chr = "{"; else if( chr == "]" ) chr = "}"; prevchr = chr; for( j = 0; j < validchars.size; j++ ) { if( chr == validchars[j] ) { string += chr; break; } } } if( string == "" ) string = "noname"; return string; } monotone( str ) { if( !isDefined( str ) || ( str == "" ) ) return( "" ); s = ""; colorCheck = false; for( i = 0; i < str.size; i++ ) { ch = str[ i ]; if( colorCheck ) { colorCheck = false; switch( ch ) { case "0": // black case "1": // red case "2": // green case "3": // yellow case "4": // blue case "5": // cyan case "6": // pink case "7": // white case "8": // Olive case "9": // Grey break; default: s += ( "^" + ch ); break; } } else if( ch == "^" ) colorCheck = true; else s += ch; } return( s ); }