[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
#2

I was in need of this. Thanks!
Reply
#3

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

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

WoW
Good job pleo!
Reply
#6

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

Next time use y_hooks and foreach
Reply
#7

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

Sounds usefull and interesting, great job



btw, your siggi: New Funtions! , small mistake
Reply
#9

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).
Reply
#10

Awesome script, i love it
Reply
#11

its laggy what you did...
Reply
#12

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

What? i just sayed its laggy..
Reply
#14

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

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

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.

....
Reply
#17

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

I will try it, nice idea

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

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
Reply
#20

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


Forum Jump:


Users browsing this thread: 4 Guest(s)