• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] how to get the last digit of a player's IP
#9
(2021-07-16, 12:18 AM)Kwarde Wrote: No idea how you treat VPN users.

Since strfind() returns -1 (not found) or the position where the string you're looking for was found. Since the piece of code I sent checks if the returned value of strfind is 0, it returns true (the statement itself) if an IP starts with "192.168.1" (without a dot at the end, "192.168.10.2" would be valid too).



I do recommend sscanf tho. What that piece of code did was unformatting a string. So instead of:



format(ip, sizeof(ip), "%d.%d.%d.%d", ip_part1, ip_part2, ip_part3, ip_part4);



It did the opposite. "p<.>dddd" tells the function to split the string in 4 integers (stored in the variables defined after the unformat specifiers) divided by ".". By default (without the p specifier) it splits strings by spaces. It is very widely used in commands (it replaced strtok()). You may want to consider using it anyway (efficient, fast, reliable, easy to use when you get the hang of it). Up to you though.



hmm, quite interesting. might use it in the future whe i get the hang of it as you said. and yeah about the vpn users, it's just a message to everyone and a kick since when players get banned, they want to evade it by using things such as vpn, so yeah, there we go
  Reply


Messages In This Thread
RE: how to get the last digit of a player's IP. - by mems - 2021-07-16, 12:26 AM

Forum Jump: