Help: /breaklock command (Car Jacker)
#1

I have a few problems with the following code, None of the ClientMessage's show for some reason, and the second problem is that ALL vehicles unlock (not just the nearest vehicle)... Whats wrong with my code, and how can I fix it or rewrite it?

Thanks: jakejohnsonusa

/breaklock Command Code:
pawn Код:
if (strcmp(cmd, "/breaklock", true) == 0)
    {
        new vehicle[24];
        new nearest = GetNearestVehicle(playerid, 20.0);
        GetVehicleName(nearest, vehicle, sizeof(vehicle));
        if(IsPlayerConnected(playerid) & PlayerInfo[playerid][pJob] == 5)// Job 5 is Car Jacker Job
        {
            new Float:X,Float:Y,Float:Z;
            GetVehiclePos(nearest, X, Y, Z);
            if(IsPlayerInRangeOfPoint(playerid, 20.0, X, Y, Z))
            {
                //SendClientMessage(playerid, COLOR_GREY, "** You broke the cars lock. Now lets see if you can start it...");
                CarInfo[nearest][cLock] = 0;
                new engine, lights, alarm, doors, bonnet, boot, objective;
                GetVehicleParamsEx(nearest, engine, lights, alarm, doors, bonnet, boot, objective);
                SetVehicleParamsEx(nearest, engine, lights, alarm, false, bonnet, boot, objective);
                SendClientMessage(playerid, COLOR_GREY, "** You broke the cars lock. Now lets see if you can start it...");
            }
            else
            {
                SendClientMessage(playerid, COLOR_WHITE, "** No vehicles in range to break into!");
            }
        }
        return 1;
    }
Reply
#2

Check the radius :
Код:
20.0
Reply
#3

Can you show your getnearestvehicle function?
Reply
#4

Sure,

Here it is:
pawn Код:
stock GetNearestVehicle(playerid, Float:dis)
{
    new Float:L, Float:O, Float:II;
    if(GetPlayerPos(playerid, L, O, II))
    {
        new vehicleid = INVALID_VEHICLE_ID;
        for(new v, Float:temp, Float:VL, Float:VO, Float:VII; v != MAX_VEHICLES; v++)
        {
            if(GetVehiclePos(v, VL, VO, VII) && v != GetPlayerVehicleID(playerid))
            {
                VL -= L, VO -= O, VII -= II;
                temp = VL * VL + VO * VO + VII * VII;
                if(temp < dis) dis = temp, vehicleid = v;
            }
        }
        dis = floatpower(dis, 1.5);
        return vehicleid;
    }
    return INVALID_VEHICLE_ID;
}
Thanks in advance!
Reply
#5

Bump... Anyone know?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)