Format problems
#1

Hello!

Code I've made isn't working - no errors or smth but in game text in dialog is not showed, only last format is there..

pawn Код:
format(string, sizeof(string), "{FFFFFF}Welcome back {00FF00}%s{FFFFFF}! \n\n",name);
        format(string, sizeof(string), "{FFFFFF}This account is registered, insert your password to {00FF00}login {FFFFFF}to your account\n\n");
        format(string, sizeof(string), "{FFFFFF}Current time:{FF8000} %02d:%02d\t\t\t{FFFFFF}Times Logged:{FF8000} %d\n",hour,minute,second,pInfo[playerid][Logins]);
        format(string, sizeof(string), "{FFFFFF}Date:{FF8000} %02d/%02d/%d\t\t\t{FFFFFF}Last Login:{FF8000} %02d/%02d/%d",year,month,day,pInfo[playerid][LastLoginD],pInfo[playerid][LastLoginM],pInfo[playerid][LastLoginY]);
        format(string, sizeof(string), "FFFFFF}Gangsters in city: {FF8000}%d\t\t\t{FFFFFF}Failed Attempts:{FF0000} 0/3",Iter_Count(Player));
        ShowPlayerDialog(playerid,dlogin,DIALOG_STYLE_INPUT,"{FF8000}                       Mafia World Roleplay",string,"Login","Quit");
Reply
#2

You cannot use several formatted strings, only the last one will be used. Use \n to go a line down, and use it in the same format, or you can use something like strcat.
Reply
#3

Well can I use those %s %d w/e in strcat?
Reply
#4

pawn Код:
format(string, sizeof(string), "{FFFFFF}Welcome back {00FF00}%s{FFFFFF}! \n\n",name);
format(string, sizeof(string), "%s{FFFFFF}This account is registered, insert your password to {00FF00}login {FFFFFF}to your account\n\n", string);
format(string, sizeof(string), "%s{FFFFFF}Current time:{FF8000} %02d:%02d\t\t\t{FFFFFF}Times Logged:{FF8000} %d\n", string, hour, minute, second, pInfo[playerid][Logins]);
format(string, sizeof(string), "%s{FFFFFF}Date:{FF8000} %02d/%02d/%d\t\t\t{FFFFFF}Last Login:{FF8000} %02d/%02d/%d", string, year, month, day, pInfo[playerid][LastLoginD], pInfo[playerid][LastLoginM], pInfo[playerid][LastLoginY]);
format(string, sizeof(string), "%s{FFFFFF}Gangsters in city: {FF8000}%d\t\t\t{FFFFFF}Failed Attempts:{FF0000} 0/3", string, Iter_Count(Player));
ShowPlayerDialog(playerid,dlogin,DIALOG_STYLE_INPUT,"{FF8000}                       Mafia World Roleplay",string,"Login","Quit");
Reply
#5

No, you format the string, then you use the formatted string in strcat.
pawn Код:
new string[2], strcatstring[2];
format(string, sizeof(string), "%d", random(2));
strcat(strcatstring, string, sizeof(string));
Not tested, but something like that.
Reply
#6

Huh can you show that in my code?
Reply
#7

I've made this and it's not working, same as before:
pawn Код:
public OnPlayerConnect(playerid)
{
    new hour, minute, second, string[500],str[500], year, month, day;
    getdate(year, month, day);
    gettime(hour, minute, second);
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    format(string,sizeof(string),"Last Login: %02d/%02d/%d",pInfo[playerid][LastLoginD],pInfo[playerid][LastLoginM],pInfo[playerid][LastLoginY]);
    SendClientMessage(playerid, -1, string);
    if(fexist(Path(playerid)))
    {
        INI_ParseFile(Path(playerid),"loadaccount_%s", .bExtra = true, .extra = playerid);
        format(string, sizeof(string), "{FFFFFF}Welcome back {00FF00}%s{FFFFFF}! \n\n",name);
        format(string, sizeof(string), "{FFFFFF}This account is registered, insert your password to {00FF00}login {FFFFFF}to your account\n\n");
        format(string, sizeof(string), "{FFFFFF}Current time:{FF8000} %02d:%02d\t\t\t{FFFFFF}Times Logged:{FF8000} %d\n",hour,minute,second,pInfo[playerid][Logins]);
        format(string, sizeof(string), "{FFFFFF}Date:{FF8000} %02d/%02d/%d\t\t\t{FFFFFF}Last Login:{FF8000} %02d/%02d/%d\n",year,month,day,pInfo[playerid][LastLoginD],pInfo[playerid][LastLoginM],pInfo[playerid][LastLoginY]);
        format(string, sizeof(string), "FFFFFF}Gangsters in city: {FF8000}%d\t\t\t{FFFFFF}Failed Attempts:{FF0000} 0/3",Iter_Count(Player));
        strcat(str, string, sizeof(str));
        ShowPlayerDialog(playerid,dlogin,DIALOG_STYLE_INPUT,"{FF8000}       TEST",string,"Login","Quit");
    }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)