Police pullover
#7

Try this:

Add these stocks;

pawn Код:
stock GetDistancePlayerVeh(playerid, veh) {

    new
        Float:Floats[7];

    GetPlayerPos(playerid, Floats[0], Floats[1], Floats[2]);
    GetVehiclePos(veh, Floats[3], Floats[4], Floats[5]);
    Floats[6] = floatsqroot((Floats[3]-Floats[0])*(Floats[3]-Floats[0])+(Floats[4]-Floats[1])*(Floats[4]-Floats[1])+(Floats[5]-Floats[2])*(Floats[5]-Floats[2]));

    return floatround(Floats[6]);
}

stock GetClosestVehicle(playerid, exception = INVALID_VEHICLE_ID) {
    new
        Float:Distance,
        target = -1;

    for(new v; v < MAX_VEHICLES; v++) if(doesVehicleExist(v)) {
        if(v != exception && (target < 0 || Distance > GetDistancePlayerVeh(playerid, v))) {
            target = v;
            Distance = GetDistancePlayerVeh(playerid, v);
        }
    }
    return target;
}

stock doesVehicleExist(const vehicleid) {
    if(GetVehicleModel(vehicleid) >= 400) {
        return 1;
    }
    return 0;
}

stock IsPlayerInRangeOfVehicle(playerid, vehicleid, Float: radius) {

    new
        Float:Floats[3];

    GetVehiclePos(vehicleid, Floats[0], Floats[1], Floats[2]);
    return IsPlayerInRangeOfPoint(playerid, radius, Floats[0], Floats[1], Floats[2]);
}
Try using this command after adding the above stocks.

pawn Код:
CMD:pu(playerid, params[])
{

    new vehicleid = GetClosestVehicle(playerid);
    for (new checkwantedpull; checkwantedpull < MAX_PLAYERS; checkwantedpull++)

    if(gTeam[playerid] == POLICE) {
        if(IsPlayerInRangeOfVehicle(playerid, vehicleid, 15.0) {
            if(IsPlayerInVehicle(checkwantedpull, vehicleid) && GetPlayerWantedLevel(checkwantedpull) >= 1) {
                GameTextForPlayer(checkwantedpull,"~b~ POLICE REQUEST~n~~r~PULL OVER",6000,5);
                SendClientMessage(playerid, COLOR_BLUE, "Pull over request sent.");
            }
            else SendClientMessage(playerid, COLOR_GREY, "That player is not wanted!");
        }
        else SendClientMessage(playerid, COLOR_GREY, "You are too far away from that vehicle!");
    }
    return 1;
}
Those stocks were taken from my script so it may need a bit of tweaking. We'll see.
Reply


Messages In This Thread
Police pullover - by Stu1 - 29.10.2012, 01:31
Re: Police pullover - by Edward d - 29.10.2012, 01:55
Re: Police pullover - by Eric - 29.10.2012, 05:35
Re: Police pullover - by guitarmandanny - 29.10.2012, 06:12
Re: Police pullover - by Stu1 - 29.10.2012, 15:57
Re: Police pullover - by Edward d - 29.10.2012, 23:16
Re: Police pullover - by Eric - 30.10.2012, 00:52
Re : Police pullover - by lelemaster - 30.10.2012, 02:09
Re: Re : Police pullover - by Eric - 30.10.2012, 04:03
Re : Police pullover - by lelemaster - 30.10.2012, 20:51

Forum Jump:


Users browsing this thread: 1 Guest(s)