Split text in two - returns я?
#1

Here's my code:
Код:
CMD:do(playerid, params[])
{
	new action[100];
	if(!CharacterLogged(playerid)) return ErrorMSG(playerid, "You are not logged in.");
	if(sscanf(params, "u", action)) return UsageMSG(playerid, "/do [action]");
	
	if(strlen(action) > 80)
	{
		new pos = 80;
		if(pos < 80-1) pos = 80;
		format(msg, sizeof(msg), "* %.*s ... (( %s ))", pos, action, GetNameEx(playerid));
		ProxDetector(20.0, playerid, msg, COLOR_PURPLE);
		format(msg, sizeof(msg), "* ... %s (( %s ))", action[pos], GetNameEx(playerid));
		ProxDetector(20.0, playerid, msg, COLOR_PURPLE);
	}
	else
	{
		format(msg, sizeof(msg), "* %s (( %s ))", action, GetNameEx(playerid));
		ProxDetector(20.0, playerid, msg, COLOR_PURPLE);
		printf("%s", msg);
	}
	return CMD_SUCCESS;
}
ProxDetector:
Код:
stock ProxDetector(Float:radi, playerid, string[],color)
{
    new Float:x,Float:y,Float:z;
    GetPlayerPos(playerid,x,y,z);
    foreach(Player,i)
    {
        if(IsPlayerInRangeOfPoint(i,radi,x,y,z)) 
        {
            SendClientMessage(i,color,string);
	    }
    }
}
How can that return "я (( Player_Name ))
Even if it is under 80 characters (when the message doesn't get split into two SCM) I get this. Uh?
Reply
#2

In this case, the specifier 'u' won't work. It only applies to usernames and IDs. Use 's' instead.

Note: using the 's' specifier requires you to put the size of the variable next to it:
PHP код:
sscanf(params"s[SIZE_HERE]"variable)) 
Read the original topic: https://sampforum.blast.hk/showthread.php?tid=570927
Reply
#3

Quote:
Originally Posted by AndySedeyn
Посмотреть сообщение
In this case, the specifier 'u' won't work. It only applies to usernames and IDs. Use 's' instead.

Note: using the 's' specifier requires you to put the size of the variable next to it:
PHP код:
sscanf(params"s[SIZE_HERE]"variable)) 
Read the original topic: https://sampforum.blast.hk/showthread.php?tid=570927
Oh shit didn't notice, ops my bad. But.. will that affect the reponse I get though? Will try. Yep thanks :P
Reply
#4

Actually sscanf is not necessary when the parameter is a single string. You can use:
pawn Код:
if (!isnull(params)) return UsageMSG(playerid, "/do [action]");
and you just use "params" instead of "action".

Another thing to note is the foreach syntax you are using is deprecated. Use:
pawn Код:
foreach(new i : Player)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)