SA-MP Forums Archive
I do not see the 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: I do not see the ip (/showthread.php?tid=523540)



I do not see the ip - TuNiSiAnO1 - 02.07.2014

Hello what's wrong with this.

PHP код:
  for(new i=0i<MAX_PLAYERSi++)
    {
      if(
IsPlayerAdmin(i))
      {
        new 
name[24], ip[17], stt[100];
        
GetPlayerName(playerid,name,sizeof(name));
        
GetPlayerIp(playerid,ip,sizeof(ip));
        
format(stt,sizeof(stt),"%s joined the server(%s)"name,ip);
        
SendClientMessageToAll(Gray,str);
      } 



Re: I do not see the ip - greentarch - 02.07.2014

Quote:
Originally Posted by TuNiSiAnO1
Посмотреть сообщение
Hello what's wrong with this.

PHP код:
  for(new i=0i<MAX_PLAYERSi++)
    {
      if(
IsPlayerAdmin(i))
      {
        new 
name[24], ip[17], stt[100];
        
GetPlayerName(playerid,name,sizeof(name));
        
GetPlayerIp(playerid,ip,sizeof(ip));
        
format(stt,sizeof(stt),"%s joined the server(%s)"name,ip);
        
SendClientMessageToAll(Gray,str);
      } 
Erm. I don't really understand that code (a little weird, sorry I have to call that)
Why..? You probably ask that.
It's because your checking if someone is an administrator, you are sending a message to all players

I made 2 versions for you, (which should work; on theory)
First version is the message, is sent to all players
pawn Код:
public OnPlayerConnect(playerid) {
    new
        pIP[17],
        pName[24],
        szStr[128];
    GetPlayerName(playerid, pName, sizeof pName);
    GetPlayerIp(playerid, pIP, sizeof pIP);
    format(szStr, sizeof (szStr), "%s has joined the server. (IP: %s)", pName, pIP);
    SendClientMessageToAll(-1, szStr);
    return 1;
}
Second version is the message, is sent to all online RCON administrators.
pawn Код:
public OnPlayerConnect(playerid) {
    new
        pIP[17],
        pName[24],
        szStr[128];
    GetPlayerName(playerid, pName, sizeof pName);
    GetPlayerIp(playerid, pIP, sizeof pIP);
    format(szStr, sizeof (szStr), "%s has joined the server. (IP: %s)", pName, pIP);
    for (new i, j = GetMaxPlayers(); i < j; ++ i) {
        if (!IsPlayerConnected(i))
            continue;
        if (IsPlayerAdmin(i)) {
            SendClientMessage(i, -1, szStr);
        }
    }
    return 1;
}
Sorry if it didn't helped..


Re: I do not see the ip - TuNiSiAnO1 - 02.07.2014

Quote:
Originally Posted by greentarch
Посмотреть сообщение
Erm. I don't really understand that code (a little weird, sorry I have to call that)
Why..? You probably ask that.
It's because your checking if someone is an administrator, you are sending a message to all players

I made 2 versions for you, (which should work; on theory)
First version is the message, is sent to all players
pawn Код:
public OnPlayerConnect(playerid) {
    new
        pIP[17],
        pName[24],
        szStr[128];
    GetPlayerName(playerid, pName, sizeof pName);
    GetPlayerIp(playerid, pIP, sizeof pIP);
    format(szStr, sizeof (szStr), "%s has joined the server. (IP: %s)", pName, pIP);
    SendClientMessageToAll(-1, szStr);
    return 1;
}
Second version is the message, is sent to all online RCON administrators.
pawn Код:
public OnPlayerConnect(playerid) {
    new
        pIP[17],
        pName[24],
        szStr[128];
    GetPlayerName(playerid, pName, sizeof pName);
    GetPlayerIp(playerid, pIP, sizeof pIP);
    format(szStr, sizeof (szStr), "%s has joined the server. (IP: %s)", pName, pIP);
    for (new i, j = GetMaxPlayers(); i < j; ++ i) {
        if (!IsPlayerConnected(i))
            continue;
        if (IsPlayerAdmin(i)) {
            SendClientMessage(i, -1, szStr);
        }
    }
    return 1;
}
Sorry if it didn't helped..
It helped thank you.