Scripting with ip
#1

how can i get that player has typed an ip
Reply
#2

There is no actual proper detection but you can use https://sampwiki.blast.hk/wiki/Strfind under OnPlayerText or OnPlayerCommandText to search for 3 full stops and a colon?
Reply
#3

don't allow more than 1 dot heh
Reply
#4

well,not allowing more than 1 dot wont be good,it would be a failure,lets say 2 players are chatting,and one of them said a sentence and used ..... instead of completing it he would be counted as ip sharing so,when i am back home i will make the code for you
Reply
#5

Regex plugin would be the most accurate method.
Reply
#6

Quote:
Originally Posted by R0
Посмотреть сообщение
well,not allowing more than 1 dot wont be good,it would be a failure,lets say 2 players are chatting,and one of them said a sentence and used ..... instead of completing it he would be counted as ip sharing so,when i am back home i will make the code for you
thanks bro waiting for it

Quote:
Originally Posted by Vince
Посмотреть сообщение
Regex plugin would be the most accurate method.
can u give link for it
Reply
#7

https://sampforum.blast.hk/showthread.php?tid=247893

If you'll search the topic you'll even find a regex expression for detecting an ip.

Quote:
Originally Posted by Fro1sha
Посмотреть сообщение
This version faster =)
pawn Код:
stock ContainsIPEx(const string[])
{
    static
        RegEx:rCIP
    ;
   
    if ( !rCIP )
    {      
        rCIP = regex_build("(.*?)([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})(.*?)");
    }
   
    return regex_match_exid(string, rCIP);
}
But be aware that if a player types for example 10.000.000.000 this function will detect it.
Reply
#8

thanks but how can i use this to get the ip ??
Reply
#9

pawn Код:
public OnPlayerText(playerid, text[])
{
      if(ContainsIPEx(text)) SendClientMessage(playerid, -1, "Don't write ip addresses on chat.");
      else SendClientMessageToAll(-1, text);
      return 0;
}
Just an idea. If you understand how regex works you can do more.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)