if(sscanf(params, "u", targetid)) -
AnonScripter - 21.12.2013
How to make /locate command also works without typing the playerid that i want to locate.
example:
/locate 4 --> Player 4 location is %s
/locate (without ID) --> your location is %s
so how to make it work for me also ?
pawn Код:
CMD:locate(playerid,params[])
{
new string[128], targetid;
if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_WHITE, "/locate [playerid]");
format(string,sizeof(string),"his location is %s", GetPlayerZone(targetid));
SendClientMessage(playerid,COLOR_WHITE,string);
return 1;
}
Re: if(sscanf(params, "u", targetid)) -
kristo - 21.12.2013
pawn Код:
CMD:locate(playerid,params[])
{
new string[128], targetid;
if(sscanf(params, "u", targetid)) format(string,sizeof(string),"your location is %s", GetPlayerZone(playerid));
else format(string,sizeof(string),"his location is %s", GetPlayerZone(targetid));
SendClientMessage(playerid,COLOR_WHITE,string);
return 1;
}
Re: if(sscanf(params, "u", targetid)) -
Jstylezzz - 21.12.2013
pawn Код:
CMD:locate(playerid,params[])
{
new string[128], targetid;
if(sscanf(params, "u", targetid))
{
format(string,sizeof(string),"You location is %s", GetPlayerZone(playerid));
SendClientMessage(playerid,COLOR_WHITE,string);
return 1;
}
format(string,sizeof(string),"Targets location is %s", GetPlayerZone(targetid));
SendClientMessage(playerid,COLOR_WHITE,string);
return 1;
}
Simple as this. Instead of sending a message with the usage, you just show your own location.
Re: if(sscanf(params, "u", targetid)) -
AnonScripter - 21.12.2013
lol i'm really stupid, i didn't think of that :D
that's really easy haha
Re: if(sscanf(params, "u", targetid)) -
Pottus - 21.12.2013
You didn't check if the targetid is connected.
Re: if(sscanf(params, "u", targetid)) -
Brandon_More - 21.12.2013
pawn Код:
CMD:locate(playerid,params[])
{
new string[128], targetid;
if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_WHITE, "[playerid]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_WHITE,"Player is not connected");
format(string,sizeof(string),"Targets location is %s", GetPlayerZone(targetid));
SendClientMessage(playerid,COLOR_WHITE,string);
return 1;
}
Re: if(sscanf(params, "u", targetid)) -
Konstantinos - 21.12.2013
pawn Код:
CMD:locate(playerid, params[])
{
if (isnull(params))
{
new
string[64];
format(string, sizeof (string),"Your location is %s", GetPlayerZone(playerid));
SendClientMessage(playerid, COLOR_WHITE, string);
}
else
{
new
targetid;
if (!sscanf(params, "u", targetid))
{
if (targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_WHITE, "Invalid player");
new
string[64];
format(string, sizeof (string), "Target's location is %s", GetPlayerZone(targetid));
SendClientMessage(playerid, COLOR_WHITE, string);
}
}
return 1;
}