Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Topo do script
- #define MAX_COUNTRY_NAME 64
- public OnPlayerConnect(playerid) {
- if(strcmp("127.0.0.1", GetPlayerIPEx(playerid), true) != 0) {
- format(STRX, 128, "ip-api.com/json/%s", GetPlayerIPEx(playerid));
- HTTP(playerid, HTTP_GET, STRX, "", "HTTP_Connect");
- return 1;
- }
- forward HTTP_Connect(playerid, response_codec, data[]);
- public HTTP_Connect(playerid, response_codec, data[]) {
- if(response_codec != 200) {
- SetPVarString(playerid, "Pais", "Desconhecido"), SetPVarString(playerid, "Estado", "Desconhecido"), SetPVarString(playerid, "Cidade", "Desconhecida");
- return 1;
- }
- new string[128], pos;
- if(strfind(data, "Reserved", true) == -1 && strlen(data) >= 15) {
- if((pos = strfind(data, "\"country\":")) != -1)
- {
- pos += 11;
- strmid(string, data, pos, strfind(data, "\"", true, pos));
- SetPVarString(playerid, "Pais", string);
- }
- if((pos = strfind(data, "\"regionName\":")) != -1)
- {
- pos += 14;
- strmid(string, data, pos, strfind(data, "\"", true, pos));
- SetPVarString(playerid, "Estado", string);
- }
- if((pos = strfind(data, "\"city\":")) != -1)
- {
- pos += 8;
- strmid(string, data, pos, strfind(data, "\"", true, pos));
- SetPVarString(playerid, "Cidade", string);
- }
- }
- GetPVarString(playerid, "Pais", string, MAX_COUNTRY_NAME);
- if(strfind(string, "Brazil", true) == -1 && strfind(string, "Portugal", true) == -1 && strfind(string, "France", true) == -1 && strfind(string, "Desconhecido", true) == -1)
- {
- SendClientMessage(playerid, 0xFF0000AA, "A entrada de seu IP não é permitida.");
- Kick(playerid);
- }
- return 0;
- }
- stock GetPlayerCountry(playerid)
- {
- new string[MAX_COUNTRY_NAME];
- GetPVarString(playerid, "Pais", string, MAX_COUNTRY_NAME);
- return string;
- }
- stock GetPlayerRegion(playerid)
- {
- new string[MAX_COUNTRY_NAME];
- GetPVarString(playerid, "Estado", string, MAX_COUNTRY_NAME);
- return string;
- }
- stock GetPlayerCountry(playerid)
- {
- new string[MAX_COUNTRY_NAME];
- GetPVarString(playerid, "Pais", string, MAX_COUNTRY_NAME);
- return string;
- }
Add Comment
Please, Sign In to add comment