Merging dialogs
#1

hey guys!
I want to show players stats and stuff in dialogs but when i put whole thing in one line and with thouse \n and stuff i got error in pawn then i looked at tutorial in forum but it isnt working for me.
There it is:
Код:
	format(HugeString, sizeof(HugeString), "\n{FFFFFF}Niks: {E11D36}%s \n{FFFFFF}Novaktie: {E11D36}%d \n{FFFFFF}Naves: {E11D36}%d \n{FFFFFF}Attieciba: {E11D36}%0.2f \n{FFFFFF}Laiks serveri: {E11D36}%d hrs %d mins %d secs",PlayerName2(player1), PlayerInfo[player1][Kills], PlayerInfo[player1][Deaths], Float:PlayerInfo[player1][Kills]/Float:pDeaths,GetPlayerMoney(player1), h, m, s);
		format(HugeString, sizeof(HugeString), "\n{FFFFFF}Pistol: {E11D36}%d {FFFFFF}Silenced Pistol: {E11D36}%d {FFFFFF}Desert Eagle: {E11D36}%d \n{FFFFFF}Shotgun: {E11D36}%d {FFFFFF}Sawnoff Shotgun: {E11D36}%d",PlayerInfo[player1][Pistolskill], PlayerInfo[player1][SilencedPistolskill], PlayerInfo[player1][DesertEagleskill],PlayerInfo[player1][Shotgunskill],PlayerInfo[player1][Sawnoffskill], HugeString);
		ShowPlayerDialog(playerid, 231, DIALOG_STYLE_MSGBOX, "{FFFFFF}Statistika.", HugeString,"Aizvērt", "");
I got showing only dialog who is under first one.. How can i merge them in one?
Hope u understand me! Thanks!
Reply
#2

Post your errors
Reply
#3

Use strcat.

Ex:

pawn Код:
new str[128];
strcat(str, "Hello! 1\n");
strcat(str, "Hello! 2\n");
strcat(str, "Hello! 3\n");
ShowPlayerDialog(playerid, YOUR_DIALOG_ID, DIALOG_STYLE_LIST, "Test Dialog", str, "Yo", "Fuck Off");
Reply
#4

Why does when i put your code i dont get any errors but when i put my i got thouse warnings

Код:
(2845) : error 035: argument type mismatch (argument 3)
(2846) : warning 202: number of arguments does not match definition
(2846) : warning 202: number of arguments does not match definition
(2846) : warning 202: number of arguments does not match definition
(2846) : warning 202: number of arguments does not match definition
(2847) : warning 202: number of arguments does not match definition
(2847) : warning 202: number of arguments does not match definition
(2847) : warning 202: number of arguments does not match definition
(2847) : warning 202: number of arguments does not match definition
(2847) : warning 202: number of arguments does not match definition
And there is the lines
pawn Код:
new str[1000];
        strcat(str, "{FFFFFF}Niks: {E11D36}%s \n{FFFFFF}Novaktie: {E11D36}%d \n{FFFFFF}Naves: {E11D36}%d \n{FFFFFF}Attieciba: {E11D36}%0.2f \n{FFFFFF}Laiks serveri: {E11D36}%d hrs %d mins %d secs \n", PlayerName2(player1), PlayerInfo[player1][Kills], PlayerInfo[player1][Deaths], Float:PlayerInfo[player1][Kills]/Float:pDeaths,GetPlayerMoney(player1), h, m, s);
        strcat(str, "{FFFFFF}Pistol: {E11D36}%d {FFFFFF}Silenced Pistol: {E11D36}%d {FFFFFF}Desert Eagle: {E11D36}%d \n{FFFFFF}Shotgun: {E11D36}%d {FFFFFF}Sawnoff Shotgun: {E11D36}%d \n", PlayerInfo[player1][Pistolskill], PlayerInfo[player1][SilencedPistolskill], PlayerInfo[player1][DesertEagleskill],PlayerInfo[player1][Shotgunskill],PlayerInfo[player1][Sawnoffskill]);
        strcat(str, "{FFFFFF}Combat Shotgun: {E11D36}%d {FFFFFF}Micro Uzi/Tec-9: {E11D36}%d {FFFFFF}MP5: {E11D36}%d {FFFFFF}AK47: {E11D36}%d \n{FFFFFF}M4A1: {E11D36}%d {FFFFFF}Rifle: {E11D36}%d", PlayerInfo[player1][Spas12shotgunskill], PlayerInfo[player1][MicroUziskill], PlayerInfo[player1][MP5skill], PlayerInfo[player1][AK47skill], PlayerInfo[player1][M4skill], PlayerInfo[player1][Sniperskill]);
        ShowPlayerDialog(playerid, 531, DIALOG_STYLE_MSGBOX, "{FFFFFF}Statistika.", str,"Aizvērt", "");
Reply
#5

Because you're adding multiple lines everytime.You've to add ONE line per strcat.You can't use all this values in a single strcat,you're to divide it.Ex:

pawn Код:
strcat(str, "{FFFFFF}Niks: {E11D36}%s", PlayerName2(player1));
And so on.
Reply
#6

Thank u!
I will try that.
Reply
#7

