Variables in a SendClientMessage
#1

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?
Reply
#2

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);
Reply
#3

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.
Reply
#4

how would i send more than one variable at a time
Reply
#5

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
Reply
#6

Thank you very much =)
Reply
#7

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
Reply
#8

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);
Reply
#9

Your file system must not be reading and storing the variables properly.
Reply
#10

Haha you reminded me that i needed to open the file first haha thanks for the help it works now =P
Reply
#11

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)