SA-MP Forums Archive
Need assistance with StrCat. - 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: Need assistance with StrCat. (/showthread.php?tid=480316)



Need assistance with StrCat. - Dokins - 10.12.2013

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



Re: Need assistance with StrCat. - SuperViper - 10.12.2013

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


Re: Need assistance with StrCat. - SickAttack - 10.12.2013

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



Re: Need assistance with StrCat. - Threshold - 10.12.2013

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



Re: Need assistance with StrCat. - Dokins - 10.12.2013

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.


Re: Need assistance with StrCat. - SickAttack - 10.12.2013

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



Re: Need assistance with StrCat. - Dokins - 10.12.2013

Thank you!