Object Question
#1

Hello,

Is there a way to detect if the player is aiming at an object? I've seen things like onplayeraimatplayer or onplayershootplayer but is there a onplayeraimatobject or shootatobject? Thanks
Reply
#2

I don't think it's possible, maybe there is - search & ****** is your friend.
Reply
#3

It wouldn't be difficult to make, depending on how you would like to do it. Just think about it logically.

Here is the basic IsPlayerAimingAtPlayer function.

Код:
stock IsPlayerAimingAtPlayer(playerid, targetid)
{
    new Float:x, Float:y, Float:z;
    GetPlayerPos(targetid, x, y, z);
    if (IsPlayerAimingAt(playerid, x, y, z-0.75, 0.25)) return true;
    if (IsPlayerAimingAt(playerid, x, y, z-0.25, 0.25)) return true;
    if (IsPlayerAimingAt(playerid, x, y, z+0.25, 0.25)) return true;
    if (IsPlayerAimingAt(playerid, x, y, z+0.75, 0.25)) return true;
    return false;
}
As you can see, all you would need to change is the position (the GetPlayerPos). You would need some kind of dynamic object system if you wanted to detect if a player is aiming at any object or multiple different objects of the same ID, but if it's just one scenario just set the x, y, and z to the appropriate coordinates.

Of course you would need to do some more editing then JUST that, but for the most part it's as simple as that. It really depends on the scenario you are talking about.
Reply
#4

Yeah I understand what you mean im thinking of a fire system aspect where the fire object would automatically start a timer once the player begins aiming at it and removes it self after a couple of seconds... Would need to work on it a bit.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)