params
#1

i was using this command but whenever i use this the parmas are not working even i type /ip instead of /ip <id> it shows my ip not the others but when i use like /ip 1 it says the player is not connected

it's my player file

pawn Код:
#define PlayerFile "CAdmin/Users/%s.ini"
pawn Код:
CMD:ip(playerid,params[])
{
    if(gPlayerInfo[playerid][Level] >= 1)
    {

        new file[100], name[MAX_PLAYER_NAME];
//          new str[128];
//      new PlayerName[MAX_PLAYER_NAME];
       
        if(!strlen(params)) return
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Usage: /ip [PlayerID]") &&
        SendClientMessage(playerid, COLOR_ORANGE, "Function: Will see Ip of specified player");
        new player1 = strval(params);
        new string[128];
        new pName[MAX_PLAYER_NAME];
        GetPlayerName(player1, pName, sizeof(pName));
        if(gPlayerInfo[player1][Level] == MAX_ADMIN_LEVEL && gPlayerInfo[playerid][Level] != MAX_ADMIN_LEVEL)
        return SendClientMessage(playerid,COLOR_RED,"ERROR: You cannot use this command on this admin");
        if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID)
        {
            GetPlayerName(player1, name, sizeof(name));
            format(file, sizeof(file), PlayerFile, name);
//          SendCommandToAdmins(playerid,"Ip");
            new tmp3[50];
            GetPlayerIp(player1,tmp3,50);
            format(string,sizeof(string),"PlayerName: %s | IP: %s", file, tmp3);
            return SendClientMessage(playerid,COLOR_YELLOW,string);
        }
        else return ErrorMessages(playerid, 2);
    }
    else return ErrorMessages(playerid, 1);
}
Reply
#2

use sscanf instead.me too was suffering from this.I used sscanf and now it works fine
Reply
#3

can u explain me how
Reply
#4

Quote:
Originally Posted by CBCandyBoy
Посмотреть сообщение
i was using this command but whenever i use this the parmas are not working even i type /ip instead of /ip <id> it shows my ip not the others but when i use like /ip 1 it says the player is not connected

it's my player file

pawn Код:
#define PlayerFile "CAdmin/Users/%s.ini"
pawn Код:
CMD:ip(playerid,params[])
{
    if(gPlayerInfo[playerid][Level] >= 1)
    {

        new file[100], name[MAX_PLAYER_NAME];
//          new str[128];
//      new PlayerName[MAX_PLAYER_NAME];
       
        if(!strlen(params)) return
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "Usage: /ip [PlayerID]") &&
        SendClientMessage(playerid, COLOR_ORANGE, "Function: Will see Ip of specified player");
        new player1 = strval(params);
        new string[128];
        new pName[MAX_PLAYER_NAME];
        GetPlayerName(player1, pName, sizeof(pName));
        if(gPlayerInfo[player1][Level] == MAX_ADMIN_LEVEL && gPlayerInfo[playerid][Level] != MAX_ADMIN_LEVEL)
        return SendClientMessage(playerid,COLOR_RED,"ERROR: You cannot use this command on this admin");
        if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID)
        {
            GetPlayerName(player1, name, sizeof(name));
            format(file, sizeof(file), PlayerFile, name);
//          SendCommandToAdmins(playerid,"Ip");
            new tmp3[50];
            GetPlayerIp(player1,tmp3,50);
            format(string,sizeof(string),"PlayerName: %s | IP: %s", file, tmp3);
            return SendClientMessage(playerid,COLOR_YELLOW,string);
        }
        else return ErrorMessages(playerid, 2);
    }
    else return ErrorMessages(playerid, 1);
}




pawn Код:
CMD:ip(playerid,params[])
{
    new tmp[256],new idx=0;
    if(gPlayerInfo[playerid][Level] >= 1)
    {

        if(!strlen(params)) return SendClientMessage(playerid, COLOR_LIGHTBLUE, "Usage: /ip [PlayerID]"), SendClientMessage(playerid, COLOR_ORANGE, "Function: Will see Ip of specified player");
      tmp=strtok(params,idx);
        new player1 = strval(tmp);
        new string[128];
        new pName[MAX_PLAYER_NAME];
        GetPlayerName(player1, pName, sizeof(pName));
        if(gPlayerInfo[player1][Level] == MAX_ADMIN_LEVEL && gPlayerInfo[playerid][Level] != MAX_ADMIN_LEVEL)
        return SendClientMessage(playerid,COLOR_RED,"ERROR: You cannot use this command on this admin");
        if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID)
        {
            new tmp3[50];
            GetPlayerIp(player1,tmp3,50);
            format(string,sizeof(string),"PlayerName: %s | IP: %s", pName, tmp3);
            SendClientMessage(playerid,COLOR_YELLOW,string);
        }
        else return ErrorMessages(playerid, 2);
    }
    else return ErrorMessages(playerid, 1);
}
I am not sure, but I have fixed some issues. Try it
Reply
#5

pawn Код:
COMMAND:getip(playerid, params[])
{
    new ip[16], target;
    if(sscanf(params, "u", target)) return SendClientMessage(playerid, -1, "USAGE: /getip (playername/ID)");
    else if(!IsPlayerConnected(target)) return SendClientMessage(playerid, -1, "Specified player not connected.");
    {
         GetPlayerIp(target, ip, sizeof( ip) );
         // format
         // return Send..
    }
    return 1;
}
This is the basic code, edit it to your needs.
Also, some tips:
1) Use sscanf2 for better checking of parameters, since it gets quite difficult (for me) to check multiple parameters in a command like /givecash (playerid) (money) and you have to use strtok and all that.
2) The IP of a person is only maximum 16 - so you need not make an array of 50 indexes for that.
Reply
#6

Quote:
Originally Posted by Rajat_Pawar
Посмотреть сообщение
pawn Код:
COMMAND:getip(playerid, params[])
{
    new ip[16], target;
    if(sscanf(params, "u", target)) return SendClientMessage(playerid, -1, "USAGE: /getip (playername/ID)");
    else if(!IsPlayerConnected(target)) return SendClientMessage(playerid, -1, "Specified player not connected.");
    {
         GetPlayerIp(target, ip, sizeof( ip) );
         // format
         // return Send..
    }
    return 1;
}
This is the basic code, edit it to your needs.
As I know, he doesn't use sscanf
Reply
#7

ok can u explain me how to use sscanf
Reply
#8

ok but instead of that return 1 i want it to return a client message can i do that
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)