SA-MP Forums Archive
scripting help(CMD: IP) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: scripting help(CMD: IP) (/showthread.php?tid=619834)



scripting help(CMD: IP) - Oshery - 22.10.2016

i need help with making command IP with GEO_IP in order to see players ip, can anyone please make me the code please?


Re: scripting help(CMD: IP) - 1fret - 22.10.2016

pawn Код:
CMD:getip(playerid,params[])
{
    if(IsPlayerAdmin(playerid))
    {
                new Target,pstring[128];
                if(sscanf(params, "ui", Target)) return SendClientMessage(playerid,-1,"Usage: /ip [playerid]");
                if(Target == INVALID_PLAYER_ID) return SendClientMessage(playerid,-1,"Invaild ID");
                new PIP[30];
                GetPlayerIp(Target,PIP,sizeof(PIP));
                new pstring[256];
                new tname[MAX_PLAYER_NAME];
                GetPlayerName(Target,tname,sizeof(tname));
                format(pstring,sizeof(pstring),"%sґs IP:{FFFFFF} %s",tname,PIP);
                SendClientMessage(playerid,-1,pstring);
           
    }
    else SendClientMessage(playerid,COLOR_RED,"You are not authorized to use this command!");
    return 1;
}
Are you talking something like this?


Re: scripting help(CMD: IP) - Oshery - 22.10.2016

yes but with country, can you do that please?


Re: scripting help(CMD: IP) - 1fret - 22.10.2016

DELETED


Re: scripting help(CMD: IP) - ISmokezU - 23.10.2016

You need GeoIp.


Re: scripting help(CMD: IP) - Oshery - 23.10.2016

yes but i dont exactly know how to use it with the command, can you please make the command for me?


Re: scripting help(CMD: IP) - RedMF - 23.10.2016

Quote:
Originally Posted by 1fret
Посмотреть сообщение
pawn Код:
CMD:getip(playerid,params[])
{
    if(IsPlayerAdmin(playerid))
    {
                new Target,pstring[128];
                if(sscanf(params, "ui", Target)) return SendClientMessage(playerid,-1,"Usage: /ip [playerid]");
                if(Target == INVALID_PLAYER_ID) return SendClientMessage(playerid,-1,"Invaild ID");
                new PIP[30];
                GetPlayerIp(Target,PIP,sizeof(PIP));
                new pstring[256];
                new tname[MAX_PLAYER_NAME];
                GetPlayerName(Target,tname,sizeof(tname));
                format(pstring,sizeof(pstring),"%sґs IP:{FFFFFF} %s",tname,PIP);
                SendClientMessage(playerid,-1,pstring);
           
    }
    else SendClientMessage(playerid,COLOR_RED,"You are not authorized to use this command!");
    return 1;
}
Are you talking something like this?
You code incorrect

Correct:
PHP код:
CMD:getip(playerid,params[])
{
       if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_RED,"You are not authorized to use this command!");
                new 
Target;
                if(
sscanf(params"u"Target)) return SendClientMessage(playerid,-1,"Usage: /ip [playerid]");
                if(
Target == INVALID_PLAYER_ID) return SendClientMessage(playerid,-1,"Invaild ID");
                new 
PIP[30];
                
GetPlayerIp(Target,PIP,sizeof(PIP));
                new 
pstring[256];
                new 
tname[MAX_PLAYER_NAME];
                
GetPlayerName(Target,tname,sizeof(tname));
                
format(pstring,sizeof(pstring),"%sґs IP:{FFFFFF} %s",tname,PIP);
                
SendClientMessage(playerid,-1,pstring);
    return 
1;




Re: scripting help(CMD: IP) - Oshery - 23.10.2016

Can you please do the same thing but with Country ?


Re: scripting help(CMD: IP) - ThatFag - 23.10.2016

Код:
CMD:getip(playerid,params[]) 
{ 
       if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_RED,"You are not authorized to use this command!"); 
                new Target; 
                if(sscanf(params, "u", Target)) return SendClientMessage(playerid,-1,"Usage: /ip [playerid]"); 
                if(Target == INVALID_PLAYER_ID) return SendClientMessage(playerid,-1,"Invaild ID"); 
                new PIP[30]; 
                GetPlayerIp(Target,PIP,sizeof(PIP)); 
                new pstring[256]; 
                new Country[256];
                GetPlayerCountry(playerid,Country);
                new tname[MAX_PLAYER_NAME]; 
                GetPlayerName(Target,tname,sizeof(tname)); 
                format(pstring,sizeof(pstring),"%sґs IP:{FFFFFF} %s / Country : %s",tname,PIP,Country); 
                SendClientMessage(playerid,-1,pstring); 
    return 1; 
}
here you go.

Getplayercountry
Код:
GetPlayerCountry(playerid,Country[256]){
        new IPAddress[256];
        new a,b,c,d,ipf;
        new File:IPFile;
        new Text[256],start,end;
        GetPlayerIp(playerid,IPAddress,sizeof(IPAddress));
        GetParams(IPAddress);
        a=strval(Params[0]);
        b=strval(Params[1]);
        c=strval(Params[2]);
        d=strval(Params[3]);
        if(a==127 && b==0 && c==0 && d==1){
                format(Country,sizeof(Country),"Localhost");
                return 1;
        }
        ipf = (16777216*a) + (65536*b) + (256*c) + d;
        if(!fexist("CountriesIPs/IPLIST.csv")) return SendClientMessage(playerid,0xFF0000FF,"Country file not found.");
        IPFile=fopen("CountriesIPs/IPLIST.csv",io_read);
        fread(IPFile,Text,sizeof(Text),false);
        while(strlen(Text)>0){
            GetFileData(Text);
            start=strval(FileData[0]);
            end=strval(FileData[1]);
            if(ipf>=start && ipf<=end){
                        format(Country,sizeof(Country),"%s(%s)",FileData[6],FileData[5]);
                        fclose(IPFile);
                        return 1;
            }
            fread(IPFile,Text,sizeof(Text),false);
        }
        fclose(IPFile);
        return 1;
}



Re: scripting help(CMD: IP) - Oshery - 23.10.2016

thanks but still, when i use /getip in game i see the name and the ip but not the country, can you please contact me on SKYPE or here in PM?
skype, Nelordya