SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 18/06/2012, 04:59 PM   #1
MechaTech
Big Clucker
 
MechaTech's Avatar
 
Join Date: Feb 2012
Location: Netherlands
Posts: 172
Reputation: 6
Default Detect aim.

I want if je aim at an object it will give you money. I have this:
pawn Code:
stock IsPlayerAiming(playerid, aimid)
{
    new Float:X1, Float:Y1, Float:Z1, Float:X2, Float:Y2, Float:Z2;
    GetPlayerPos(playerid, X1, Y1, Z1);
    GetObjectPos(aimid, X2, Y2, Z2);
    new Float:Distance = floatsqroot(floatpower(floatabs(X1-X2), 2) + floatpower(floatabs(Y1-Y2), 2));
    if(Distance < 100)
    {
        new Float:A;
        GetPlayerFacingAngle(playerid, A);
        X1 += (Distance * floatsin(-A, degrees));
        Y1 += (Distance * floatcos(-A, degrees));
        Distance = floatsqroot(floatpower(floatabs(X1-X2), 2) + floatpower(floatabs(Y1-Y2), 2));
        if(Distance < 0.5)
        {
            return true;
        }
    }
    return false;
}

And if he is aiming:

pawn Code:
new myobj;
    myobj = CreateDynamicObject(2942, 2110.6797, -1791.0314, 14.3004,   0.00, 0.00, 0.00);

if(IsPlayerAiming(playerid, myobj))
    {
        GivePlayerMoney(playerid, 2000);
    }

But if i am at the object it doesnt give money.
__________________
Code:
Maps: Stunt World
FilterScripts: Advanced Weapon Shop
MechaTech is offline   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


Similar Threads
Thread Thread Starter Forum Replies Last Post
detect manchestera Scripting Help 1 21/10/2011 09:36 PM
Detect CJ Run? Antonio [G-RP] Help Archive 10 29/03/2011 08:53 AM
detect again willsuckformoney Help Archive 7 01/08/2010 07:27 AM
How to detect.. NewTorran Help Archive 2 07/06/2010 12:46 PM
How can i detect. NewTorran Help Archive 18 04/06/2010 02:48 PM


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


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