Does anyone know..
#1

Hey.
Does anyone know how to make a IsPlayerInRangeOfVehicleModel or something like that?

So you can check if a player is near a police car.

Thankyou
Reply
#2

Quote:
Originally Posted by bartje01
Посмотреть сообщение
Hey.
Does anyone know how to make a IsPlayerInRangeOfVehicleModel or something like that?

So you can check if a player is near a police car.

Thankyou
Just loop through all vehicles and check if its in the range of the player

And for each vehicle in range check if the model fits
Reply
#3

Yup. That's my question. Could you help me a bit?
Reply
#4

I have two usefull stocks for you:

pawn Код:
stock GetPlayerDistanceToVehicle(playerid, tovehicleid, &Float:Distance)
{
    new Float:pX, Float:pY, Float:pZ, Float:vX, Float:vY, Float:vZ;
    GetPlayerPos(playerid,pX,pY,pZ);
    GetVehiclePos(tovehicleid,vX,vY,vZ);
    Distance = floatsqroot((vX-pX)*(vX-pX)+(vY-pY)*(vY-pY)+(vZ-pZ)*(vZ-pZ));
}
and

pawn Код:
stock IsPlayerInRangeOfVehicle(playerid, tovehicleid, Float:Range)
{
    new Float:vX, Float:vY, Float:vZ;
    GetPlayerPos(playerid,pX,pY,pZ);
    GetVehiclePos(tovehicleid,vX,vY,vZ);
    if(IsPlayerInRangeOfPoint(playerid,Range,vX,vY,vZ)) return true;
    return false;
}
Reply
#5

Ok thanks.
Now how will I use it on model 596?
Please help.
Reply
#6

Quote:
Originally Posted by bartje01
Посмотреть сообщение
Hey.
Does anyone know how to make a IsPlayerInRangeOfVehicleModel or something like that?

So you can check if a player is near a police car.

Thankyou
You can make it using loops and functions do check and get coordinates .


I did it .



pawn Код:
stock IsPlayerInRangeOfVehicleModel(playerid, Float:range, vehiclemodel)
{
    new Float:VehiclePos[3];
    for(new x; x != MAX_VEHICLES; x++)
    {
        GetVehiclePos(x,VehiclePos[0],VehiclePos[1],VehiclePos[2]);
        if((GetVehicleModel(x) == vehiclemodel) && IsPlayerInRangeOfPoint(playerid, range, VehiclePos[0],VehiclePos[1],VehiclePos[2]))
        {
            return true;
        }
    }
    return false;
}


So, you can use like this:



Код:
if(IsPlayerInRangeOfVehicleModel(playerid, 10.0, 596))
To police cars .



I hope that i have helped .
Reply
#7

Quote:
Originally Posted by rjjj
Посмотреть сообщение
You can make it using loops and functions do check and get coordinates .


I did it .



pawn Код:
stock IsPlayerInRangeOfVehicleModel(playerid, Float:range, vehiclemodel)
{
    new Float:VehiclePos[3];
    for(new x; x != MAX_VEHICLES; x++)
    {
        GetVehiclePos(x,VehiclePos[0],VehiclePos[1],VehiclePos[2]);
        if((GetVehicleModel(x) == vehiclemodel) && IsPlayerInRangeOfPoint(playerid, range, VehiclePos[0],VehiclePos[1],VehiclePos[2]))
        {
            return true;
        }
    }
    return false;
}


So, you can use like this:



Код:
if(IsPlayerInRangeOfVehicleModel(playerid, 10.0, 596))
To police cars .



I hope that i have helped .
Thankyou. You helped alot.
It works perfect.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)