Split text in two - returns я? - 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: Split text in two - returns я? (
/showthread.php?tid=614133)
Split text in two - returns я? -
TheBigFive - 04.08.2016
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?
Re: Split text in two - returns я? -
AndySedeyn - 04.08.2016
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
Re: Split text in two - returns я? -
TheBigFive - 04.08.2016
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
Re: Split text in two - returns я? -
Konstantinos - 04.08.2016
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: