SA-MP Forums Archive
Format Code problems - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Format Code problems (/showthread.php?tid=624773)



Format Code problems - SytonicX - 22.12.2016

Код:
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?


Re: Format Code problems - OneDay - 22.12.2016

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]); 



Re: Format Code problems - GoldenLion - 22.12.2016

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...



Respuesta: Format Code problems - Cerealguy - 22.12.2016

use format and strcat!

https://sampwiki.blast.hk/wiki/Strcat


Re: Format Code problems - SytonicX - 22.12.2016

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.


Re: Format Code problems - Eloy - 22.12.2016

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