Raised This Month: $ Target: $400
 0% 

get user name


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
aron9forever
Veteran Member
Join Date: Feb 2013
Location: Rromania
Old 06-18-2017 , 10:23   Re: get user name
Reply With Quote #2

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(idtheNamecharsmax(theName));
}

stock get_user_name_ex(idszName[], len)
{
    
get_user_name(idszNamelen);

    
replace_all(szNamelen"'""\'");
    
replace_all(szNamelen"^"", "\^"");
    
replace_all(szNamelen".""");

__________________
Meanwhile, in 2050:
Quote:
Originally Posted by aron9forever
useless small optimizations
Quote:
Originally Posted by Black Rose View Post
On a map that is 512x512x128 units you end up with 3,355,443,200,000 different "positions". To store each one of those positions individually in the variable "user_or" you need 12 terabytes of memory.

Last edited by aron9forever; 06-18-2017 at 10:31.
aron9forever is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 22:44.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode