Strlen - 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: Strlen (
/showthread.php?tid=573792)
Strlen -
TiXz0r - 10.05.2015
Hello, i have this:
Код:
if(strlen(adminctext) > 130) return SendClientMessage(playerid, COLOR_RED, "error: long text!");
this is on admin chat and when im use /a and type 150 words, she dont say me: error: long text!.
where is problem?
Re: Strlen - justice96 - 10.05.2015
Код:
if(sscanf(params,"s[130]",adminctext)) bla bla
new adminctext[numbers of string];
Did you have put in the command?
Re: Strlen -
TiXz0r - 10.05.2015
Quote:
Originally Posted by justice96
Код:
if(sscanf(params,"s[130]",adminctext)) bla bla
new adminctext[numbers of string];
Did you have put in the command?
|
Код:
new adminctext[144];
Код:
if(sscanf(params, "s[130]", adminctext)) return SendClientMessage(playerid, COLOR_CYAN, "USAGE: /a");
Re: Strlen -
Stev - 10.05.2015
They are different, Keep them the same value.
Код:
new adminctext[144];
if(sscanf(params, "s[130]", adminctext)) return SendClientMessage(playerid, COLOR_CYAN, "USAGE: /a");
E.G
Код:
new message[100];
if(sscanf(params, "s[100]", message)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /a");
Re: Strlen -
Konstantinos - 10.05.2015
adminctext holds the max 130 characters stored by sscanf so the check would fail. You don't need a new string and sscanf for that though:
pawn Код:
if (isnull(params)) return SendClientMessage(playerid, COLOR_CYAN, "USAGE: /a <text>");
if (strlen(params) > 130) return SendClientMessage(playerid, COLOR_RED, "error: long text!");
...
// "params" holds the text