Getting last vehicle id player was in.
#5

Quote:
Originally Posted by eesh
Посмотреть сообщение
pawn Код:
public OnPlayerStateChange(playerid,oldstate,newstate)
{
    if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
    {
        lastvehicleid[playerid] = GetPlayerVehicleID(playerid);
    }
}
stock IsVehicleNear(vehicleid)
{
    new Float:p[3];
    GetVehiclePos(vehicleid, p[0],p[1],p[2])
    if(IsPlayerInRangeOfPoint(playerid, 4.0, p[0],p[1],p[2])) return 1;
    return 0;
}
So you can use a vehicles trunk, AFTER you enter & exit it? Whats the point in that? O.O

Anyway i searched ****** for you, and found this:
pawn Код:
GetClosestVehicleID(playerid)
{
    new Float:min_dist = 100.0;
    new Float:dist;
    new Float:vehx,Float:vehy,Float:vehz;
    new Float:px,Float:py,Float:pz;
    new Float:x,Float:y,Float:z;
    GetPlayerPos(playerid,px,py,pz);
    new close_vehid;
    for(new i = 1; i < MAX_VEHICLES;i++)
    {
        if(GetVehicleModel(i) > 0)
        {
            GetVehiclePos(i,vehx,vehy,vehz);
            x = px - vehx;
            y = py - vehy;
            z = pz - vehz;
            dist = floatsqroot((x * x) + (y * y) + (z * z));
            if(dist < min_dist)
            {
                min_dist = dist;
                close_vehid = i;
            }
        }
    }
    return close_vehid;
}
Then just use a check, if(player is near that vehicle id), for example, PlayerToPoint or IsPlayerInRange.


Tell me if this works, and +rep !
Reply


Messages In This Thread
Getting last vehicle id player was in. - by Dokins - 12.03.2012, 23:18
Re: Getting last vehicle id player was in. - by ddnbb - 12.03.2012, 23:31
Re: Getting last vehicle id player was in. - by eesh - 13.03.2012, 04:04
Re: Getting last vehicle id player was in. - by ddnbb - 13.03.2012, 10:28
Re: Getting last vehicle id player was in. - by ddnbb - 13.03.2012, 10:31
Re: Getting last vehicle id player was in. - by Babul - 13.03.2012, 10:51
Re: Getting last vehicle id player was in. - by ddnbb - 13.03.2012, 11:01
Re: Getting last vehicle id player was in. - by Babul - 13.03.2012, 11:11
Re: Getting last vehicle id player was in. - by ddnbb - 13.03.2012, 11:30

Forum Jump:


Users browsing this thread: 1 Guest(s)