[Include] "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle.
#1

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.
Reply


Messages In This Thread
"OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - by iPLEOMAX - 12.01.2012, 16:47
Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - by T0pAz - 12.01.2012, 16:51
Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - by TheArcher - 12.01.2012, 16:58
Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - by iPLEOMAX - 12.01.2012, 17:01
Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - by Hoss - 12.01.2012, 17:08
Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - by System64 - 12.01.2012, 17:22
Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - by TheArcher - 12.01.2012, 17:34
Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - by Voldemort - 12.01.2012, 17:54
Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - by iPLEOMAX - 13.01.2012, 10:23
Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - by kizla - 13.01.2012, 11:12
Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - by yos136 - 13.01.2012, 11:24
Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - by iPLEOMAX - 13.01.2012, 11:55
Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - by yos136 - 13.01.2012, 12:02
Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - by iPLEOMAX - 13.01.2012, 12:09
Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - by iPLEOMAX - 13.01.2012, 12:24
Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - by T0pAz - 13.01.2012, 12:31
Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - by Haydz - 13.01.2012, 13:24
Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - by Unknownich - 13.01.2012, 13:42
Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - by Snowman12 - 13.01.2012, 13:44
Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - by Sinner - 13.01.2012, 14:21
Respuesta: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - by nacho_gb1 - 13.01.2012, 14:51
Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - by skaTim - 13.01.2012, 14:55
Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - by iZN - 13.01.2012, 15:03
Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - by Michael@Belgium - 13.01.2012, 15:19
Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - by Kaperstone - 13.01.2012, 15:25
Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - by iPLEOMAX - 13.01.2012, 15:27
Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - by [DOG]irinel1996 - 13.01.2012, 18:15
Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - by Kaperstone - 13.01.2012, 19:37
Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - by TheArcher - 13.01.2012, 20:02
Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - by iPLEOMAX - 13.01.2012, 20:04
Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - by juraska - 14.01.2012, 13:26
Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - by THE_KING$5$ - 14.01.2012, 17:49
Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - by iPLEOMAX - 14.01.2012, 20:40
Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - by iPLEOMAX - 14.01.2012, 20:46
Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - by Kar - 14.01.2012, 23:19
Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - by TheArcher - 15.01.2012, 15:34
Re: "OnPlayerLookAtVehicle" - Detect if a player is looking at some vehicle. - by iPLEOMAX - 28.01.2012, 18:09

Forum Jump:


Users browsing this thread: 2 Guest(s)