Vehicle In Water
#1

Hello,


I was wondering if there has been any methods yet to detect if the vehicle have been driven into water, or pushed into water, etc. I know I've heard about certain zs in certain areas.. but was wondering if it has already been done, If so please link me or tell me about it, I've searched it but never found it.

Thanks in advance.
Reply
#2

OnVehicleDeath is called when a vehicle enters water (but also when they explode). That's all I can think of. Not sure how you could detect whether it's water or explosion.

P.S. Note the following:

> Vehicle enters water
> OnVehicleDeath called
> Vehicle is 'saved' from water (teleported/driven out (thanks to low waves))
> Vehicle re-enters water
> OnVehicleDeath won't be called a second time.
Reply
#3

Well, mapandreas returns a z-height of 0.0 over water.
Reply
#4

So do MANY other places.
Reply
#5

Quote:
Originally Posted by MP2
Посмотреть сообщение
So do MANY other places.
Yeah thats my issue. The quarry is definitely under 0.0, so if you enter there, it would be considered under water as well.
Reply
#6

That is not what I meant, Mapandreas will always return 0.0 over any water, now MP2 mentioned there are other areas any idea where they might be ? Another thing under bridges would be a problem with that detection.
Reply
#7

I have one idea but i not test it much :
if you be able to fallow i will wrote it here and you test it and let me know is it working.

Car is in water , OnVehicleDeath is called,Car coordinates are still,and this in chat not position coordinate

Car stay out of water,Car coordinate are still ,but look in chat (explained will be below)

Code of chat:
pawn Код:
public OnPlayerUpdate(playerid)
{
new Float:w,Float:x,Float:y,Float:z;
new text[128];
if(IsPlayerInAnyVehicle(playerid))
{
GetVehicleRotationQuat(GetPlayerVehicleID(playerid),w,x,y,z);
format(text,sizeof(text),"w: %f x: %f y: %f z: %f",w,x,y,z);
SendClientMessage(playerid,0xFFFFFFFF,text);
}
return 1;
}
And if you check is OnVehicleDeath is called , and this things go wild may be you able to detect.
just a idea and mumble of me.
Reply
#8

That is a good idea but what if the vehicle is airborne, on a hill etc then this won't work.

There is one other way but it's a bit of work.

Use incognito's streamer and these functions

Код:
native CreateDynamicPolygon(Float:points[], Float:minz = -FLOAT_INFINITY, Float:maxz = FLOAT_INFINITY, maxpoints = sizeof points, worldid = -1, interiorid = -1, playerid = -1);

native IsPointInDynamicArea(areaid, Float:x, Float:y, Float:z);
Define your water areas then check to see if a vehicle's position is in your water areas.
Reply
#9

I tested whit hi z(cord) no change:

on hill do not know but i will leave it to more test when i have more time.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)