location problem - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: location problem (
/showthread.php?tid=417603)
location problem -
blackdragon1 - 21.02.2013
i added this stock.
PHP код:
stock GetPlayerDirectionFromPlayer(playerid,targetid)
{
new
Float:tpX,
Float:tpY,
Float:tpZ,
Float:tpX2,
Float:tpY2,
Float:tpZ2,
Float:pX,
Float:pY,
Float:pX2,
Float:pY2,
tDir[20];
GetPlayerPos(playerid,tpX,tpY,tpZ);
GetPlayerPos(targetid,tpX2,tpY2,tpZ2);
pX = floatround(tpX,floatround_round);
pY = floatround(tpY,floatround_round);
pX2 = floatround(tpX2,floatround_round);
pY2 = floatround(tpY2,floatround_round);
if((pX2 < pX) && (pY2 < pY))
tDir = "South West";
else if((pX2 > pX) && (pY2 > pY))
tDir = "North East";
else if((pX2 < pX) && (pY2 > pY))
tDir = "North West";
else if((pX2 > pX) && (pY2 < pY))
tDir = "South East";
else if((pX2 == pX) && (pY2 > pY))
tDir = "North";
else if((pX2 == pX) && (pY2 < pY))
tDir = "South";
else if((pY2 == pY) && (pX2 < pX))
tDir = "West";
else
tDir = "East";
return tDir;
}
PHP код:
CMD:loc(playerid, params[])
{
new targetid, id;
if(sscanf(params, "u", targetid)) return SendClientMessage(playerid,RED, "[USAGE]: /loc [name/id]");
if(!IsPlayerConnected(targetid)) SendClientMessage(playerid, RED, "Player not found.");
{
format(fstr, sizeof(fstr), "%s (%d) is currently located near %s (%s) Distance: %0.0f Metres", GetName(targetid), targetid, ReturnPlayerZone(ID), GetPlayerDirectionFromPlayer(playerid,targetid), GetDistanceBetweenPlayer(playerid,id));
SendClientMessage(playerid, YELLOW, fstr);
}
return true;
}
they just showing "East" idk what's wrng with south east north east north. help?
Re: location problem -
blackdragon1 - 22.02.2013
bump?