Strlen
#1

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

Код:
if(sscanf(params,"s[130]",adminctext)) bla bla
new adminctext[numbers of string];
Did you have put in the command?
Reply
#3

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");
Reply
#4

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");
Reply
#5

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)