Stock not setting vehicles trunk.
#1

As the title says the stock I am working on isn't setting the vehicles boot to 1 it just says as 0.
pawn Код:
stock BootStatusOfNearestVehicle(playerid, Float:distance = 2.0)
{
    new
        Float:fPos[3],
        Float:sPos[3],
        currentvehicle,
        engine,
        lights,
        alarm,
        doors,
        bonnet,
        boot,
        objective
    ;

    GetPlayerPos(playerid, fPos[0], fPos[1], fPos[2]);

    for(new v = 1; v < MAX_VEHICLES; v++)
    {
        new Float:odist =
        floatsqroot(
        floatpower(floatsub(sPos[0], fPos[0]), 2.0) +
        floatpower(floatsub(sPos[1], fPos[1]), 2.0) +
        floatpower(floatsub(sPos[2], fPos[2]), 2.0));
        GetVehiclePos(v, sPos[0], sPos[1], sPos[2]);
        if (odist < distance)
        {
            currentvehicle = v;
            distance = odist;
            if(IsPlayerInRangeOfPoint(playerid, sPos[0], sPos[1], sPos[2], distance))
            {
                if(boot == 1)
                {
                    GetVehicleParamsEx(v, engine, lights, alarm, doors, bonnet, boot, objective);
                    SetVehicleParamsEx(v, engine, lights, alarm, doors, bonnet, 0, objective);
                }
                else if(boot == 0)
                {
                    GetVehicleParamsEx(v, engine, lights, alarm, doors, bonnet, boot, objective);
                    SetVehicleParamsEx(v, engine, lights, alarm, doors, bonnet, 1, objective);
                }
            }
        }
    }
    return currentvehicle;
}
Reply
#2

You aren't retrieving the boot status for each vehicle, so the code just assumes it equals 0.

This:

pawn Код:
if(boot == 1)
                {
                    GetVehicleParamsEx(v, engine, lights, alarm, doors, bonnet, boot, objective);
                    SetVehicleParamsEx(v, engine, lights, alarm, doors, bonnet, 0, objective);
                }
                else if(boot == 0)
                {
                    GetVehicleParamsEx(v, engine, lights, alarm, doors, bonnet, boot, objective);
                    SetVehicleParamsEx(v, engine, lights, alarm, doors, bonnet, 1, objective);
                }
Should be, this:

pawn Код:
GetVehicleParamsEx(v, engine, lights, alarm, doors, bonnet, boot, objective);
if(boot == 1) SetVehicleParamsEx(v, engine, lights, alarm, doors, bonnet, 0, objective);
else if(boot == 0) SetVehicleParamsEx(v, engine, lights, alarm, doors, bonnet, 1, objective);
Reply
#3

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
You aren't retrieving the boot status for each vehicle, so the code just assumes it equals 0.

This:

pawn Код:
if(boot == 1)
                {
                    GetVehicleParamsEx(v, engine, lights, alarm, doors, bonnet, boot, objective);
                    SetVehicleParamsEx(v, engine, lights, alarm, doors, bonnet, 0, objective);
                }
                else if(boot == 0)
                {
                    GetVehicleParamsEx(v, engine, lights, alarm, doors, bonnet, boot, objective);
                    SetVehicleParamsEx(v, engine, lights, alarm, doors, bonnet, 1, objective);
                }
Should be, this:

pawn Код:
GetVehicleParamsEx(v, engine, lights, alarm, doors, bonnet, boot, objective);
if(boot == 1) SetVehicleParamsEx(v, engine, lights, alarm, doors, bonnet, 0, objective);
else if(boot == 0) SetVehicleParamsEx(v, engine, lights, alarm, doors, bonnet, 1, objective);
Still isn't doing it.
Reply
#4

