Burgershot
  • Home
  • Members
  • Team
  • Help
  • Search
  • Register
  • Login
  • Home
  • Members
  • Help
  • Search
Burgershot SA-MP Pawn Scripting [Pawn] Checking aiming data real-time

 
  • 0 Vote(s) - 0 Average
Pawn Checking aiming data real-time
c4p
Offline

Burgershot Member
Posts: 7
Threads: 3
Joined: Dec 2020
Reputation: 0
#1
2020-12-20, 06:11 PM
I am working on a right-clickable NPC system. Currently I am checking if the player is aiming on the npc under onplayerupdate.
This solution is not the best, because you should move in order to open the npc's menu. Any way to instantly detect aiming? Is there a callback for aim detection?
Eloctro
Offline

Burgershot Member
Posts: 3
Threads: 0
Joined: Dec 2020
Reputation: 0
Location: France
#2
2020-12-20, 08:05 PM (This post was last modified: 2020-12-20, 08:05 PM by Eloctro.)
Code:
new actorid = GetPlayerTargetActor(playerid);
Markski
Offline

Burgershot Clerk

Posts: 127
Threads: 6
Joined: Apr 2019
Reputation: 5
Location: La Plata, Argentina
#3
2020-12-20, 10:18 PM (This post was last modified: 2020-12-20, 10:18 PM by Markski.)
(2020-12-20, 08:05 PM)Eloctro Wrote:
Code:
new actorid = GetPlayerTargetActor(playerid);


More or less. NPC's are considered players by the server.

In order to get the ID of the NPC a player is aiming to, use GetPlayerTargetPlayer(playerid);


Furthermore, in order for either of these two functions to work, you'll have to enable the following inside OnPlayerConnect:

Code:
EnablePlayerCameraTarget(playerid, 1);

This is disabled by default to save bandwidth, but isn't really a problem in the last decade.
Website
c4p
Offline

Burgershot Member
Posts: 7
Threads: 3
Joined: Dec 2020
Reputation: 0
#4
2020-12-24, 07:02 PM
You guys misunderstood me. I am looking for a callback which is called when a player aims. The function is done, but using it under onplayerupdate may not be instant when the player is not moving.
So i am looking for something like this:

public OnPlayerAim(playerid)
{
return 1;
}

OnPlayerUpdate dependent callbacks are not an option.(emmet's new samp callbacks, etc)
Pinch
Offline

Burgershot Member
Posts: 391
Threads: 19
Joined: Apr 2019
Reputation: 22
Location: Belgrade, Serbia
#5
2020-12-24, 10:23 PM (This post was last modified: 2020-12-24, 10:24 PM by Pinch.)
ID_AIM_SYNC - ID: 203

EDIT: Packet ID, try with raknet.
Using Pawn.CMD?
If you're doing so, this is the very first sign that you absolutely shouldn't utilize your all powerful P-Code knowledge in any of the scripting discussion topics.
c4p
Offline

Burgershot Member
Posts: 7
Threads: 3
Joined: Dec 2020
Reputation: 0
#6
2020-12-25, 02:58 PM (This post was last modified: 2020-12-25, 02:59 PM by c4p.)
(2020-12-24, 10:23 PM)Pinch Wrote: ID_AIM_SYNC - ID: 203

EDIT: Packet ID, try with raknet.
Sorry for my stupid question, but what callback or function is that related to? I am a little bit confused.


For anyone else who might wanna help:
I am looking for a callback which gets called when a player is aiming, so i can instantly check if he is aiming on the npc and if he is, i can run the wanted function.
The problem with OnPlayerUpdate is if the player is moving and right clicking the npc, it instantly runs the function, but when the player is not moving, onplayerupdate doesn't get called so the aiming isn't checked and the function doesn't get called.
So I am looking for a callback where i can instantly check if the player is aiming on the npc, without the player having to move.

I prefer not to use small timers because they might not be "instant"(you have to keep right click pressed for some time) or cause lag(it's not a really good idea to run 20-50ms timers on a lot of players)

I hope this is possible in pawn, never managed to do anything like this before, but MTA is getting advantage over samp and i have to implement functions which replaces commands and gives the players more options.
Pinch
Offline

Burgershot Member
Posts: 391
Threads: 19
Joined: Apr 2019
Reputation: 22
Location: Belgrade, Serbia
#7
2020-12-25, 04:27 PM (This post was last modified: 2020-12-25, 04:27 PM by Pinch.)
Pawn.RakNet plugin, incoming packet, ID 203
Using Pawn.CMD?
If you're doing so, this is the very first sign that you absolutely shouldn't utilize your all powerful P-Code knowledge in any of the scripting discussion topics.
c4p
Offline

Burgershot Member
Posts: 7
Threads: 3
Joined: Dec 2020
Reputation: 0
#8
2020-12-25, 04:34 PM (This post was last modified: 2020-12-25, 05:05 PM by c4p.)
(2020-12-25, 04:27 PM)Pinch Wrote: Pawn.RakNet plugin, incoming packet, ID 203
Thanks, i'm gonna give it a look today or tomorrow and find out if it works well.

EDIT: Tried it, it works. Sometimes it has a small delay(around max. 750ms) but if you move the mouse or move the character it works instantly. Thanks for the help, if i find out any ways to make it faster, i'm gonna post it here.

ps. the delay might appear just because of localhost's lag.
« Next Oldest | Next Newest »



  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Burgershot - Powered by our Community and MyBB Original Theme by Emerald

Linear Mode
Threaded Mode