SA-MP Forums Archive
[Include] "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - 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: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. (/showthread.php?tid=310502)

Pages: 1 2


"OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - iPLEOMAX - 12.01.2012

OnPlayerLookAtVehicle V2*

Info:
Detects if a player is looking at any vehicle and executes a callback on any change.

How it works:
Uses Camera Vector, Position, Streamed Vehicles & your distance between the vehicle to calculate, etc..

Callback & Natives:
pawn Код:
//To Enable this for a player. (If you forget to do this, it won't work!)
EnableVehicleLookAt(playerid);

//The following Callback is called when a player has his camera's point of view towards a vehicle.
public OnPlayerLookAtVehicle(playerid, vehicleid, Float:distance)
{
    new message[128];
    format(message, sizeof message,
    "You are looking at vehicle id %i with a distance of %f meters.", vehicleid, distance);
    SendClientMessage(playerid, -1, message);
    return true;
}

//To disable the lookat system for a player. (Good thing to put it under OnPlayerDisconnect)
DisableVehicleLookAt(playerid);
Are you looking for IsPlayerLookingAt(vehicle ... object ... player) ?
http://forum.sa-mp.com/showpost.php?...postcount=2946

What can I do with it?
Few ideas:
- Make a showroom featuring TDU2's style. (I have done one)
Don't get it? I mean, if you point at any vehicle, it shows up it's name, price, top speed etc with textdraws. (It's cool TBH).

-Making other such thingies

Video Demonstration:
[ame]http://www.youtube.com/watch?v=LOYfW008PNU[/ame]

Download:
LATEST (V2.0)
"OPLAV.inc" V2 raw - Pastebin
OPLAV.V2.pleomax.rar - MediaFire
Requirement: You need YSI Server Includes to make this work!

OLD:
"vla.inc" raw - Pastebin
VLA Include (RAR) - MediaFire
Changelogs:
Код:
Version 1.0:
- Initial Release.

Version 2.0:
- Optimized the code hence increased performance/efficiency.
- Now uses a collection of player's streamed vehicles to check for the 'lookat'. (Thanks to "Kar" for the idea ;))
- Removed "oldvehicle" parameter from the callback since it's useless.
- Added Float:distance parameter to the callback.
- Uses y_hook to hook with the default callbacks.



Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - T0pAz - 12.01.2012

I was in need of this. Thanks!


Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - TheArcher - 12.01.2012

I took a look at the code, and seems good scripted and faster. It's very useful though but i didn't understand what EnableVehicleLookAt(playerid); function is used for. Yes for enable/disable the function for a player but why? Good job tough.


Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - iPLEOMAX - 12.01.2012

Quote:
Originally Posted by T0pAz
Посмотреть сообщение
I was in need of this. Thanks!
Glad it helped you.

Quote:
Originally Posted by TheArcher
Посмотреть сообщение
I took a look at the code, and seems good scripted and faster. It's very useful though but i didn't understand what EnableVehicleLookAt(playerid); function is used for. Yes for enable/disable the function for a player but why? Good job tough.
Nothing much actually.. I thought adding these functions would be better because sometimes you don't wanna run this system on each player all the time.. Too much for nothing.

Upto you guys, like Enable on Connect & done! It'll stay active all the time.


Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - Hoss - 12.01.2012

WoW
Good job pleo!



Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - System64 - 12.01.2012

wow this is awesome job, such a good idea and script

Next time use y_hooks and foreach


Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - TheArcher - 12.01.2012

Quote:
Originally Posted by System64
Посмотреть сообщение
wow this is awesome job, such a good idea and script

Next time use y_hooks and foreach
This include is fine how is it right now. It ingrease the speed with those add-ons. Anyways he can hook manualy.


Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - Voldemort - 12.01.2012

Sounds usefull and interesting, great job



btw, your siggi: New Funtions! , small mistake


Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - iPLEOMAX - 13.01.2012

Quote:
Originally Posted by Hoss
Посмотреть сообщение
WoW
Good job pleo!
Quote:
Originally Posted by Voldemort
Посмотреть сообщение
Sounds usefull and interesting, great job
btw, your siggi: New Funtions! , small mistake
Thanks guys.
@Voldemort: Edited xD

Quote:
Originally Posted by System64
Посмотреть сообщение
wow this is awesome job, such a good idea and script

Next time use y_hooks and foreach
Thanks & Alright, I'll post a foreach+y_hooks version too just in case (But I guess 'foreach' wouldn't make much difference here though).


Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - kizla - 13.01.2012

Awesome script, i love it


Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - yos136 - 13.01.2012

its laggy what you did...


Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - iPLEOMAX - 13.01.2012

Quote:
Originally Posted by yos136
Посмотреть сообщение
its laggy what you did...
There's no other way you could do it. (Atleast in my head)

To get the vehicle on a player's sight, you WILL NEED these positions/calculations and a timer.


Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - yos136 - 13.01.2012

What? i just sayed its laggy..


Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - iPLEOMAX - 13.01.2012

Quote:
Originally Posted by yos136
Посмотреть сообщение
What? i just sayed its laggy..
You said: "its laggy what you did..."

Do you or anyone else have a better method? I'm not being angry, I'm just asking so it would be good for everyone else if you had one..


Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - iPLEOMAX - 13.01.2012

Quote:
Originally Posted by Kepler
Посмотреть сообщение
ya it's very laggy. wups or ****** can do better.
Well ofcourse they can. I hope one of them does.


Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - T0pAz - 13.01.2012

Quote:

its laggy what you did...

Quote:

What? i just sayed its laggy..

Quote:

ya it's very laggy. wups or ****** can do better.





Quote:

To get the vehicle on a player's sight, you WILL NEED these positions/calculations and a timer.

....


Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - Haydz - 13.01.2012

Wow, that's actually a pretty awesome idea. You've done an awesome job, looking forward to more scripts in the future.


Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - Unknownich - 13.01.2012

I will try it, nice idea

[ame]http://www.youtube.com/watch?v=EF8GhC-T_Mo[/ame]


Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - Snowman12 - 13.01.2012

Nice looks like you directed it more at RP servers. Would be nice to see some other things like perhaps OnPlayerShootVehicle I need a call back like this for health hack detection :P


Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - Sinner - 13.01.2012

Quote:
Originally Posted by Kepler
Посмотреть сообщение
ya it's very laggy. wups or ****** can do better.
You're an asshole.