Using strfind - 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: Using strfind (
/showthread.php?tid=316456)
Using strfind -
2KY - 06.02.2012
I have this define:
pawn Код:
#define DIALOG_TEXT_REASONS "Cheaters\nHi\nHl\nHel\nHi"
/*
Edit this string with your available reasons to kick a player.
Put \n between reasons.
Example: Cheating\nFlaming would display: Cheating
Flaming
*/
and I'm trying to count the number of \n's and increase the number of the variable according to it like so:
pawn Код:
new lines = 0;
for( new i; i < 255; i++)
{
if(strfind(DIALOG_TEXT_REASONS, "\n", true) != -1) { lines++; }
printf("lines: %d", lines);
}
What am I doing wrong?
Re: Using strfind -
IceCube! - 06.02.2012
str means string your using a define
find means find which is fine.
Put your define in somthing like this
pawn Код:
format(string, sizeof(string), "text");
Re: Using strfind -
2KY - 07.02.2012
So, something like...
pawn Код:
new lines = 0;
for( new i; i < 255; i++)
{
new Str[128];
format(Str, sizeof(Str), DIALOG_TEXT_REASONS);
if(strfind(Str, "\n", true) != -1) { lines++; }
printf("lines: %d", lines);
}
Should work? (Very crude)