make strcat
#1

Its already in a dialog but can you please make this to strcat? Coz later on I will add more things inside the dialog msg box and in the default dialog string is not enough.



Код HTML:
COMMAND:stats(playerid,params[])
{
	new string[250], pDeaths, player1, player, h, m, s;

	if(sscanf(params, "r", player))
	{
		player1 = playerid;
	}
	else
	{
		player1 = player;
	}

	if(IsPlayerConnected(player1))
	{
		TotalGameTime(player1, h, m, s);
 		if(PlayerInfo[player1][Deaths] == 0) { pDeaths = 1; }
	 	else { pDeaths = PlayerInfo[player1][Deaths]; }
	 	#if USE_VIP_SYSTEM == true
 		format(string, sizeof(string), "\n{FEFEFE}Stats of the player: %s\n\n{FEFEFE}Kills:\t\t%d\nDeaths:\t\t%d\nK/D:\t\t%0.2f\nScore:\t\t%d\nMoney:\t\t$%d\nVIP Level:\t%d\nHours:\t\t%d\nMinutes\t%d\nSeconds:\t%d\nRegister date:\t%s",GetName(player1), PlayerInfo[player1][Kills], PlayerInfo[player1][Deaths],Float:PlayerInfo[player1][Kills]/Float:pDeaths,GetPlayerScore(player1),GetPlayerMoney(player1),PlayerInfo[player1][VIPLevel],h,m,s,PlayerInfo[player1][RegDate]);
		#else
 		format(string, sizeof(string), "\n{FEFEFE}Stats of the player: %s\n\n{FEFEFE}Kills:\t\t%d\nDeaths:\t\t%d\nK/D:\t\t%0.2f\nScore:\t\t%d\nMoney:\t\t$%d\nHours:\t\t%d\nMinutes\t%d\nSeconds:\t%d\nRegister date:\t%s",GetName(player1), PlayerInfo[player1][Kills], PlayerInfo[player1][Deaths],Float:PlayerInfo[player1][Kills]/Float:pDeaths,GetPlayerScore(player1),GetPlayerMoney(player1),h,m,s,PlayerInfo[player1][RegDate]);
		#endif
		ShowPlayerDialog(playerid, STATS_DIALOG, DIALOG_STYLE_MSGBOX, "Player Statistics", string, "Close", "");
	}
	else
	{
			GameTextForPlayer(playerid, "~r~player is unavailable", 3000, 3);
	}
	return 1;
}
Reply
#2

You can just try this one :-
pawn Код:
COMMAND:stats(playerid,params[])
{
    new string[250], string2[250], AllStrings[500], pDeaths, player1, player, h, m, s;

    if(sscanf(params, "r", player))
    {
        player1 = playerid;
    }
    else
    {
        player1 = player;
    }

    if(IsPlayerConnected(player1))
    {
        TotalGameTime(player1, h, m, s);
        if(PlayerInfo[player1][Deaths] == 0) { pDeaths = 1; }
        else { pDeaths = PlayerInfo[player1][Deaths]; }
        #if USE_VIP_SYSTEM == true
        format(string, sizeof(string), "\n{FEFEFE}Stats of the player: %s\n\n{FEFEFE}Kills:\t\t%d\nDeaths:\t\t%d\nK/D:\t\t%0.2f\nScore:\t\t%d",GetName(player1), PlayerInfo[player1][Kills], PlayerInfo[player1][Deaths],Float:PlayerInfo[player1][Kills]/Float:pDeaths,GetPlayerScore(player1));
        format(string2, sizeof(string2), "Money:\t\t$%d\nVIP Level:\t%d\nHours:\t\t%d\nMinutes\t%d\nSeconds:\t%d\nRegister date:\t%s",GetPlayerMoney(player1),PlayerInfo[player1][VIPLevel],h,m,s,PlayerInfo[player1][RegDate]);
        format(AllStrings, sizeof(AllStrings), "%s\n%s",string, string2);
        #else
        format(string, sizeof(string), "\n{FEFEFE}Stats of the player: %s\n\n{FEFEFE}Kills:\t\t%d\nDeaths:\t\t%d\nK/D:\t\t%0.2f\nScore:\t\t%d",GetName(player1), PlayerInfo[player1][Kills], PlayerInfo[player1][Deaths],Float:PlayerInfo[player1][Kills]/Float:pDeaths,GetPlayerScore(player1));
        format(string2, sizeof(string2), "Money:\t\t$%d\nHours:\t\t%d\nMinutes\t%d\nSeconds:\t%d\nRegister date:\t%s",,GetPlayerMoney(player1),h,m,s,PlayerInfo[player1][RegDate]);
        format(AllStrings, sizeof(AllStrings), "%s\n%s",string, string2);
        #endif
        ShowPlayerDialog(playerid, STATS_DIALOG, DIALOG_STYLE_MSGBOX, "Player Statistics", string, "Close", "");
    }
    else
    {
            GameTextForPlayer(playerid, "~r~player is unavailable", 3000, 3);
    }
    return 1;
}
Tell me if there is any problem
Reply
#3