Thought it will work but no.. :/ There is the whole code.
pawn Код:
dcmd_stats(playerid,params[]) {
    new pDeaths, player1, h, m, s;
    if(!strlen(params)) player1 = playerid;
    else player1 = strval(params);

    if(IsPlayerConnected(player1)) {
        TotalGameTime(player1, h, m, s);
        if(PlayerInfo[player1][Deaths] == 0) pDeaths = 1; else pDeaths = PlayerInfo[player1][Deaths];
        new str[1000];
        strcat(str, "{FFFFFF}Niks: {E11D36}%s\n", PlayerName2(player1));
        strcat(str, "{FFFFFF}Novaktie: {E11D36}%d\n", PlayerInfo[player1][Kills]);
        strcat(str, "{FFFFFF}Naves: {E11D36}%d\n", PlayerInfo[player1][Deaths]);
        strcat(str, "{FFFFFF}Attieciba: {E11D36}%0.2f\n", Float:PlayerInfo[player1][Kills]/Float:pDeaths);
        strcat(str, "{FFFFFF}Nauda: {E11D36}%d\n", GetPlayerMoney(player1));
        strcat(str, "{FFFFFF}Laiks serveri: {E11D36}%d hrs ", h);
        strcat(str, "{E11D36}%d mins", m);
        strcat(str, "{E11D36%d secs\n", s);
        strcat(str, "{FFFFFF}Pistol: {E11D36}%d", PlayerInfo[player1][Pistolskill]);
        strcat(str, "{FFFFFF}Silenced Pistol: {E11D36}%d\n", PlayerInfo[player1][SilencedPistolskill]);
        strcat(str, "{FFFFFF}Desert Eagle: {E11D36}%d", PlayerInfo[player1][DesertEagleskill]);
        strcat(str, "{FFFFFF}Shotgun: {E11D36}%d\n", PlayerInfo[player1][Shotgunskill]);
        strcat(str, "{FFFFFF}Sawnoff Shotgun: {E11D36}%d", PlayerInfo[player1][Sawnoffskill]);
        strcat(str, "{FFFFFF}Combat Shotgun: {E11D36}%d\n", PlayerInfo[player1][Spas12shotgunskill]);
        strcat(str, "{FFFFFF}Micro Uzi/Tec-9: {E11D36}%d", PlayerInfo[player1][MicroUziskill]);
        strcat(str, "{FFFFFF}MP5: {E11D36}%d\n", PlayerInfo[player1][MP5skill]);
        strcat(str, "{FFFFFF}AK47: {E11D36}%d", PlayerInfo[player1][AK47skill]);
        strcat(str, "{FFFFFF}M4A1: {E11D36}%d", PlayerInfo[player1][M4skill]);
        strcat(str, "{FFFFFF}Rifle: {E11D36}%d", PlayerInfo[player1][Sniperskill]);
        ShowPlayerDialog(playerid, 333, DIALOG_STYLE_MSGBOX, "{FFFFFF}Statistika.", str,"Aizvērt", "");
        return 1;
    } else return SendClientMessage(playerid, COLOR_GREY, "KLUDA: Speletajs nav piesledzies!");
}
Код:
(2841) : error 035: argument type mismatch (argument 3)
(2844) : warning 213: tag mismatch
Код:
LINE 2841: strcat(str, "{FFFFFF}Niks: {E11D36}%s\n", PlayerName2(player1));
LINE 2844: strcat(str, "{FFFFFF}Attieciba: {E11D36}%0.2f\n", Float:PlayerInfo[player1][Kills]/Float:pDeaths);
Reply
#8

Quote:
Originally Posted by Logitech90
Посмотреть сообщение
Because you're adding multiple lines everytime.You've to add ONE line per strcat.You can't use all this values in a single strcat,you're to divide it.Ex:

pawn Код:
strcat(str, "{FFFFFF}Niks: {E11D36}%s", PlayerName2(player1));
And so on.
No-no-no. strcat != format. You got to format each line separately before inserting it into the large string with strcat.
Reply
#9

First strcat, then format all

pawn Код:
strcat(HugeString, "{FFFFFF}Niks: {E11D36}%s \n{FFFFFF}Novaktie: {E11D36}%d \n{FFFFFF}Naves: {E11D36}%d \n{FFFFFF}Attieciba: {E11D36}%0.2f \n{FFFFFF}Laiks serveri: {E11D36}%d hrs %d mins %d secs");
strcat(HugeString, "\n{FFFFFF}Pistol: {E11D36}%d {FFFFFF}Silenced Pistol: {E11D36}%d {FFFFFF}Desert Eagle: {E11D36}%d \n{FFFFFF}Shotgun: {E11D36}%d {FFFFFF}Sawnoff Shotgun: {E11D36}%d");
format(HugeString, sizeof(HugeString), HugeString,PlayerName2(player1), PlayerInfo[player1][Kills], PlayerInfo[player1][Deaths], Float:PlayerInfo[player1][Kills]/Float:pDeaths,GetPlayerMoney(player1), h, m, s,
    PlayerInfo[player1][Pistolskill], PlayerInfo[player1][SilencedPistolskill], PlayerInfo[player1][DesertEagleskill],PlayerInfo[player1][Shotgunskill],PlayerInfo[player1][Sawnoffskill], HugeString);
ShowPlayerDialog(playerid, 231, DIALOG_STYLE_MSGBOX, "{FFFFFF}Statistika.", HugeString,"Aizvērt", "");
Reply
#10

Edit..
Thank u. its working.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)