Unrelated to your sscanf problem:
You're checking if the ID is connected before you know what the ID even is. This will render your IsPlayerConnected checks pointless.
pawn Код:
CMD:loc(playerid, params[])
{
new id;
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xFF0000FF, "ERROR: Player not connected");
if(sscanf(params, "u", id))
{
SendClientMessage(playerid, 0xFF0000FF, "Usage: /loc [playerid]");
}
else
{
new zone[MAX_ZONE_NAME];
GetPlayer2DZone(id, zone, MAX_ZONE_NAME);
new playername[MAX_PLAYER_NAME],message2[170];
GetPlayerName(id,playername,MAX_PLAYER_NAME);
format(message2,sizeof(message2),"%s(%d)'s current location: %s",playername,id,zone);
SendClientMessage(playerid,0x00C7FFAA,message2);
}
return true;
}
Specifically here:
pawn Код:
new id;
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xFF0000FF, "ERROR: Player not connected");
if(sscanf(params, "u", id))
When you create an integer variable, the default value is zero (0). When you use the 'u' parameter in sscanf, it returns an ID of a player or INVALID_PLAYER_ID. What you're doing is checking if the player is connected before sscanf has a chance to tell you what the ID is.
Your IsPlayerConnected check should be after sscanf.
pawn Код:
CMD:loc(playerid, params[])
{
new id;
if(sscanf(params, "u", id))
{
SendClientMessage(playerid, 0xFF0000FF, "Usage: /loc [playerid]");
}
else
{
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xFF0000FF, "ERROR: Player not connected");
new zone[MAX_ZONE_NAME];
GetPlayer2DZone(id, zone, MAX_ZONE_NAME);
new playername[MAX_PLAYER_NAME],message2[128];
GetPlayerName(id,playername,MAX_PLAYER_NAME);
format(message2,sizeof(message2),"%s(%d)'s current location: %s",playername,id,zone);
SendClientMessage(playerid,0x00C7FFAA,message2);
}
return true;
}
This should fix a problem with your command, but as for the sscanf warning problem, I'm not entirely sure.
Also, chat message strings are only ever 128 characters, not 170.