Does anyone know.. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Does anyone know.. (
/showthread.php?tid=265580)
Does anyone know.. -
bartje01 - 01.07.2011
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
AW: Does anyone know.. -
Nero_3D - 01.07.2011
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
Re: Does anyone know.. -
bartje01 - 01.07.2011
Yup. That's my question. Could you help me a bit?
Re: Does anyone know.. -
BigETI - 01.07.2011
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;
}
Re: Does anyone know.. -
bartje01 - 01.07.2011
Ok thanks.
Now how will I use it on model 596?
Please help.
Re: Does anyone know.. - rjjj - 01.07.2011
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
.
Re: Does anyone know.. -
bartje01 - 01.07.2011
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.