SA-MP Forums Archive
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=450066)



strlen - dominik523 - 11.07.2013

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?


Re: strlen - Misiur - 11.07.2013

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)


Re: strlen - MP2 - 11.07.2013

Swap the order.


Re: strlen - dominik523 - 11.07.2013

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


Re: strlen - Konstantinos - 11.07.2013

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..



Re: strlen - dominik523 - 11.07.2013

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