How to check if trunk is open?
#1

Hello again. I was trying something but it failed, so i am asking for help. I want to check if car trunk is open or not...

I want to make /trunk open if it is closed, and close if it is open, but i have no idea how to check if it is open.. :S
Reply
#2

Add a if
pawn Код:
if(trunk == 0) return set the trunk open.
else return close the trunk.
it does not always work. I would recommand to debug it but since im on my phone i cant do it for you.
Reply
#3

Quote:
Originally Posted by HDFord
Посмотреть сообщение
Add a if
pawn Код:
if(trunk == 0) return set the trunk open.
else return close the trunk.
it does not always work. I would recommand to debug it but since im on my phone i cant do it for you.
Lol, i am talking about checking VehicleParamsEx...
Reply
#4

Ricardo,
you should really know this by now,

Make a variable for every vehicle, and set it to 1 if you opened the trunk,
Set it to 0 if you closed it.


pawn Код:
CMD:boot(playerid, param[])
{
    new count2 = 0;
    for(new vid = 1; vid < MAX_VEHICLES; vid++)
    {
        new Float:ppx, Float:ppy, Float:ppz;
        GetVehiclePos(vid, ppx, ppy, ppz);
        if(IsPlayerInRangeOfPoint(playerid, 3.5, ppx, ppy, ppz))
        {
            count2++;
        }
    }
    if(count2 > 0)
    {
    for(new vid = 1; vid < MAX_VEHICLES; vid++)
    {
        new Float:ppx, Float:ppy, Float:ppz;
        GetVehiclePos(vid, ppx, ppy, ppz);
        if(IsPlayerInRangeOfPoint(playerid, 3.5, ppx, ppy, ppz))
        {
            if(carboot[vid] == 1)
            {
            GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
            SetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,false,objective);
            SendClientMessage(playerid, COLOR_ORANGE, "Car Trunk Closed!");
            carboot[vid] = 0;
            }
            else if(carboot[vid] == 0)
            {
            GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
            SetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,true,objective);
            SendClientMessage(playerid, COLOR_ORANGE, "Car Trunk Opened!!");
            carboot[vid] = 1;
            }
        }
    }
    return 1;
    }
    else return SCM(playerid, COLOR_GREY, "Not near any vehicles!");
}
Reply
#5

So, this will work to make a cmd named /trunk that opens and closes it? I will make the same to /engine too, so i asked for this one as it's the same..

Thanks, as soon as i have patience, i will make it. xD Been without internet the whole day.. :S
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)