pawn Код:
stock BootStatusOfNearestVehicle(playerid, Float:distance = 2.0)
{
    new
        Float:fPos[3],
        Float:sPos[3],
        currentvehicle,
        engine,
        lights,
        alarm,
        doors,
        bonnet,
        boot,
        objective
    ;

    GetPlayerPos(playerid, fPos[0], fPos[1], fPos[2]);

    for(new v = 1; v < MAX_VEHICLES; v++)
    {
        GetVehiclePos(v, sPos[0], sPos[1], sPos[2]);
       
        new Float:odist =
            floatsqroot(
                floatpower(floatsub(sPos[0], fPos[0]), 2.0) +
                floatpower(floatsub(sPos[1], fPos[1]), 2.0) +
                floatpower(floatsub(sPos[2], fPos[2]), 2.0)
            )
        ;
       
        if (odist < distance)
        {
            currentvehicle = v;
            distance = odist;
        }
    }
   
    GetVehicleParamsEx(v, engine, lights, alarm, doors, bonnet, boot, objective);
    if(boot == 1) SetVehicleParamsEx(v, engine, lights, alarm, doors, bonnet, 0, objective);
    else if(boot == 0) SetVehicleParamsEx(v, engine, lights, alarm, doors, bonnet, 1, objective);
    return currentvehicle;
}
Reply
#5

pawn Код:
return boot;
Maybe you need return boot?
Reply
#6

I can't seem to get it working still.
Reply
#7

1. You don't need loop at all. Put vehicleid parameter in your function.
2. You need return boot status not currentvehicle. Am I right?
Reply
#8

Quote:
Originally Posted by B-Matt
Посмотреть сообщение
1. You don't need loop at all. Put vehicleid parameter in your function.
2. You need return boot status not currentvehicle. Am I right?
Ok this is what I have now and it does't work.
pawn Код:
stock BootStatusOfNearestVehicle(playerid, Float:distance = 2.0)
{
    new
        Float:fPos[3],
        Float:sPos[3],
        currentvehicle,
        engine,
        lights,
        alarm,
        doors,
        bonnet,
        boot,
        objective
    ;

    GetPlayerPos(playerid, fPos[0], fPos[1], fPos[2]);

    for(new v = 1; v < MAX_VEHICLES; v++)
    {
        GetVehiclePos(v, sPos[0], sPos[1], sPos[2]);

        new Float:odist =
            floatsqroot(
                floatpower(floatsub(sPos[0], fPos[0]), 2.0) +
                floatpower(floatsub(sPos[1], fPos[1]), 2.0) +
                floatpower(floatsub(sPos[2], fPos[2]), 2.0)
            )
        ;

        if (odist < distance)
        {
            currentvehicle = v;
            distance = odist;
        }
    }

    GetVehicleParamsEx(currentvehicle, engine, lights, alarm, doors, bonnet, boot, objective);
    if(boot == 1) SetVehicleParamsEx(currentvehicle, engine, lights, alarm, doors, bonnet, 0, objective);
    else if(boot == 0) SetVehicleParamsEx(currentvehicle, engine, lights, alarm, doors, bonnet, 1, objective);
    return boot;
}
Reply
#9

pawn Код:
stock BootStatusOfNearestVehicle(playerid, vehicleid, Float:distance = 2.0)
{
    new
        Float:fPos[3],
        Float:sPos[3],
        currentvehicle,
        engine,
        lights,
        alarm,
        doors,
        bonnet,
        boot,
        objective
    ;

    GetPlayerPos(playerid, fPos[0], fPos[1], fPos[2]);
    GetVehiclePos(v, sPos[0], sPos[1], sPos[2]);

    new Float:odist =
            floatsqroot(
                floatpower(floatsub(sPos[0], fPos[0]), 2.0) +
                floatpower(floatsub(sPos[1], fPos[1]), 2.0) +
                floatpower(floatsub(sPos[2], fPos[2]), 2.0)
            );

        if (odist < distance) //What the hell is that?
        {
            currentvehicle = v;
            distance = odist;
        }
    }

    GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
    if(boot == 1) SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, 0, objective);
    else if(boot == 0) SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, 1, objective);
    return boot;
}
Your code don't work because you set and get params from currentvehicle what is not vehicleid.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)