SA-MP Forums Archive
IP comand? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: IP comand? (/showthread.php?tid=88440)



IP comand? - jonybomb - 26.07.2009

I am trying to make a command like /ip (ID) to see the ip of someone, but I can't, appears to me other things and not the ip lol ..

I think it's very easy and don't know why I can't, but if someone help me was good


Re: IP comand? - refshal - 26.07.2009

Ok, I was bored, so I made you the whole filterscript. You must be logged in RCON to use the command. Command = "/getip", script:

pawn Код:
#include <a_samp>

strtok(const string[], &index)
{
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }

    new offset = index;
    new result[20];
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
  if(strcmp(cmdtext, "/getip", true) == 0)
  {
    if(IsPlayerAdmin(playerid))
    {
      new text[128];
      new index;
      text = strtok(cmdtext, index);
      if(!strlen(text))
      {
        SendClientMessage(playerid, 0xFFFFFFFF,"Usage: /getip [playerid]");
        return 1;
      }
      new player;
      player = strval(text);
      if(IsPlayerConnected(player))
      {
        new string[128];
      new name[MAX_PLAYER_NAME];
      new IP[20];
      GetPlayerName(player, name, sizeof(name));
        GetPlayerIp(player, IP, sizeof(IP));
        format(string, sizeof(string), "%s's IP: %s", name, IP);
        SendClientMessage(playerid, 0xFFFFFFFF, string);
        return 1;
      }
      else return SendClientMessage(playerid, 0xFFFFFFFF,"Player is not connected");
    }
    else return 0;
  }
  return 0;
}



Re: IP comand? - James_Alex - 26.07.2009

Quote:
Originally Posted by еddy
Ok, I was bored, so I made you the whole filterscript. You must be logged in RCON to use the command. Command = "/getip", script:

pawn Код:
#include <a_samp>

strtok(const string[], &index)
{
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }

    new offset = index;
    new result[20];
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
  if(strcmp(cmdtext, "/getip", true) == 0)
  {
    if(IsPlayerAdmin(playerid))
    {
      new text[128];
      new index;
      text = strtok(cmdtext, index);
      if(!strlen(text))
      {
        SendClientMessage(playerid, 0xFFFFFFFF,"Usage: /getip [playerid]");
        return 1;
      }
      new player;
      player = strval(text);
      if(IsPlayerConnected(player))
      {
        new string[128];
     new name[MAX_PLAYER_NAME];
     new IP[20];
     GetPlayerName(player, name, sizeof(name));
        GetPlayerIp(player, IP, sizeof(IP));
        format(string, sizeof(string), "%s's IP: %s", name, IP);
        SendClientMessage(playerid, 0xFFFFFFFF, string);
        return 1;
      }
      else return SendClientMessage(playerid, 0xFFFFFFFF,"Player is not connected");
    }
    else return 0;
  }
  return 0;
}
nice


Re: IP comand? - jonybomb - 26.07.2009

pawn Код:
strtok(const string[], &index)
{
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }

    new offset = index;
    new result[20];
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}
Where i put this part?

And i also eliminated if(isplayeradmin), because i want this comando for all ppl lol, by rcon i have /rcon players


Re: IP comand? - MadeMan - 26.07.2009

You can put it at the end of your script.


Re: IP comand? - jonybomb - 26.07.2009

I have that

Quote:

C:\Documents and Settings\Mario\AT\doc\gamemodes\gm.pwn(14725) : warning 219: local variable "string" shadows a variable at a preceding level
C:\Documents and Settings\Mario\AT\doc\gamemodes\gm.pwn(14741) : warning 225: unreachable code
C:\Documents and Settings\Mario\AT\doc\gamemodes\gm.pwn(29479) : error 021: symbol already defined: "strtok"




Re: IP comand? - refshal - 26.07.2009

I gave you a filterscript... Just compile the code I gave you. Copy and paste.


Re: IP comand? - jonybomb - 26.07.2009

I know, but, limit of FS is 16, i need some filterscripts, i want put this script on gamemode


Re: IP comand? - jonybomb - 26.07.2009

Ok, i put in a FS and i test, and i think you make that wrong, i only writte /getip, and show mi ip lol, only show my ip :P


Re: IP comand? - Jefff - 26.07.2009

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
	new cmd[128],index;
	cmd = strtok(cmdtext, index);
	if(strcmp(cmd, "/getip", true) == 0)
	{
		if(IsPlayerAdmin(playerid))
		{
			new text[128];
			text = strtok(cmdtext, index);
			if(!strlen(text)) return SendClientMessage(playerid, 0xFFFFFFFF,"Usage: /getip [playerid]");
			new player = strval(text);
			if(IsPlayerConnected(player))
			{
				new string[128];
				new name[MAX_PLAYER_NAME];
				new IP[20];
				GetPlayerName(player, name, sizeof(name));
				GetPlayerIp(player, IP, sizeof(IP));
				format(string, sizeof(string), "%s's IP: %s", name, IP);
				SendClientMessage(playerid, 0xFFFFFFFF, string);
			}else SendClientMessage(playerid, 0xFFFFFFFF,"Player is not connected");
		}else SendClientMessage(playerid, 0xFFFFFFFF,"Only for admins !");
		return 1;
	}
	return 0;
}