IP comand?
#1

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
Reply
#2

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;
}
Reply
#3

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
Reply
#4

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
Reply
#5

You can put it at the end of your script.
Reply
#6

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"

Reply
#7

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

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

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
Reply
#10

Код:
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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)