SA-MP Forums Archive
Get the ip in strcmp - 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: Get the ip in strcmp (/showthread.php?tid=500167)



Get the ip in strcmp - Semo - 11.03.2014

Solved, thanks


Re: Get the ip in strcmp - Matess - 11.03.2014

Add this:

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

and you will see where is problem


Re: Get the ip in strcmp - Semo - 11.03.2014

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


Re: Get the ip in strcmp - Matess - 11.03.2014

Код:
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);
        }



Re: Get the ip in strcmp - Semo - 11.03.2014

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


Re: Get the ip in strcmp - Matess - 11.03.2014

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"


Re: Get the ip in strcmp - Semo - 11.03.2014

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?


Re: Get the ip in strcmp - Semo - 11.03.2014

IT WORKED, THANKS!!


AW: Get the ip in strcmp - Nero_3D - 11.03.2014

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