strlen
#1

Hey! I tried to add strlen to my command so users can't enter strings larger than 24 characters. This code won't work, and I have no idea why.
Код:
 
    if(sscanf(params, "s[24]", params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /bizname [name]");
    if(strlen(params) > 24) return SendClientMessage(playerid, COLOR_GREY, "Maximum character limit is 24.");
Does anyone know what to add so it will work?
Reply
#2

Basically s[24] makes sure that the string obtained will be at least 24 chars long, the rest is truncated. Change it to s[25] (in your string declaration aswell)
Reply
#3

Swap the order.
Reply
#4

where do I put params than? I mean what to use instead of sscanf to get string?
Reply
#5

pawn Код:
#if !defined isnull
    #define isnull(%1) \
                ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
#endif
pawn Код:
if(isnull(params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /bizname [name]");
// rest..
Reply
#6

thank you so much guys, now I understand sscanf and strlen.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)