detect vehicle is in water - 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)
+--- Thread: detect vehicle is in water (
/showthread.php?tid=489110)
detect vehicle is in water -
COL - 20.01.2014
how i could i detect if the vehicle in water, is there a stock or something could be created?
thanks.
Re: detect vehicle is in water -
Ballu Miaa - 20.01.2014
You can only check if the player is in a vehicle and the vehicle is in the water by the available codes on the forums. If you want to do that. You will need to make a custom function which will check the pos of the vehicle with all the water areas. I tried to code you a function. It is untested. Maybe it will work. I am not sure.
pawn Код:
stock IsVehicleInWater(vehicleid)
{
new Float:water_areas[][] =
{
{25.0, 2313.0, -1417.0, 23.0},
{15.0, 1280.0, -773.0, 1082.0},
{15.0, 1279.0, -804.0, 86.0},
{20.0, 1094.0, -674.0, 111.0},
{26.0, 194.0, -1232.0, 76.0},
{25.0, 2583.0, 2385.0, 15.0},
{25.0, 225.0, -1187.0, 73.0},
{50.0, 1973.0, -1198.0, 17.0}
};
for(new t=0; t < sizeof water_areas; t++)
if(GetVehicleDistanceFromPoint(vehicleid,water_areas[t][1],water_areas[t][2],water_areas[t][3]) <= water_areas[t][0]) return 1;
return 0;
}
Re: detect vehicle is in water -
Vince - 20.01.2014
If I recall correctly, OnVehicleDeath is triggered immediately when a vehicle enters water.
Re: detect vehicle is in water -
Ballu Miaa - 20.01.2014
Quote:
Originally Posted by Vince
If I recall correctly, OnVehicleDeath is triggered immediately when a vehicle enters water.
|
Quote:
Originally Posted by SA-MP Wiki
This callback is called when a vehicle is destroyed - either by exploding or becoming submerged in water.
|
Also when it explodes.
Re: detect vehicle is in water -
COL - 24.01.2014
could you give me a small example how it work?
Re: detect vehicle is in water -
Memoryz - 24.01.2014
Quote:
Originally Posted by COL
could you give me a small example how it work?
|
pawn Код:
if(IsVehicleInWater(vehicleid))
{
SendClientMessageToAll(-1, "Vehicle is in water.");
}