Raised This Month: $ Target: $400
 0% 

[AMXX] Getting the mapname


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
TheRadiance
Senior Member
Join Date: Nov 2007
Location: Kazakhstan
Old 07-01-2009 , 02:55   Re: [AMXX] Getting the mapname
Reply With Quote #9

Quote:
Wow, you should not use "sizeof()" you must use "sizeof() - 1" for string lengths.
PHP Code:
/* Returns player name. */
native get_user_name(index,name[],len); 
len = length of string if i understood this well?

I can't understand this as long as i scripting pawn.

Why sizeof (name) -1 ?

Imagine that user name contains 4 chars:
PHP Code:
new name[4];
get_user_name(idnamesizeof (name) - 1// sizeof (name) - 1 = 3
get_user_name(idnamesizeof (name)) // sizeof (name) = 4 
PHP Code:
// name rofl for example
//first case (sizeof (name) - 1): 0 1 2 3 4
//                                r o f               // 3 is empty; 4 is null;

//second case (sizeof (name)): 0 1 2 3 4
//                             r o f l            // 4 is null; 
also from SourcePawn base plugins:
PHP Code:
decl String:name[64];
GetClientName(clientnamesizeof(name)); 
Can anyone explain this to stupid Radiance?
Thanks

Last edited by TheRadiance; 07-01-2009 at 02:58.
TheRadiance is offline
Send a message via ICQ to TheRadiance
 



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 15:31.


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