Raised This Month: $ Target: $400
 0% 

Formatting String


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
BenSib
Senior Member
Join Date: Aug 2008
Old 05-09-2013 , 08:18   Formatting String
Reply With Quote #1

Do you have an idea how to change Name2 and Name3 in the following example ? Formatting that way is obviously wrong...

Code:
#define MAXADMIN 3

new String:Name[MAXADMIN][] = 
{
   "Name1", "Name2", "Name3"
};

FormatNames()
{
   Format(Name[2], sizeof(Name), "NewName2"); 
   Format(Name[3], sizeof(Name), "NewName3"); 
}

Many thanks!
BenSib is offline
Bimbo1
Senior Member
Join Date: Jan 2010
Location: brazil
Old 05-09-2013 , 08:44   Re: Formatting String
Reply With Quote #2

it's not wrong to use format. but create the string if a bigger lenght, like string[3][32], so it will fit the newname2 and be aware that string[1] refers to name2. the index goes from 0 to 2, not from 1 to 3, you would probably receive an error.
__________________
sie sind das essen und wir sind die jäger!
Bimbo1 is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 05-09-2013 , 08:46   Re: Formatting String
Reply With Quote #3

You'll want to do sizeof(Name[]), and also remember that array indexes start at 0, so Name[3] is invalid.
bl4nk is offline
BenSib
Senior Member
Join Date: Aug 2008
Old 05-09-2013 , 08:48   Re: Formatting String
Reply With Quote #4

thats it, thanks.
BenSib is offline
Reply



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 12:38.


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