Variables in a SendClientMessage -
slymatt - 19.07.2011
How do i embed varibales in to a sendclientmessage For example
Код:
SendClientMessage(playerid, COLOUR_RED, "Cash:" INI_ReadInt("Cash"));
But it doenst like that so how would i go about doing it?
Re: Variables in a SendClientMessage -
[HiC]TheKiller - 19.07.2011
https://sampforum.blast.hk/showthread.php?tid=257849
There is some SendFormattedMessage functions or you could always do this
pawn Код:
new string[50];
format(string, sizeof(string), "Cash:%d", INI_ReadInt("Cash"))
SendClientMessage(playerid, COLOUR_RED, string);
Re: Variables in a SendClientMessage -
Calgon - 19.07.2011
You've got to format a string, and send the message. An example of this would be:
pawn Код:
new
szMessage[128];
format(szMessage, sizeof(szMessage), "Cash: %d", INI_ReadInt("Cash"));
SendClientMessage(playerid, -1, szMessage);
EDIT: Didn't see [HiC]'s post.
Re: Variables in a SendClientMessage -
slymatt - 19.07.2011
how would i send more than one variable at a time
Re: Variables in a SendClientMessage -
[HiC]TheKiller - 19.07.2011
pawn Код:
new variable[2], string[60];
variable[0] = 1;
variable[1] = 2;
format(string, sizeof(string), "Variable 1 is %d, Variable 2 is %d", variable[0], variable[1]);
And read
https://sampwiki.blast.hk/wiki/Format
Re: Variables in a SendClientMessage -
slymatt - 19.07.2011
Thank you very much =)
Re: Variables in a SendClientMessage -
slymatt - 19.07.2011
Ive done that what you said but it only shows the first part of it which is Account: Cash and then it says 75 but there is 20000 in there =S
Re: Variables in a SendClientMessage -
slymatt - 19.07.2011
Ive sorted it out to show everything but now they all say 0
EDIT
Heres the code
Код:
new Stats[10], string[150];
Stats[0] = INI_ReadInt("Cash");
Stats[1] = INI_ReadInt("Kills");
Stats[2] = INI_ReadInt("Deaths");
format(string, sizeof(string), "Account: Cash: %d, Kills: %d , Deaths: %d", Stats[0], Stats[1], Stats[2]);
SendClientMessage(playerid, COLOUR_GREEN, string);
Re: Variables in a SendClientMessage -
[HiC]TheKiller - 19.07.2011
Your file system must not be reading and storing the variables properly.
Re: Variables in a SendClientMessage -
slymatt - 19.07.2011
Haha you reminded me that i needed to open the file first haha thanks for the help it works now =P
Re: Variables in a SendClientMessage -
Donya - 19.07.2011
Quote:
Originally Posted by slymatt
Haha you reminded me that i needed to open the file first haha thanks for the help it works now =P
|
also use new string[128], for sending messages, the max chat limit is 128 characters