Need assistance with StrCat.
#1

It only sends the last one.

What am I doing wrong?

pawn Код:
new string[128], string2[128];
            format(string, sizeof(string), "{FF0000}Vehicle Deleted.");
            strcat(string2, string);
            format(string, sizeof(string), "Vehicle Server ID: {FF0000}%d", vehicleid);
            strcat(string2, string);
            format(string,sizeof(string), "Vehicle MySQL ID: {FF0000}%d", VehicleSQLID[vehicleid]);
            strcat(string2, string);
            format(string, sizeof(string), "Next Free SQLID: {FF0000}%d", GetFreeMySQLSlot("vehicles"));
            strcat(string2, string);
            SendClientMessage(playerid, COLOUR_WHITE, string);
Reply
#2

If you're trying to do multiple lines, then you need to send a client message for each line.
Reply
#3

Like this:

Код:
new string[128];
format(string, sizeof(string), "{FF0000}Vehicle Deleted.");
SendClientMessage(playerid, COLOUR_WHITE, string);
format(string, sizeof(string), "Vehicle Server ID: {FF0000}%d", vehicleid);
SendClientMessage(playerid, COLOUR_WHITE, string);
format(string,sizeof(string), "Vehicle MySQL ID: {FF0000}%d", VehicleSQLID[vehicleid]);
SendClientMessage(playerid, COLOUR_WHITE, string);
format(string, sizeof(string), "Next Free SQLID: {FF0000}%d", GetFreeMySQLSlot("vehicles"));
SendClientMessage(playerid, COLOUR_WHITE, string);
Reply
#4

Ah, but ask yourself this, where are you actually formatting 'string2'? If there is no value for string2, you are not adding anything to 'string'. In fact you're just doing:
string =
addnothingtostring
string =
addnothingtostring
//...
Send(string);

pawn Код:
new string[128], string2[40];
            format(string, sizeof(string), "{FF0000}Vehicle Deleted. | ");
            format(string2, sizeof(string2), "Vehicle Server ID: {FF0000}%d | ", vehicleid);
            strcat(string2, string);
            format(string2,sizeof(string2), "Vehicle MySQL ID: {FF0000}%d | ", VehicleSQLID[vehicleid]);
            strcat(string2, string);
            format(string2, sizeof(string2), "Next Free SQLID: {FF0000}%d", GetFreeMySQLSlot("vehicles"));
            strcat(string2, string);
            SendClientMessage(playerid, COLOUR_WHITE, string);
Should work :P

EDIT: I knew I shouldn't of walked away before posting, 2 others got in before me. I did find it a little weird as to why you were using strcat for this, and there was nothing separating the texts... so I would assume that you're trying to do what SuperViper was suggesting. In that case:

pawn Код:
new string[40];
SendClientMessage(playerid, 0xFFFF00FF, "Vehicle Deleted.");
format(string, sizeof(string), "Vehicle Server ID: {FF0000}%d", vehicleid);
SendClientMessage(playerid, COLOUR_WHITE, string);
format(string, sizeof(string), "Vehicle MySQL ID: {FF0000}%d", VehicleSQLID[vehicleid]);
SendClientMessage(playerid, COLOUR_WHITE, string);
format(string, sizeof(string), "Next Free SQL ID: {FF0000}%d", GetFreeMySQLSlot("vehicles"));
SendClientMessage(playerid, COLOUR_WHITE, string);
Reply
#5

Thank you. I knew other solutions, but truth is I want to understand it better and you just help me do so; I appreciate that.
Reply
#6

Oh so i now understand what your trying to do mate. Your trying to put all messages in one line? Try this:

Код:
new string[128], string2[128];
format(string, sizeof(string), "{FF0000}Vehicle Deleted.");
strcat(string2, string);
format(string, sizeof(string), "Vehicle Server ID: {FF0000}%d", vehicleid);
strcat(string2, string);
format(string,sizeof(string), "Vehicle MySQL ID: {FF0000}%d", VehicleSQLID[vehicleid]);
strcat(string2, string);
format(string, sizeof(string), "Next Free SQLID: {FF0000}%d", GetFreeMySQLSlot("vehicles"));
strcat(string2, string);
SendClientMessage(playerid, COLOUR_WHITE, string2);
Reply
#7

Thank you!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)