Format Code problems
#1

Код:
COMMAND:charactersheet(playerid, params[])
{
		new string[2000];
		if(PlayerInfo[playerid][race] == 1)
		{
		format(string, sizeof(string), "{FFFFFF}Name: %s\n\
		{FFFFFF}Age\n\
		{FFFFFF}Race\n\
		{FFFFFF}-- Attributes --\n\
		{FFFFFF}- Physical -\n\
		{FFFFFF}Strength\n\
		{FFFFFF}Dexterity\n\
		{FFFFFF}Stamina\n\
		{FFFFFF}- Social -\n\
		{FFFFFF}Charisma\n\
		{FFFFFF}Manipulation\n\
		{FFFFFF}Appearance\n\
		{FFFFFF}- Mental -\n\
		{FFFFFF}Perception\n\
		{FFFFFF}Intelligence\n\
		{FFFFFF}Wits\n\
		{FFFFFF}- Talents -\n\
		{FFFFFF}Alertness\n\
		{FFFFFF}Athletics\n\
		{FFFFFF}Brawl\n\
		{FFFFFF}Dodge\n\
		{FFFFFF}Empathy\n",RPName(playerid));
		format(string, sizeof(string), "{FFFFFF}Expression %d\n\
		{FFFFFF}Intimidation\n\
		{FFFFFF}Leadership\n\
		{FFFFFF}Streetwise\n\
		{FFFFFF}Subterfuge\n\
		{FFFFFF}- Skills -\n\
		{FFFFFF}Animalken\n\
		{FFFFFF}Crafts\n\
		{FFFFFF}Drive\n\
		{FFFFFF}Etiquette\n\
		{FFFFFF}Firearms\n\
		{FFFFFF}Melee\n\
		{FFFFFF}Performance\n\
		{FFFFFF}Secruity\n\
		{FFFFFF}Stealth\n\
		{FFFFFF}Survival\n\
		{FFFFFF}- Knowledges -\n\
		{FFFFFF}Academics\n\
		{FFFFFF}Computer\n", string,PlayerInfo[playerid][expression]);
		format(string, sizeof(string), "{FFFFFF}Finance\n\
		{FFFFFF}Investigation\n\
		{FFFFFF}Law\n\
		{FFFFFF}Linguistics\n\
		{FFFFFF}Medicine %d\n\
		{FFFFFF}Occult\n\
		{FFFFFF}Politics\n\
		{FFFFFF}Science\n\
		{FFFFFF}-- Advantages --\n\
		{FFFFFF}- Other -\n\
		{FFFFFF}Humanity\n\
		{FFFFFF}Willpower\n",PlayerInfo[playerid][medicine]);
		ShowPlayerDialog(playerid, 61, DIALOG_STYLE_LIST, "CharacterSheet", string, "Select", "Cancel");
		return 1;
		}
	return 1;
}
Each time i enter the server and type the command, the last format is removing all of the other formats is there a way to fix it?
Reply
#2

PHP код:
format(stringsizeof(string), "%s{FFFFFF}Finance\n\
        {FFFFFF}Investigation\n\
        {FFFFFF}Law\n\
        {FFFFFF}Linguistics\n\
        {FFFFFF}Medicine %d\n\
        {FFFFFF}Occult\n\
        {FFFFFF}Politics\n\
        {FFFFFF}Science\n\
        {FFFFFF}-- Advantages --\n\
        {FFFFFF}- Other -\n\
        {FFFFFF}Humanity\n\
        {FFFFFF}Willpower\n"
stringPlayerInfo[playerid][medicine]); 
Reply
#3

This happens because you are re-formatting it everytime and not including the old string. You must do it like this:
Код:
format(string, sizeof(string), "item1\nitem2\nitem3\n");
format(string, sizeof(string), "%sitem4\nitem5\nitem6\n", string);
format(string, sizeof(string), "%sitem7\nitem8\n", string);
and so on...
Reply
#4

use format and strcat!

https://sampwiki.blast.hk/wiki/Strcat
Reply
#5

Quote:
Originally Posted by GoldenLion
Посмотреть сообщение
This happens because you are re-formatting it everytime and not including the old string. You must do it like this:
Код:
format(string, sizeof(string), "item1\nitem2\nitem3\n");
format(string, sizeof(string), "%sitem4\nitem5\nitem6\n", string);
format(string, sizeof(string), "%sitem7\nitem8\n", string);
and so on...
Thanks man, fixed it.

Thanks everyone.
Reply
#6

yeah, use a strcat for concat your strings and show calling your variable
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)