Fraction-Car "locking" doesn't work
#1

Hey guys!
I've made a fraction-car locking command so a fraction member can lock his fraction-vehicle.
But this only works on the first created fraction vehicle. (fVehicle[0][..])

So here's my command.
If I go to the next vehicle (is also an fraction vehicle, 100%!!) there comes: No car in your range ...

pawn Код:
CMD:flock(playerid)
{
    new Float:pos[3];
    if(Player[playerid][pFraction] == 0)return SendClientMessage(playerid, COLOR_LIGHTBLUE, ">> "COLOR_HEX_GREY"You're not in a fraction!");
    for(new fV;fV<MAX_FVEHS;fV++)
    {
        if(IsValidVehicle(fVehicle[fV][vehID]))
        {
            GetVehiclePos(fVehicle[fV][vehID], pos[0], pos[1], pos[2]);
            GetVehicleParamsEx(fVehicle[fV][vehID], engine, lights, alarm, doors, bonnet, boot, objective);
            if(IsPlayerInRangeOfPoint(playerid, 3.0, pos[0], pos[1], pos[2]))
            {
                if(fVehicle[fV][vehFraction] == Player[playerid][pFraction])
                {
                    if(doors == VEHICLE_PARAMS_UNSET || doors == VEHICLE_PARAMS_OFF)
                    {
                        LockVehicle(fVehicle[fV][vehID]);
                        GameTextForPlayer(playerid, "~w~Fracton-Vehicle~n~~r~locked", 3000, 6);
                        PlaySoundInRange(pos[0], pos[1], pos[2], 1027, 10, 0, 0);
                        return 1;
                    }
                    else if(doors == VEHICLE_PARAMS_ON)
                    {
                        UnlockVehicle(fVehicle[fV][vehID]);
                        GameTextForPlayer(playerid, "~w~Fraction-Vehicle~n~~g~opened", 3000, 6);
                        PlaySoundInRange(pos[0], pos[1], pos[2], 1027, 10, 0, 0);                      
                        return 1;
                    }
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_LIGHTBLUE, ">> "COLOR_HEX_GREY"There's no vehicle in your range.");
                return 1;
            }
        }
    }
    return 1;
}
Thank you guys!
Reply
#2

Are we talking about 2/5 here, or 1/3?
Reply
#3

What do you mean?
Reply
#4

pawn Код:
if(GetDistanceFromPlayerToVehicle(playerid, fV) < 5.0)
pawn Код:
CMD:flock(playerid)
{
    new Float:pos[3];
    if(Player[playerid][pFraction] == 0)return SendClientMessage(playerid, COLOR_LIGHTBLUE, ">> "COLOR_HEX_GREY"You're not in a fraction!");
    for(new fV;fV<MAX_FVEHS;fV++)
    {
        if(GetDistanceFromPlayerToVehicle(playerid, fV) < 5.0)
        {
            GetVehiclePos(fVehicle[fV][vehID], pos[0], pos[1], pos[2]);
            GetVehicleParamsEx(fVehicle[fV][vehID], engine, lights, alarm, doors, bonnet, boot, objective);
            if(IsPlayerInRangeOfPoint(playerid, 3.0, pos[0], pos[1], pos[2]))
            {
                if(fVehicle[fV][vehFraction] == Player[playerid][pFraction])
                {
                    if(doors == VEHICLE_PARAMS_UNSET || doors == VEHICLE_PARAMS_OFF)
                    {
                        LockVehicle(fVehicle[fV][vehID]);
                        GameTextForPlayer(playerid, "~w~Fracton-Vehicle~n~~r~locked", 3000, 6);
                        PlaySoundInRange(pos[0], pos[1], pos[2], 1027, 10, 0, 0);
                        return 1;
                    }
                    else if(doors == VEHICLE_PARAMS_ON)
                    {
                        UnlockVehicle(fVehicle[fV][vehID]);
                        GameTextForPlayer(playerid, "~w~Fraction-Vehicle~n~~g~opened", 3000, 6);
                        PlaySoundInRange(pos[0], pos[1], pos[2], 1027, 10, 0, 0);
                        return 1;
                    }
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_LIGHTBLUE, ">> "COLOR_HEX_GREY"There's no vehicle in your range.");
                return 1;
            }
        }
    }
    return 1;
}
Reply
#5

Now it shows:
No vehicle in range .. lulz
Reply
#6

Maybe try increasing the radius, or use this method:

Код:
stock GetDistanceBetween(playerid, vehicleid)
{
new Float: cx, Float: cy, Float: cz;
if(IsPlayerInRangeOfPoint(playerid, cx, cy, cz) return 1;
if(!IsPlayerInRangeOfPoint(playerid, cx, cy, cz) return 0;
}
Haven't tested it, though... Just something I did in a few seconds...
Reply
#7

Had a brain fart... Sorry...

Код:
Use:
stock GetDistanceBetween(playerid, vehicleid)
{
new Float: cx, Float: cy, Float: cz;
GetVehiclePos(vehicleid, cx, cy, cz);
if(IsPlayerInRangeOfPoint(playerid, 15.0, cx, cy, cz) return 1;
if(!IsPlayerInRangeOfPoint(playerid, 15.0, cx, cy, cz) return 0;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)