In the refer of t his https://forum.vc-mp.org/index.php?topic=9275.0
I want to say thanks to
@habi and
@vitovc for the help.
I tried to utilize the function and made a code it detecting its as a proxy, but in print, it said
not using a proxy While I've provided a proxy IP and it detected
(https://i.postimg.cc/bJ6cQ16N/Untitled.png)
Function
function HTTP_OnResponse(tag, url, statusCode, response)
{
print("Data received for request with tag " + tag);
print("Response: " + response);
if (tag == "proxy_check_request")
{
// Check if the request was successful
if (statusCode == 200)
{
local findProxy = response.find("proxy");
if (findProxy == "yes")
{
//Player is using a proxy
print("Using a proxy.");
}
else
{
// Player is not using a proxy
print("Not using a proxy.");
}
}
else
{
// Handle HTTP request error
print("Proxy check request failed with status code " + statusCode);
}
}
}
QuoteI want to say thanks to @habi and @vitovc for the help
you are welcome.
local findProxy = response.find("proxy");
if (findProxy == "yes")
This won't work. Change to:
local findProxy = response.find("proxy\": \"yes");
if (findProxy!= null)
Thank you so much habi its works, just because of you I made VPN detector
btw one question how do i include player name ?
+player.Name+ using VPN ?
p.s The player variable is not directly accessible inside the HTTP_OnResponse function since it's a separate callback function. We need to find a way to pass the player data from onPlayerJoin to HTTP_OnResponse
There is another way.
if(response.find(player.IP)!=null)
Put above code in a loop over all players.
Only one will match it.
Quote from: habi on Jul 19, 2023, 02:46 PMThere is another way.
if(response.find(player.IP)!=null)
Put above code in a loop over all players.
Only one will match it.
I am sorry habi, but how does player.IP helped me to get the player.Name ?
Quote from: vitovc on Jul 19, 2023, 03:05 PM1) why not work with json normally with this https://github.com/electricimp/JSONParser
Never used that JSONParser, any tip please
Get the below file from github given by vito.
then
dofile("scripts/JsonParser.class.nut")
Now at proper place do this
local tbl=JSONParser.parse( request.slice( request.find( "{" ) ) );
If you print contents of tbl, you get
[SCRIPT] status
[SCRIPT] 79.137.85.208
So the ip is indexed at position 1.
How to loop through players?
Then make a for loop from 0 to Max Players.
player = FindPlayer( i );
if( !player ) continue; //checking for null;
Now, compare IPs
if( player.IP == tbl[1] )
Quote from: habi on Jul 19, 2023, 04:29 PMGet the below file from github given by vito.
can it be done like this ?
local JSONData = JSONParser.parse(response.slice(response.find("{")));
if (JSONData != null && JSONData("player")) {
local playerName = JSONData["player"];
print("Player Name: " + playerName);
for (local i = 0; i < MaxPlayers; ++i) {
local player = FindPlayer(i);
if (!player) continue; //checking for null
if (player.IP == tbl[1]) {
print("Player IP matches: " + player.Name);
}
}
line 442 --> if (JSONData != null && JSONData("player"))
(https://i.postimg.cc/447hDbrz/Untitled.png)
if (JSONData != null ) {
//local playerName = JSONData["player"];
//print("Player Name: " + playerName);
Thank you so much habi, i finally made it
thanks to vito also for such efforts