CMD:getid(playerid, params[])
{
new id;
if(sscanf(params, "u", id)) return SendClientMessage(playerid, "USAGE: /getid <part of name>");
//The u parameter is playerid / part of name
format(str, sizeof(str), "ID: %d is %s", id, Name(id)); //the name of the player..I used my stock here
SendClientMessage(playerid, -1, str);
return 1;
}
CMD:getid( playerid, params[ ] )
{
new found, string[128], playername[MAX_PLAYER_NAME];
if(isnull(params)) return SendClientMessage(playerid, -1, "Usage: /getid [PartOfName] ");
format(string,sizeof(string),"Searched for: \"%s\"",params);
SendClientMessage(playerid, -1,string);
for(new i=0; i <= MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
GetPlayerName(i, playername, MAX_PLAYER_NAME);
new namelen = strlen(playername);
new bool:searched=false;
for(new pos=0; pos <= namelen; pos++)
{
if(searched != true)
{
if(strfind(playername,params,true) == pos)
{
found++;
format(string,sizeof(string),"%d. %s (ID: %d)",found,playername,i);
SendClientMessage(playerid, -1 ,string);
searched = true;
}
}
}
}
}
if(found == 0)
SendClientMessage(playerid, -1, "No Players Localized!");
return 1;
}
\"%s\
Why these are used? ( \ \ )? And also i have a GetName(playerid) stock so please convert it to that. |
CMD:getid( playerid, params[ ] )
{
new found, string[128];
if(isnull(params)) return SendClientMessage(playerid, -1, "Usage: /getid [PartOfName] ");
format(string,sizeof(string),"Searched for: %s",params);
SendClientMessage(playerid, -1,string);
for(new i=0; i <= MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
new namelen = strlen(GetName(i));
new bool:searched=false;
for(new pos=0; pos <= namelen; pos++)
{
if(searched != true)
{
if(strfind(GetName(i),params,true) == pos)
{
found++;
format(string,sizeof(string),"%d. %s (ID: %d)",found,GetName(i),i);
SendClientMessage(playerid, -1 ,string);
searched = true;
}
}
}
}
}
if(found == 0)
SendClientMessage(playerid, -1, "No Players Localized!");
return 1;
}
We cannot write simple as %s?
And whats Bool? And can you convert GetPlayerName to GetName(playerid) cause i have a stock for it. |
CMD:getid( playerid, params[ ] )
{
new found, string[128];
if(isnull(params)) return SendClientMessage(playerid, -1, "Usage: /getid [PartOfName] ");
format(string,sizeof(string),"Searched for: %s",params);
SendClientMessage(playerid, -1,string);
for(new i=0; i <= MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
new namelen = strlen(GetName(i));
new bool:searched=false;
for(new pos=0; pos <= namelen; pos++)
{
if(searched != true)
{
if(strfind(GetName(i),params,true) == pos)
{
found++;
format(string,sizeof(string),"%d. %s (ID: %d)",found,GetName(i),i);
SendClientMessage(playerid, -1 ,string);
searched = true;
}
}
}
}
}
if(found == 0)
SendClientMessage(playerid, -1, "No Players Localized!");
return 1;
}