when pressing the key, he doesnt enters the vehicle, something different than the default
#1

hey everybody,

ok so my friend had an idea, a caddy, with the car wreck model, attached to it, so it would look cool xD, and it does looks cool now, i attached it to the caddy and its like a real car, so we attached some things to the bonnet and the roof, and a spoiler also, but now when i exit the vehicle, and wanna enter it again, i cant enter it, probably cuz the objects are in the way and that he doesnt wants to enter, so i thought, imma make something for that, but still it aint working, i made some debug msgs, but it only sends the first one when my friend tries it, not the second one, here is my code:

pawn Код:
if(newkeys & KEY_SECONDARY_ATTACK)
    {
        printf("pressed key");
        if(IsPlayerNearVehicle(playerid, GetVehicleModel(457), 10.0))
        {
            PutPlayerInVehicle(playerid, GetClosestVehicle(playerid, 5.0), 0);
            printf("entered");
        }
    }
pawn Код:
stock GetClosestVehicle(playerid, Float:range)
{
    new     Float:p_X;
    new     Float:p_Y;
    new     Float:p_Z;

    new     Float:Distance;
    new     Float:PretendentDistance = range +1;
    new     Pretendent;

    GetPlayerPos(playerid, p_X, p_Y, p_Z);

    for(new vehicleid=1; vehicleid < MAX_VEHICLES; vehicleid++)
    {
        Distance = GetVehicleDistanceFromPoint(vehicleid, p_X, p_Y, p_Z);

        if(Distance <= range && Distance <= PretendentDistance)
        {
            Pretendent = vehicleid;
            PretendentDistance = Distance;
        }
    }

    return Pretendent;
}
stock IsPlayerNearVehicle(playerid, vehicleid, Float:range)
{
    new Float:X, Float:Y, Float:Z;
    GetVehiclePos(vehicleid, X, Y, Z);
    if(IsPlayerInRangeOfPoint(playerid, range, X, Y, Z))return true;
    else return false;
}
can anybody tell me wuts wrong with this? i tried many things but none worked, as i said the message "pressed key" does gets send, so that works, but the message of "entered" doesnt gets send... meaning something isnt right there, but i cant see wut is wrong, can anybody tell me wuts wrong with this?

greets niels
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)