IsPlayerAiming on object? - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: IsPlayerAiming on object? (
/showthread.php?tid=192935)
IsPlayerAiming on object? -
DRCharlie - 24.11.2010
Hey guys I'd need some help with a filterscript I'm making, I want to detect if the character is actually looking on the object or not. I saw the IsPlayerAiming ,,script", and I just don't know how to edit it.
Код:
stock IsPlayerAiming(playerid, aimid)
{
new Float:X1, Float:Y1, Float:Z1, Float:X2, Float:Y2, Float:Z2;
GetPlayerPos(playerid, X1, Y1, Z1);
GetPlayerPos(aimid, X2, Y2, Z2);
new Float:Distance = floatsqroot(floatpower(floatabs(X1-X2), 2) + floatpower(floatabs(Y1-Y2), 2));
if(Distance < 100)
{
new Float:A;
GetPlayerFacingAngle(playerid, A);
X1 += (Distance * floatsin(-A, degrees));
Y1 += (Distance * floatcos(-A, degrees));
Distance = floatsqroot(floatpower(floatabs(X1-X2), 2) + floatpower(floatabs(Y1-Y2), 2));
if(Distance < 0.5)
{
return true;
}
}
return false;
}
Is it possible to change the aimid to any Object's id?
Re: IsPlayerAiming on object? -
Vandooz - 24.11.2010
Yes, but you need to change the GetPlayerPos(aimid... to GetObjectPos(aimid...
Make sure you do:
pawn Код:
new myobj;
myobj = CreateObject( etc );
Re: IsPlayerAiming on object? -
DRCharlie - 24.11.2010
Yeah, thanks already solved it