Advertisement
Guest User

Untitled

a guest
Mar 7th, 2012
3,071
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.55 KB | None | 0 0
  1. /////////////////////////////////////////////////////
  2. ///////////// Script by Abhinav ////////////////////
  3. ///////////////////////////////////////////////////
  4.  
  5. #include <a_samp>
  6. #define COLOR_JOIN 0x99FF9900
  7.  
  8. new Params[4][8];
  9. new FileData[7][128];
  10. public OnFilterScriptInit()
  11. {
  12.     print("\n--------------------------------------");
  13.     print(" Country FileScript by Abhinav");
  14.     print("--------------------------------------\n");
  15.     return 1;
  16. }
  17.  
  18. public OnFilterScriptExit()
  19. {
  20.     return 1;
  21. }
  22.  
  23. public OnPlayerConnect(playerid)
  24. {
  25.     new Country[256];
  26.     GetPlayerCountry(playerid,Country);
  27.     new mess[256],IP[256];
  28.     GetPlayerIp(playerid,IP,sizeof(IP));
  29.     format(mess,sizeof(mess),"%s has joined the server.  [ Country: %s | IP Address: %s | Ping: %i ]",GetPName(playerid),Country,IP,GetPlayerPing(playerid));
  30.     printf(mess);
  31.     SendClientMessageToAll(COLOR_JOIN,mess);
  32.     return 1;
  33. }
  34.  
  35.  
  36. GetParams(Source[]){
  37.     new Destination[256];
  38.     new SLen=strlen(Source);
  39.     new at,pos=0,tp=0;
  40.     new tempo[256];
  41.  
  42.     ////////////// Clearing DATA /////////////////    FOR LOOP WAS NOT WORKING FOR THIS PURPOSE
  43.     format(Params[0],sizeof(Params),"");
  44.     format(Params[1],sizeof(Params),"");
  45.     format(Params[2],sizeof(Params),"");
  46.     format(Params[3],sizeof(Params),"");
  47.  
  48.     /////////////////////////////////////////////
  49.  
  50.     for(at=pos;at<=SLen;at++){
  51.         strmid(tempo,Source,at,at+1,sizeof(tempo));
  52.         if(!strcmp(tempo,".",true)){
  53.             if(tp<=10){
  54.                 strmid(Destination,Source,pos,at,sizeof(Destination));
  55.                 format(Params[tp][0],256,"%s",Destination);
  56.                 tp=tp+1;
  57.             }
  58.             pos=at+1;
  59.         }
  60.     }
  61.     return 1;
  62. }
  63.  
  64.  
  65. GetFileData(Source[]){
  66.     new Destination[256];
  67.     new SLen=strlen(Source);
  68.     new at,pos=0,tp=0;
  69.     new tempo[256];
  70.  
  71.     ////////////// Clearing DATA /////////////////    FOR LOOP WAS NOT WORKING FOR THIS PURPOSE
  72.     format(FileData[0],sizeof(FileData),"");
  73.     format(FileData[1],sizeof(FileData),"");
  74.     format(FileData[2],sizeof(FileData),"");
  75.     format(FileData[3],sizeof(FileData),"");
  76.     format(FileData[4],sizeof(FileData),"");
  77.     format(FileData[5],sizeof(FileData),"");
  78.     format(FileData[6],sizeof(FileData),"");
  79.     /////////////////////////////////////////////
  80.  
  81.     for(at=pos;at<=SLen;at++){
  82.         strmid(tempo,Source,at,at+1,sizeof(tempo));
  83.         if(!strcmp(tempo,",",true)){
  84.             if(tp<=10){
  85.                 strmid(Destination,Source,pos,at,sizeof(Destination));
  86.                 format(FileData[tp][0],256,"%s",Destination);
  87.                 tp=tp+1;
  88.             }
  89.             pos=at+1;
  90.         }
  91.     }
  92.     return 1;
  93. }
  94.  
  95. GetPlayerCountry(playerid,Country[256]){
  96.     new IPAddress[256];
  97.     new a,b,c,d,ipf;
  98.     new File:IPFile;
  99.     new Text[256],start,end;
  100.     GetPlayerIp(playerid,IPAddress,sizeof(IPAddress));
  101.     GetParams(IPAddress);
  102.     a=strval(Params[0]);
  103.     b=strval(Params[1]);
  104.     c=strval(Params[2]);
  105.     d=strval(Params[3]);
  106.     if(a==127 && b==0 && c==0 && d==1){
  107.         format(Country,sizeof(Country),"Localhost");
  108.         return 1;
  109.     }
  110.     ipf = (16777216*a) + (65536*b) + (256*c) + d;
  111.     if(!fexist("CountriesIPs/IPLIST.csv")) return SendClientMessage(playerid,0xFF0000FF,"Country file not found.");
  112.     IPFile=fopen("CountriesIPs/IPLIST.csv",io_read);
  113.     fread(IPFile,Text,sizeof(Text),false);
  114.     while(strlen(Text)>0){
  115.         GetFileData(Text);
  116.         start=strval(FileData[0]);
  117.         end=strval(FileData[1]);
  118.         if(ipf>=start && ipf<=end){
  119.             format(Country,sizeof(Country),"%s(%s)",FileData[6],FileData[5]);
  120.             fclose(IPFile);
  121.             return 1;
  122.         }
  123.         fread(IPFile,Text,sizeof(Text),false);
  124.     }
  125.     fclose(IPFile);
  126.     return 1;
  127. }
  128.  
  129. GetPName(playerid){
  130.     new name[MAX_PLAYER_NAME];
  131.     GetPlayerName(playerid, name, sizeof(name));
  132.     return name;
  133. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement