SendClientMessage ingame error - 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: SendClientMessage ingame error (
/showthread.php?tid=608532)
SendClientMessage ingame error -
Deroxi - 02.06.2016
So i made a setscore command:
Код:
CMD:setscore(playerid, params[])
{
new targetid, score, name[24], texttotarget[20], textadmin[20];
if(Player[playerid][Admin] < 4) return SendClientMessage(playerid, COLOR_RED, "[WARNING] You are not authorized to use this command!");
if(sscanf(params, "ui", targetid, score)) return SendClientMessage(playerid, COLOR_RED, "SYNTAX: /setscore <ID> <Score>");
GetPlayerName(targetid, name, 24);
SetPlayerScore(targetid, GetPlayerScore(targetid) + score);
format(texttotarget, sizeof(texttotarget),"[ADMIN] %s has set your score to: %i", playerid, score);
format(textadmin, sizeof(textadmin),"[ADMIN] You have set the score of %s to: %i", targetid, score);
SendClientMessage(targetid, COLOR_GREEN, texttotarget);
SendClientMessage(playerid, COLOR_GREEN, textadmin);
return 1;
}
But when I use the command ingame (i do get the score), But the text is bugged.
What it says: [ADMIN] has set yo. And [ADMIN] You have se.
Re: SendClientMessage ingame error -
Konstantinos - 02.06.2016
You use %s specifier which is for strings and it's expecting a string not an integer as argument.
pawn Код:
format(textadmin, sizeof(textadmin),"[ADMIN] You have set the score of %s to: %i", name, score);
Get the name of the admin too and format it correctly. Also use 1 string for the output and increase its size from 20 to a tleast 71 characters.
Re: SendClientMessage ingame error -
Deroxi - 02.06.2016
Ah i see, I've been a total spoon