SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 06/05/2015, 01:36 PM   #1
iWhite
Huge Clucker
 
Join Date: May 2012
Posts: 223
Reputation: 18
Default EnablePlayerCameraTarget

Hey guys.

I've wanted to ask you something about EnablePlayerCameraTarget function. In my server I use player's camera to point things and use them, like here:


I've been using GetPlayerCameraFrontVector and GetPlayerCameraPos to see if player is looking at objects or NPCs. Should I continue using it, or should I EnablePlayerCameraTarget and use GetPlayerCameraTarget?
iWhite is offline   Reply With Quote
Old 06/05/2015, 01:39 PM   #2
Konstantinos
Spam Machine
 
Konstantinos's Avatar
 
Join Date: Dec 2011
Posts: 11,981
Reputation: 1392
Default Re: EnablePlayerCameraTarget

You can use: https://wiki.sa-mp.com/wiki/GetPlayerCameraTargetObject
and I'm not sure if NPCs are targeted as "players": https://wiki.sa-mp.com/wiki/GetPlayerCameraTargetPlayer
If it does, a simply check (IsPlayerNPC) would be a good way to do this.
__________________
Life is like riding a bicycle. To keep your balance, you must keep moving.

[Tutorial] How to use SQLite
[FilterScript] Tune System
Konstantinos is offline   Reply With Quote
Old 06/05/2015, 01:42 PM   #3
iWhite
Huge Clucker
 
Join Date: May 2012
Posts: 223
Reputation: 18
Default Re: EnablePlayerCameraTarget

Quote:
Originally Posted by Konstantinos View Post
You can use: https://wiki.sa-mp.com/wiki/GetPlayerCameraTargetObject
and I'm not sure if NPCs are targeted as "players": https://wiki.sa-mp.com/wiki/GetPlayerCameraTargetPlayer
If it does, a simply check (IsPlayerNPC) would be a good way to do this.
I've replaced NPCs with Actors, so I can use GetPlayerCameraTargetActor, but I want to know if GetPlayerCameraTarget functions will improve performance using instead of GetPlayerCameraPos and Vector, because Wiki says, that EnablePlayerCameraTarget will use a lot of bandwidth.
iWhite is offline   Reply With Quote
Old 06/05/2015, 01:53 PM   #4
Konstantinos
Spam Machine
 
Konstantinos's Avatar
 
Join Date: Dec 2011
Posts: 11,981
Reputation: 1392
Default Re: EnablePlayerCameraTarget

Quote:
Originally Posted by Kalcor
The camera targeting functions added in 0.3.7-RC1 will be disabled by default as it may use bandwidth on servers when it's not needed.
that's a downside but as I'm not aware of the answer you're looking for (never used it), let's wait for another member to reply.
__________________
Life is like riding a bicycle. To keep your balance, you must keep moving.

[Tutorial] How to use SQLite
[FilterScript] Tune System
Konstantinos is offline   Reply With Quote
Old 06/05/2015, 02:28 PM   #5
MP2
Godfather
 
MP2's Avatar
 
Join Date: Jan 2011
Location: England
Posts: 6,416
Reputation: 973
Default Re: EnablePlayerCameraTarget

Enabling camera targeting will use more server networking bandwidth, but using PAWN functions will slow your server down. I'd go for bandwidth. Shouldn't matter unless you're on a 56 kb/s host..
MP2 is offline   Reply With Quote
Old 06/05/2015, 03:17 PM   #6
iWhite
Huge Clucker
 
Join Date: May 2012
Posts: 223
Reputation: 18
Default Re: EnablePlayerCameraTarget

Quote:
Originally Posted by MP2 View Post
Enabling camera targeting will use more server networking bandwidth, but using PAWN functions will slow your server down. I'd go for bandwidth. Shouldn't matter unless you're on a 56 kb/s host..
I'm planning to buy 80-100mbps server, is that ok?
iWhite is offline   Reply With Quote
Old 06/05/2015, 03:35 PM   #7
MP2
Godfather
 
MP2's Avatar
 
Join Date: Jan 2011
Location: England
Posts: 6,416
Reputation: 973
Default Re: EnablePlayerCameraTarget

I'm sure the difference would be minimal. However, Kye must have included the function to disable it to save bandwidth for a reason. I guess with hundreds of players it could have a small effect, but probably still not much.
MP2 is offline   Reply With Quote
Old 06/05/2015, 04:20 PM   #8
Pottus
Godfather
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 5,418
Reputation: 1240
Default Re: EnablePlayerCameraTarget

In a couple weeks you will be able to use ColAndreas to do this, it looks like to me that the function only checks against objects and not player objects obviously a system like this is going to require using the streamer. There are other options as well to check if you are looking at an object.

There is other decisions you need to make as well such has how you actually check for objects efficiently. What I would do is create a dynamic area for each object then use an iterator to store the areaids the player is in and the type of area in a variable. From there it is a matter of looping through your iterator to check if the player is looking at any one object(s).
Pottus is online now   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 10:12 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.