Offline Command
#1

hello there
can someone help me to convert this command to get offline player offlineip
thanks

PHP код:
CMD:ip(playerid,params[]) {
    if(
PlayerInfo[playerid][Level] >= 1) {
        if(
isnull(params)) return SendClientMessage(playeridred"USAGE: /ip [playerid]");
        new 
player1 strval(params), string[128];
        if(
PlayerInfo[player1][Level] == ServerInfo[MaxAdminLevel] && PlayerInfo[playerid][Level] != ServerInfo[MaxAdminLevel]) return SendClientMessage(playerid,red,"ERROR: You cannot use this command on this admin");
        if(
IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID) {
            
CMDMessageToAdmins(playerid,"IP");
            new 
tmp3[50]; GetPlayerIp(player1,tmp3,50);
            
format(string,sizeof(string),"\"%s's\" ip is '%s'"pName(player1), tmp3);
            return 
SendClientMessage(playerid,blue,string);
        } else return 
SendClientMessage(playerid,red,"ERROR: Player is not connected");
    } else return 
SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");

Reply
#2

I can not convert it for you but I can try give you some help for how you can do it.
You would first need to store the players IP (When he connect or disconnect) in some file with his name for easier access.
Then change the command so it will search for his name where ever you save those files.

It's a long time since I've been coding and I was lazy so only "know" dini but here is an example on how you can get the stored IP once you've saved it.

PHP код:
    new name[MAX_PLAYER_NAME];
    new 
string[60];
    
GetPlayerName(playeridnameMAX_PLAYER_NAME);
    
format(string,sizeof(string),"SaveFolderForIP/%s.ini"name);
    if(
dini_Exists(string))
    {
        
/*
        If the file exist, get the IP stored inside.
        */
        
return true;
    } 
Reply
#3

-- Delete It's Double post from lag Sorry --
Reply
#4

Why get IP ? its worse
Player IP can change everytime they leave or connect I prefer to load User Data Better its more worth
try this ( this is example idea )
PHP код:
//top of scripts
#define strcpy(%0,%1) \
    
strcat((%0[0] = '\0', %0), %1)
#define MAX_PLAYERS_FILE 9000
new offlineplayerstr[64];
new 
tmpstr[64];
CMD:offlineinfo(playerid,params[])
{
    if(
PlayerInfo[playerid][Level] >= 1)
    {
        
        if(
sscanf(params"s[25]"offlineplayerstr)) return SendClientMessage(playeridCOLOR_RED1"[SYSTEM][EXPLAIN] :/offlineinfo (playername)")
        else
        {
            
LoadPlayerInfoOffline();
            
SCM(playerid,COLOR_YELLOW,tmpstr);
        }
    } else return 
SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");
}
LoadPlayerInfoOffline()
{
        for (new 
i=MAX_PLAYERS_FILE i++)
        {
             new 
file[100];
             new 
tmploadname[64],tmpip[28];
            
format(file,sizeof(file),"saveuser/%s.ini",offlineplayerstr);
            if(!
dini_Exists(file)) 
                         {
              
/*get player info blahg blah your condition
                like example of this*/
                
strcpy(tmpip,dini_Get(file,"Player IP:"),28); //copy str need strcpy
                
                
format(tmpstr,sizeof(tmpstr),"Player Name %s , Player IP %s",offlineplayerstr,tmpip);
              }
            
        }
        return 
tmpstr;

*Edit : Change public to stock if you can do better just write it down , I made it for public function just simple ideas make easy to understand so he can adapt to his server or he can re-scripts & if its wrong you just write it new one not better ? , hmm... if you asking different here https://sampforum.blast.hk/showthread.php?tid=281094 if you ask its for correct just write it and make it correct , apologize my fools code too and sorry for my bad grammar I still newbie noob so you are professional Genius just make it correct so its' good or another people and owner then
Reply
#5

Quote:
Originally Posted by colonel-top
Посмотреть сообщение
Why get IP ? its worse
Player IP can change everytime they leave or connect I prefer to load User Data Better its more worth
try this ( this is example idea )
PHP код:
#define MAX_PLAYERS_FILE 9000
new offlineplayerstr[64];
new 
tmpstr[64];
CMD:offlineinfo(playerid,params[])
{
    if(
PlayerInfo[playerid][Level] >= 1)
    {
        
        if(
sscanf(params"s[25]"offlineplayerstr)) return SendClientMessage(playeridCOLOR_RED1"[SYSTEM][EXPLAIN] :/offlineinfo (playername)")
        else
        {
            
LoadPlayerInfoOffline();
            
SCM(playerid,COLOR_HAHAHA,tmpstr);
        }
    } else return 
SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");
}
forward LoadPlayerInfoOffline();
public 
LoadPlayerInfoOffline()
{
        for (new 
i=MAX_PLAYERS_FILE i++)
        {
             new 
file[100];
             new 
tmploadname[64],tmpip[28];
            
format(file,sizeof(file),FACTION_FILE,i);
            if(!
dini_Exists(file)) continue;
            
strcpy(tmploadname,dini_Get(file,"Player Name:"),25);
            if(!
strcmp(offlineplayerstr,tmploadname))
            {
                
/*get player info blahg blah your condition
                like example of this*/
                
strcpy(tmploadname,dini_Get(file,"Player Name:"),25);
                
strcpy(tmpip,dini_Get(file,"Player IP:"),28);
                
                
format(tmpstr,sizeof(tmpstr),"Player Name %s , Player IP %s",tmploadname,tmpip);
                
            }
        }
        return 
tmpstr;

Why is it public function?
Reply
#6

Doesn't need to public or stock...


A function alone will suffice.

PHP код:
forward LoadPlayerInfoOffline(); 
LoadPlayerInfoOffline() 

Reply
#7

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
Doesn't need to public or stock...


A function alone will suffice.

PHP код:
forward LoadPlayerInfoOffline(); 
LoadPlayerInfoOffline() 

You don't need to forward it even,

PHP код:
LoadPlayerInfoOffline() 

Reply
#8

Quote:
Originally Posted by jlalt
Посмотреть сообщение
You don't need to forward it even,

PHP код:
LoadPlayerInfoOffline() 

For someone who doesn't know, could you explain the difference?
Reply
#9

Quote:
Originally Posted by MarikAshtar
Посмотреть сообщение
For someone who doesn't know, could you explain the difference?
https://sampforum.blast.hk/showthread.php?tid=341545
Reply
#10

Quote:
Originally Posted by Stinged
Посмотреть сообщение
Thank you
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)