[Pawn] Checking aiming data real-time - Printable Version + open.mp forum (https://forum.open.mp) -- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3) --- Forum: Pawn Scripting (https://forum.open.mp/forumdisplay.php?fid=10) --- Thread: [Pawn] Checking aiming data real-time (/showthread.php?tid=1437) |
Checking aiming data real-time - c4p - 2020-12-20 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? RE: Checking aiming data real-time - Eloctro - 2020-12-20 Code: new actorid = GetPlayerTargetActor(playerid); RE: Checking aiming data real-time - Markski - 2020-12-20 (2020-12-20, 08:05 PM)Eloctro Wrote: 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. RE: Checking aiming data real-time - c4p - 2020-12-24 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) RE: Checking aiming data real-time - Pinch - 2020-12-24 ID_AIM_SYNC - ID: 203 EDIT: Packet ID, try with raknet. RE: Checking aiming data real-time - c4p - 2020-12-25 (2020-12-24, 10:23 PM)Pinch Wrote: ID_AIM_SYNC - ID: 203Sorry 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. RE: Checking aiming data real-time - Pinch - 2020-12-25 Pawn.RakNet plugin, incoming packet, ID 203 RE: Checking aiming data real-time - c4p - 2020-12-25 (2020-12-25, 04:27 PM)Pinch Wrote: Pawn.RakNet plugin, incoming packet, ID 203Thanks, 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. |