AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Formatting String (https://forums.alliedmods.net/showthread.php?t=215555)

BenSib 05-09-2013 08:18

Formatting String
 
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!

Bimbo1 05-09-2013 08:44

Re: Formatting String
 
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.

bl4nk 05-09-2013 08:46

Re: Formatting String
 
You'll want to do sizeof(Name[]), and also remember that array indexes start at 0, so Name[3] is invalid.

BenSib 05-09-2013 08:48

Re: Formatting String
 
thats it, thanks.


All times are GMT -4. The time now is 18:32.

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