[HELP] GetVehiclePos Really this bugged?!?!?
#1

I was wondering if GetVehiclePos is really this bugged up or is it some weird ass error in my code. I know GetVehiclePos is supposed to return either the players last vehicles position or the original spawn location. Yet from the printf in the console no matter what I do, get in a car or just get near a fresh spawned car the result is always the same. GetClosestVehicle returns 0, and in the print I get the distance to the vehicle as being 1158606533 (read EDIT2).

WTF do I do or can I do to get this to work?

Here is the 2 functions code.
pawn Код:
stock GetClosestVehicle(playerid)
{
    new x,Float:dis,Float:dis2,vehicleid;
    vehicleid = -1;
    dis = 99999.99;
    for (x=0;x<MAX_VEHICLES;x++)
    {
        dis2 = GetDistanceToVehicle(playerid, vehicleid);
        if(dis2 < dis && dis2 != -1.00)
        {
            dis = dis2;
            vehicleid = x;
        }

    }
    printf("Closest Vehicle: %d", vehicleid);
    return vehicleid;
}

stock Float:GetDistanceToVehicle(playerid, vehicleid)
{
    new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
    GetPlayerPos(playerid,x1,y1,z1);
    GetVehiclePos(vehicleid ,x2,y2,z2);
    new Float:tmpdis = floatsqroot((x2-=x1)*x2 + (y2-=y1)*y2 + (z2-=z1)*z2);
    printf("Distance to Vehicle: %.2f", tmpdis);
    return tmpdis;
}
[EDIT] Does it matter that I spawn the cars with AddStaticVehicleEx ?

[EDIT2]Whoops I see now why I wasn't getting a float value on print (duh) but still why am I only getting the same distance of 2471.96 no matter what I do -.-
Reply


Messages In This Thread
[HELP] GetVehiclePos Really this bugged?!?!? - by cyber_punk - 01.09.2009, 10:55
Re: [HELP] GetVehiclePos Really this bugged?!?!? - by MrSns - 01.09.2009, 11:51
Re: [HELP] GetVehiclePos Really this bugged?!?!? - by cyber_punk - 01.09.2009, 12:15
Re: [HELP] GetVehiclePos Really this bugged?!?!? - by Joosephe - 01.09.2009, 14:21
Re: [HELP] GetVehiclePos Really this bugged?!?!? - by cyber_punk - 01.09.2009, 14:56

Forum Jump:


Users browsing this thread: 2 Guest(s)