SendClientMessage ingame error
#1

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

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

Ah i see, I've been a total spoon
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)