detecting if a vehicle is infront of a vehicle?
#1

pawn Код:
new cv = GetClosestVehicle(playerid, 8.0);
                                if(cv == INVALID_VEHICLE_ID) return 1;
                                new Float:x, Float:y, Float:z;
                                GetVehiclePos(id, x, y, z);
                                SendClientMessageFormatted(playerid, -1, "x: %f - y: %f", x, y);
                                GetXYInFrontOfVehicle(id, x, y, 4.0);
                                SendClientMessageFormatted(playerid, -1, "after - x: %f - y: %f", x, y);
                                if(GetVehicleDistanceToPoint(cv, x, y, z) < 4.0)
                                {
                                    new Float:Health;
                                    GetVehicleHealth(cv, Health);
                                    SetVehicleHealth(cv, Health - 50.0);
                                }
i tried that, it doesn't really work good.

got any ideas?
Reply
#2

your code should work, can you debug it with printf? (for us, the sa-mp users of course and yourself :P)
tip: try to print as many variables as possible then check if they are correct or not.

Also are you sure your functions work correctly?
Reply
#3

yes but, i can't have health being lost in this case.

it would be even accurate if i could get getobjectpos to work after attachobjecttovehicle

[URL=http://imageshack.us/photo/my-images/402/samp041j.png/]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)