Get the ip in strcmp
#1

Solved, thanks
Reply
#2

Add this:

printf("%s %s",string,p_IP);

and you will see where is problem
Reply
#3

Quote:
Originally Posted by Matess
Посмотреть сообщение
Add this:

printf("%s %s",string,p_IP);

and you will see where is problem
Where should i add it? please be more spacefic, and the problem is that the code is not reaching the ip in the .txt
Reply
#4

Код:
new p_IP[ 16 ];
        GetPlayerIp(playerid, p_IP, 16 );
        new File:gFile2 = fopen("BanIP.txt", io_read);
        if(gFile2)
        {
            new string[50];
            while(fread(gFile2, string))
            {
                printf("%s %s",string,p_IP);// and look at the server log
                if(strcmp(string, p_IP, true) == 0)
                {
                    SendClientMessage(playerid, COLOR_RED, "TEST");
                }
            }
            fclose(gFile2);
        }
Reply
#5

Quote:
Originally Posted by Matess
Посмотреть сообщение
Код:
new p_IP[ 16 ];
        GetPlayerIp(playerid, p_IP, 16 );
        new File:gFile2 = fopen("BanIP.txt", io_read);
        if(gFile2)
        {
            new string[50];
            while(fread(gFile2, string))
            {
                printf("%s %s",string,p_IP);// and look at the server log
                if(strcmp(string, p_IP, true) == 0)
                {
                    SendClientMessage(playerid, COLOR_RED, "TEST");
                }
            }
            fclose(gFile2);
        }
Why should i do this?
The IP is already in the BanIP.txt, and p_IP is right i did it above, it's done right.
But problem is in strcmp(string, p_IP,true)==0)
it must be a " "
Anyways that what appeared in server_log

86.99.185.53
86.99.185.53

my ip appeared, my ip only is in the BanIP.txt that why
Reply
#6

Or you can try this:

pawn Код:
if(strfind(string, p_IP, true) != -1)
Btw. in server_log was

86.99.185.53
86.99.185.53//this form

or 86.99.185.53 86.99.185.53 //this form?

if the first one than you have space in string or something like "\n"
Reply
#7

Quote:
Originally Posted by Matess
Посмотреть сообщение
Or you can try this:

pawn Код:
if(strfind(string, p_IP, true) != -1)
Btw. in server_log was

86.99.185.53
86.99.185.53//this form

or 86.99.185.53 86.99.185.53 //this form?

if the first one than you have space in string or something like "\n"
It appeared this form: 86.99.185.53 86.99.185.53
What's wrong?
Reply
#8

IT WORKED, THANKS!!
Reply
#9

You need to strip off the new line '\n' and / or the return charater '\r' of the line read by fread
Or you add the character to the ip of the player to match the line in strcmp
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)