[HELP] looking at a vehicle!
#1

I wanted to do that if a player is looking at a vehicle and press "ENTER" to enter the vehicle (not if it is close, but if you are watching the vehicle.). Is this possible? Thanks in advance.

Translated with ****** Translate.
Reply
#2

Up з_з
Reply
#3

Worst translation i have ever seen in my life.
Reply
#4

Quote:
Originally Posted by Coole[AG
]
Worst translation i have ever seen in my life.
Why?
Even though It's not the clearer,you can still understand what he asks for.
He asks for a system that will allow you getting into a vehicle from any distance,only by aiming at it and pressing enter.
Reply
#5

Like..

Код:
public GetClosestPlayer(p1)
{
	new
		x,
		Float:dis,
		Float:dis2,
		player;

	player = -1;
	dis = 99999.99;

	for (x=0;x<MAX_PLAYERS;x++)
		if(IsPlayerConnected(x))
			if(x != p1)
			{
				dis2 = GetDistanceBetweenPlayers(x,p1);
				if(dis2 < dis && dis2 != -1.00)
				{
					dis = dis2;
					player = x;
				}
			}

	return player;
}
for cars?
Reply
#6

You could have used GetPlayerFacingAngle but then it would not detect if a car is in the view. So only thing possible afaik is to use IsPlayerInRangeOfPoint.
Reply
#7

Quote:
Originally Posted by DJDhan
You could have used GetPlayerFacingAngle but then it would not detect if a car is in the view. So only thing possible afaik is to use IsPlayerInRangeOfPoint.
I think you should also use GetPlayerCameraFrontVector.
Reply
#8

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;
}
Reply
#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


Forum Jump:


Users browsing this thread: 1 Guest(s)