[HELP] looking at a vehicle!
#9

Quote:
Originally Posted by MadeMan
pawn Код:
stock Float:DistanceCameraTargetToLocation(playerid, Float:ObjX, Float:ObjY, Float:ObjZ)
{
    new Float:CamX, Float:CamY, Float:CamZ;
    GetPlayerCameraPos(playerid, CamX, CamY, CamZ);

    new Float:TGTDistance;
    TGTDistance = floatsqroot((CamX - ObjX) * (CamX - ObjX) + (CamY - ObjY) * (CamY - ObjY) + (CamZ - ObjZ) * (CamZ - ObjZ));

    new Float:FrX, Float:FrY, Float:FrZ;
    GetPlayerCameraFrontVector(playerid, FrX, FrY, FrZ);

    new Float:tmpX, Float:tmpY, Float:tmpZ;
    tmpX = FrX * TGTDistance + CamX;
    tmpY = FrY * TGTDistance + CamY;
    tmpZ = FrZ * TGTDistance + CamZ;

    return floatsqroot((tmpX - ObjX) * (tmpX - ObjX) + (tmpY - ObjY) * (tmpY - ObjY) + (tmpZ - ObjZ) * (tmpZ - ObjZ));
}
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
    {
        if(newkeys & KEY_SECONDARY_ATTACK)
        {
            new Float:pos[3];
            for(new v=1; v < MAX_VEHICLES; v++)
            {
                if(GetVehiclePos(v, pos[0], pos[1], pos[2]))
                {
                    if(DistanceCameraTargetToLocation(playerid, pos[0], pos[1], pos[2]) < 5.0)
                    {
                        PutPlayerInVehicle(playerid, v, 0);
                        return 1;
                    }
                }
            }
        }
    }
    return 1;
}
Erm..that's what i was going to say
Reply


Messages In This Thread
[HELP] looking at a vehicle! - by raever - 30.05.2010, 16:05
Re: [HELP] looking at a vehicle! - by raever - 30.05.2010, 18:35
Re: [HELP] looking at a vehicle! - by coole210 - 30.05.2010, 18:50
Re: [HELP] looking at a vehicle! - by [XST]O_x - 30.05.2010, 18:53
Re: [HELP] looking at a vehicle! - by coole210 - 30.05.2010, 18:55
Re: [HELP] looking at a vehicle! - by DJDhan - 30.05.2010, 18:56
Re: [HELP] looking at a vehicle! - by [XST]O_x - 30.05.2010, 18:57
Re: [HELP] looking at a vehicle! - by MadeMan - 30.05.2010, 19:44
Re: [HELP] looking at a vehicle! - by [XST]O_x - 30.05.2010, 19:48

Forum Jump:


Users browsing this thread: 3 Guest(s)