So in my case, what would the size of the array be? 2?
Later edit:
Let's say I have the following command:
pawn Код:
COMMAND:goto(playerid, params[])
{
if(IsPlayerConnected(playerid))
{
new plo, string[150];
if (sscanf(params, "r", plo))
{
SendClientMessage(playerid, COLOR_GRAD2, "Usage: /goto <player>");
return 1;
}
new Float:plocx,Float:plocy,Float:plocz;
if (IsPlayerConnected(plo))
{
if(plo != INVALID_PLAYER_ID)
{
if (PlayerInfo[playerid][pAdmin] >= 1)
{
GetPlayerPos(plo, plocx, plocy, plocz);
SetPlayerInterior(playerid, GetPlayerInterior(plo));
SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(plo));
SetPlayerPos(playerid, plocx, plocy, plocz);
}
else
{
SendClientMessage(playerid, -1, "You're not an admin!");
}
}
}
else
{
SendClientMessage(playerid, -1, "That's player is NOT connected!");
}
}
return 1;
}
In order to convert it for partial name matches, should I replace plo (like in here: "GetPlayerPos(plo, plocx, plocy, plocz);") with plo[0]?
Update:
I've done this:
pawn Код:
COMMAND:goto(playerid, params[])
{
if(IsPlayerConnected(playerid))
{
new plo[2], string[150];
if (sscanf(params, "r[2]", plo))
{
SendClientMessage(playerid, COLOR_GRAD2, "Usage: /goto <player>");
return 1;
}
if(!CheckMultipleNames(playerid, plo)) return 1;
new Float:plocx,Float:plocy,Float:plocz;
if (IsPlayerConnected(plo[0]))
{
if(plo[0] != INVALID_PLAYER_ID)
{
if (PlayerInfo[playerid][pAdmin] >= 1)
{
GetPlayerPos(plo[0], plocx, plocy, plocz);
SetPlayerInterior(playerid, GetPlayerInterior(plo[0]));
SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(plo[0]));
SetPlayerPos(playerid, plocx, plocy, plocz);
}
else
{
SendClientMessage(playerid, -1, "You're not an admin!");
}
}
}
else
{
SendClientMessage(playerid, -1, "That's player is NOT connected!");
}
}
return 1;
// where:
CheckMultipleNames(playerid, array[])
{
new strfound[180], yesno, foundplayer, name[MAX_PLAYER_NAME];
for(new i = 0; array[i] != INVALID_PLAYER_ID; i++)
{
GetPlayerName(array[i], name, sizeof(name));
if (array[i] == cellmin)
{
if(yesno == 0)
{
SendClientMessage(playerid, COLOR_LIGHTRED, "(!) Multiple players have been found matching that name. Use one of the IDs:");
format(strfound, sizeof(strfound), "%d. %s [ID %d]", yesno+1, GetPlayerNameEx(foundplayer), foundplayer);
SendClientMessage(playerid, COLOR_LIGHTRED, strfound);
}
yesno ++;
format(strfound, sizeof(strfound), "%d. %s [ID %d]", yesno+1, name, array[i]);
SendClientMessage(playerid, COLOR_LIGHTRED, strfound);
}
foundplayer = array[i];
}
if(yesno > 0) return 0;
return 1;
}
The output is this:
pawn Код:
(!) Multiple players have been found matching that name. Use one of the IDs:
1. [TAG]Potato (ID 1) // first name, displayed correctly
2. [TAG]Potato (ID --) // ID '--', i don't know why, and it displays the same name as the first player (i don't know why) - the second player should be just 'Potato'
SERVER: Unknown command.
What's wrong?