Problem with a callback
#3

That is because you are checking only the first vehicle to see if the player is near it. Here is, hopefully, the working code. I suggest you look up some structures on how to properly execute loops. Note that 'return' stops the rest of the code from executing, and since you have it in both places, it's useless. I also slightly optimized this code. You can also use IsPlayerInRangeOfPoint. Seeing it's a native function, it will be slightly faster.
pawn Код:
public IsVehicleInRadius(playerid)
{
        new Float:x, Float:y, Float:z;
    for(new c=0;c<MAX_VEHICLES;c++)
    {
        GetVehiclePos(c,x,y,z);
        if( IsPlayerInRangeOfPoint( playerid, 5.0, x, y, z ) ) return 1;
        continue;
    }
        SendClientMessage( playerid, COLOR_YELLOW, "You are not near the car!" );
    return 0;
}
This function has also been slightly changed to return 0 if the player is not near the vehicle.
Reply


Messages In This Thread
Problem with a callback - by Ice-cup - 27.01.2011, 12:26
Re: Problem with a callback - by DeathOnaStick - 27.01.2011, 15:07
Re: Problem with a callback - by Grim_ - 27.01.2011, 17:08
Re: Problem with a callback - by Ice-cup - 27.01.2011, 19:46
Re: Problem with a callback - by Ice-cup - 28.01.2011, 16:22

Forum Jump:


Users browsing this thread: 1 Guest(s)