params -
CBCandyBoy - 30.03.2013
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);
}
Re: params -
Gamer_007 - 30.03.2013
use sscanf instead.me too was suffering from this.I used sscanf and now it works fine
Re: params -
CBCandyBoy - 30.03.2013
can u explain me how
Re: params -
pasha97 - 30.03.2013
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
Re: params -
RajatPawar - 30.03.2013
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.
Re: params -
pasha97 - 30.03.2013
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
Re: params -
CBCandyBoy - 30.03.2013
ok can u explain me how to use sscanf
Re: params -
CBCandyBoy - 30.03.2013
ok but instead of that return 1 i want it to return a client message can i do that