Quote:
Originally Posted by SAMProductions
Посмотреть сообщение
You can just try this one :-
pawn Код:
COMMAND:stats(playerid,params[])
{
    new string[250], string2[250], AllStrings[500], pDeaths, player1, player, h, m, s;

    if(sscanf(params, "r", player))
    {
        player1 = playerid;
    }
    else
    {
        player1 = player;
    }

    if(IsPlayerConnected(player1))
    {
        TotalGameTime(player1, h, m, s);
        if(PlayerInfo[player1][Deaths] == 0) { pDeaths = 1; }
        else { pDeaths = PlayerInfo[player1][Deaths]; }
        #if USE_VIP_SYSTEM == true
        format(string, sizeof(string), "\n{FEFEFE}Stats of the player: %s\n\n{FEFEFE}Kills:\t\t%d\nDeaths:\t\t%d\nK/D:\t\t%0.2f\nScore:\t\t%d",GetName(player1), PlayerInfo[player1][Kills], PlayerInfo[player1][Deaths],Float:PlayerInfo[player1][Kills]/Float:pDeaths,GetPlayerScore(player1));
        format(string2, sizeof(string2), "Money:\t\t$%d\nVIP Level:\t%d\nHours:\t\t%d\nMinutes\t%d\nSeconds:\t%d\nRegister date:\t%s",GetPlayerMoney(player1),PlayerInfo[player1][VIPLevel],h,m,s,PlayerInfo[player1][RegDate]
        format(AllStrings, sizeof(AllStrings), "%s\n%s",string, string2);
        #else
        format(string, sizeof(string), "\n{FEFEFE}Stats of the player: %s\n\n{FEFEFE}Kills:\t\t%d\nDeaths:\t\t%d\nK/D:\t\t%0.2f\nScore:\t\t%d",GetName(player1), PlayerInfo[player1][Kills], PlayerInfo[player1][Deaths],Float:PlayerInfo[player1][Kills]/Float:pDeaths,GetPlayerScore(player1));
        format(string2, sizeof(string2), "Money:\t\t$%d\nHours:\t\t%d\nMinutes\t%d\nSeconds:\t%d\nRegister date:\t%s",,GetPlayerMoney(player1),h,m,s,PlayerInfo[player1][RegDate]);
        format(AllStrings, sizeof(AllStrings), "%s\n%s",string, string2);
        #endif
        ShowPlayerDialog(playerid, STATS_DIALOG, DIALOG_STYLE_MSGBOX, "Player Statistics", string, "Close", "");
    }
    else
    {
            GameTextForPlayer(playerid, "~r~player is unavailable", 3000, 3);
    }
    return 1;
}
Tell me if there is any problem
thanks for trying brother but I need the strcat which each line = 1 variable like this

Код HTML:
sizeof(string), "\nPlayer: %s",GetName(player1)
sizeof(string), "\nKills: %d",PlayerInfo[player1][Kills]
sizeof(string), "\nDeaths: %d",PlayerInfo[player1][Deaths]
sizeof(string), "\nK/D: %0.2f",Float:PlayerInfo[player1][Kills]
and so on
Reply
#4

I think you can't use it with "strcat";

and i think "strcat"s will not answer that kind of Format Strings such as :-
%b, %c, %d, %f, %i, %s, %x, and %%.


EDIT :-

I think Format Strings is only available for format.

You can just edit it by yourself for Example :-

Код:
format(string, sizeof(string), "My Name is: %s", pName);
format(string2, sizeof(string2), "My ID is: %d", playerid);
format(string3, sizeof(string3), "The number is %i.",number);  //-> The number is 42.
format(string4, sizeof(string4), "This is a %s containing the number %i.", string, number);

format(AllStrings, sizeof(AllStrings), "%s\n%s\n%s\n%s", string, string2, string3, string4);

ShowPlayerDialog(playerid, STATS_DIALOG, DIALOG_STYLE_MSGBOX, "Player Statistic(s)", AllStrings, "Close", "");
Reply
#5

pawn Код:
new string[100], dialogstring[750];
format(string, sizeof(string), "text %specifier", variable);
strcat(dialogstring, string);
format(string, sizeof(string), "text %specifier", variable);
strcat(dialogstring, string);
ShowPlayerDialog(... dialogstring ...); // do the rest of the parameters yourself, I'm on my phone :P
Reply
#6

You can just edit it by yourself for Example :-

Using ShowPlayerDialog,
Код:
format(string, sizeof(string), "My Name is: %s", pName);
format(string2, sizeof(string2), "My ID is: %d", playerid);
format(string3, sizeof(string3), "The number is %i.",number);  //-> The number is 42.
format(string4, sizeof(string4), "This is a %s containing the number %i.", string, number);

format(AllStrings, sizeof(AllStrings), "%s\n%s\n%s\n%s", string, string2, string3, string4);

ShowPlayerDialog(playerid, STATS_DIALOG, DIALOG_STYLE_MSGBOX, "Player Statistic(s)", AllStrings, "Close", "");
Using SendClientMessage,
Код:
format(string, sizeof(string), "My Name is: %s", pName);
format(string2, sizeof(string2), "My ID is: %d", playerid);
format(string3, sizeof(string3), "The number is %i.",number);  //-> The number is 42.
format(string4, sizeof(string4), "This is a %s containing the number %i.", string, number);

format(AllStrings, sizeof(AllStrings), "%s\n%s\n%s\n%s", string, string2, string3, string4);

SendClientMessage(playerid, -1, AllStrings);
Using SendClientMessageToAll,
Код:
format(string, sizeof(string), "My Name is: %s", pName);
format(string2, sizeof(string2), "My ID is: %d", playerid);
format(string3, sizeof(string3), "The number is %i.",number);  //-> The number is 42.
format(string4, sizeof(string4), "This is a %s containing the number %i.", string, number);

format(AllStrings, sizeof(AllStrings), "%s\n%s\n%s\n%s", string, string2, string3, string4);

SendClientMessageToAll(-1, AllStrings);
etc.
Reply
#7

Quote:
Originally Posted by SAMProductions
Посмотреть сообщение
You can just edit it by yourself for Example :-

Using ShowPlayerDialog,
Код:
format(string, sizeof(string), "My Name is: %s", pName);
format(string2, sizeof(string2), "My ID is: %d", playerid);
format(string3, sizeof(string3), "The number is %i.",number);  //-> The number is 42.
format(string4, sizeof(string4), "This is a %s containing the number %i.", string, number);

format(AllStrings, sizeof(AllStrings), "%s\n%s\n%s\n%s", string, string2, string3, string4);

ShowPlayerDialog(playerid, STATS_DIALOG, DIALOG_STYLE_MSGBOX, "Player Statistic(s)", AllStrings, "Close", "");
Using SendClientMessage,
Код:
format(string, sizeof(string), "My Name is: %s", pName);
format(string2, sizeof(string2), "My ID is: %d", playerid);
format(string3, sizeof(string3), "The number is %i.",number);  //-> The number is 42.
format(string4, sizeof(string4), "This is a %s containing the number %i.", string, number);

format(AllStrings, sizeof(AllStrings), "%s\n%s\n%s\n%s", string, string2, string3, string4);

SendClientMessage(playerid, -1, AllStrings);
Using SendClientMessageToAll,
Код:
format(string, sizeof(string), "My Name is: %s", pName);
format(string2, sizeof(string2), "My ID is: %d", playerid);
format(string3, sizeof(string3), "The number is %i.",number);  //-> The number is 42.
format(string4, sizeof(string4), "This is a %s containing the number %i.", string, number);

format(AllStrings, sizeof(AllStrings), "%s\n%s\n%s\n%s", string, string2, string3, string4);

SendClientMessageToAll(-1, AllStrings);
etc.
That method is terrible, strcat is a lot more efficient and easier, also faster.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)