Help needed
#1

How can i add a Trunk open and Bonnet hood

Like the front part and back one

OnPLayerKeyState "Y" opens the trunk and "N" opens honnet/hood what its called idk the back one

front one and back one
Reply
#2

That's pretty simple...

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(!IsPlayerInAnyVehicle(playerid))
    {
        new
            vehicleid = GetClosestVehicle(playerid);
       
        if(vehicleid != INVALID_VEHICLE_ID)
        {
            new
                engine,
                lights,
                alarm,
                doors
                bonnet,
                boot,
                objective;

            GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
               
            if(newkeys & KEY_YES) // if they pushed Y, open/close the bonnet/hood
            {
                if(bonnet) == 1) SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, 0, boot, objective);
                else SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, 1, boot, objective);
            }
            else if(newkeys & KEY_NO) // if they pushed N, open/close the boot/trunk
            {
                if(boot) == 1) SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, 0, objective); // if the boot is opened, close it
                else SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, 1, objective); // if the boot is closed, open it
            }
        }
    }
    return 1;
}

stock GetCloestVehicle(playerid)
{
    new
        Float:X,
        Float:Y,
        Float:Z,
        Float:distance,
        Float:lastdistance = 20.0,
        vehicleid = INVALID_VEHICLE_ID;
   
    for(new i = 0; i < MAX_VEHICLES; i++)
    {
        GetVehiclePos(v, X, Y, Z);
        distance = GetPlayerDistanceFromPoint(playerid, X, Y, Z);
       
        if(distance < lastdistance)
        {
            lastdistance = distance;
            vehicleid = v;
        }
    }
    return vehicleid;
}
I'm not sure if the GetClosestVehicle function will work or not, I just wrote that up. It looks like it will though!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)