PDA

View Full Version : Warning with sendclientmessage?


buhs
03/12/2016, 03:40 PM
Can u guys help me with this sendclientmessage error?
Warning what's shown:
warning 202: number of arguments does not match definition
warning 202: number of arguments does not match definition
warning 202: number of arguments does not match definition

Cmd:

SendClientMessage(playerid, -1, "*"COL_YELLOW" You have given %s "COL_WHITE"%i"COL_GREEN" %s", PlayerName(playerid), amount, string);

Micko123
03/12/2016, 03:48 PM
You can't format in SendPlayerMessage.. You can only send message without any usage of %s %d..
You can do it this way

new string[128];
format(string, sizeof(string), "*"COL_YELLOW" You have given %s "COL_WHITE"%i", PlayerName(playerid), amount);
SendClientMessage(playerid, -1, string);

Yaa
03/12/2016, 03:49 PM
new str[120];
format(str, sizeof(str), "*"COL_YELLOW" You have given %s "COL_WHITE"%i"COL_GREEN"", PlayerName(playerid), amount,);
SendClientMessage(playerid, -1, str);

Logic_
03/12/2016, 04:07 PM
Are the above strings even 100 characters long?

new str[90]; // 90 is enuf
format(str, sizeof(str), "*"COL_YELLOW" You have given %s "COL_WHITE"%i", PlayerName(playerid), amount,); // no need to use COLOR_GREEN...
SendClientMessage(playerid, -1, str);

buhs
03/12/2016, 04:14 PM
new str[120];
format(str, sizeof(str), "*"COL_YELLOW" You have given %s "COL_WHITE"%i"COL_GREEN"", PlayerName(playerid), amount,);
SendClientMessage(playerid, -1, str);

Thanks, worked!

Logic_
03/12/2016, 04:16 PM
The above code worked, but you are wasting 20+ unused memory. Optimization should be your higher priority than a code that works.