sscanf2 problem - string and message
#1

Hello.

I've got a little problem with sscanf 2.6 - it's about the string. Let me show the code first:

Код:
new playerid2, reason[128];
if(!sscanf(params, "us[128]", playerid2, reason))
{
	new string[256];
	format(string,sizeof(string),"[INFO]{C0C0C0} Player {FFFF00}%s (ID %d){C0C0C0} has been banned by {FFFF00}%s (ID %d){C0C0C0} (Reason: %s)!",GetName(playerid2),playerid2,GetName(playerid),playerid,reason);
	SendClientMessageToAll(yellow,string);
}
else return SendClientMessage(playerid,red,"[USAGE]{C0C0C0} /ban [playerid] [reason]");
It's a testing message. Problem is that when I try to ban myself, it shows ~30 characters in a reason instead 128 like I did in "us[128]". If I would ban a player with 5 more characters than in my nickname, it would allow to show 5 less symbols in the end. If I input too much letters in a reason, this message won't show. Could anyone help me with that to allow sending a message in chat which would show all symbols in a reason?

PS: I use 256 cells because I also use colour embedding and sometimes 128 isn't enough (sentence 'breaks' in the end).
Reply
#2

right and SendClientMessage will only print the first 128
so even if you sent 256 or whatever it will always prinbt the first 128,
counting the color codes and brackets also.

I suggest sending all the info one line but the reason and then send a second client message with the reason

pawn Код:
new string[128];
    format(string,sizeof(string),"[INFO]{C0C0C0} Player {FFFF00}%s (ID %d){C0C0C0} has been banned by {FFFF00}%s (ID %d)",GetName(playerid2),playerid2,GetName(playerid),playerid);
    SendClientMessageToAll(yellow,string);
    format(string,sizeof(string),"(Reason: %s)!",reason);   //now reason can be 119 chars long
    SendClientMessageToAll(0xC0C0C0,string);
Reply
#3

Ok. I think I will remove 16 symbols for colour embedding (which highlights Administrator's name) and disallow adding a reason with 25 or more symbols. I can't use it in two messages, because all other are in one. But thanks for anwser, now I know another thing about it
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)