Get nearby vehicle's ID & check if player is near that vehicles boot eg?
#1

Hello.

How should I get nearby vehicle's ID? I think it would be possible if I'd hook it up with MySQL database, since I'm creating a SQL based gamemode anyway, it wouldn't be a problem. I think it should be possible to use a loop too.

It should be something like this, if using a loop...
pawn Код:
SetNearbyVehicleParam(playerid)
{
    new Float:x, Float:y, Float:z, Float:radi;
    GetPlayerPos(playerid, x, y, z);
    Float:radi = 3.0;
    for(new i=1; i<MAX_VEHICLES; i++) {
        if(GetVehicleModel(i)) {
            new Float:posx, Float:posy, Float:posz;
            new Float:tempposx, Float:tempposy, Float:tempposz;
            new engine, lights, alarm, doors, bonnet, boot, objective;
            GetVehicleParamsEx(i, engine, lights, alarm, doors, bonnet, boot, objective);
            GetVehiclePos(i, posx, posy, posz);
            tempposx = (posx - x);
            tempposy = (posy - y);
            tempposz = (posz - z);
            if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi))) {
                // Setting the vehicle's params here.
            }
        }
    }
}
Is there any way to check if player is near vehicle's specific point, eg. boot?
Reply
#2

Search for uf.inc ('useful functions') as it retains a "GetClosestVehicle" function.
Reply
#3

Ah, I found it. If anybody else needs, then it's located in SA-MP wiki. Check it out here.

Thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)