Your command using strcmp.
pawn Код:
if(strcmp(cmd, "/gotoid", true) == 0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /gotoid [Playerid/PartOfName]");
return 1;
}
new Float:plocx,Float:plocy,Float:plocz;
new plo;
plo = ReturnUser(tmp);
if (IsPlayerConnected(plo))
{
if(plo != INVALID_PLAYER_ID)
{
if (PlayerInfo[playerid][pAdmin] >= 1) // Edit this line according to your admin variable
{
GetPlayerPos(plo, plocx, plocy, plocz);
SetPlayerInterior(playerid, GetPlayerInterior(plo));
SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(plo));
if (GetPlayerState(playerid) == 2)
{
new tmpcar = GetPlayerVehicleID(playerid);
SetVehiclePos(tmpcar, plocx, plocy+4, plocz);
TelePos[playerid][0] = 0.0;TelePos[playerid][1] = 0.0;
}
else
{
SetPlayerPos(playerid,plocx,plocy+2, plocz);
}
SendClientMessage(playerid, COLOR_GRAD1, " You have been teleported");
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, "You are not authorised to use that command.");
}
}
}
else
{
format(string, sizeof(string), " %d is not an active player.", plo);
SendClientMessage(playerid, COLOR_GRAD1, string);
}
}
return 1;
}
Your command using ZCMD with Sscanf.
pawn Код:
COMMAND:gotoid(playerid, params[])
{
if(IsPlayerConnected(playerid))
{
new plo;
if(sscanf(params, "u",plo)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /goto [Playerid/PartOfName]");
new Float:plocx,Float:plocy,Float:plocz;
if (IsPlayerConnected(plo))
{
if(plo != INVALID_PLAYER_ID)
{
if (PlayerInfo[playerid][pAdmin] >= 1) // Edit this line according to your admin variable
{
GetPlayerPos(plo, plocx, plocy, plocz);
SetPlayerInterior(playerid, GetPlayerInterior(plo));
SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(plo));
if (GetPlayerState(playerid) == 2)
{
new tmpcar = GetPlayerVehicleID(playerid);
SetVehiclePos(tmpcar, plocx, plocy+4, plocz);
TelePos[playerid][0] = 0.0;TelePos[playerid][1] = 0.0;
}
else
{
SetPlayerPos(playerid,plocx,plocy+2, plocz);
}
SendClientMessage(playerid, COLOR_GRAD1, " You have been teleported");
}
else return SendClientMessage(playerid, COLOR_GRAD1, "You are not authorised to use that command.");
}
}
else return SendClientMessage(playerid, COLOR_GRAD1, "[CW:WW3] That is not an active player");
}
return 1;
}