SA-MP Forums Archive
Get nearby vehicle's ID & check if player is near that vehicles boot eg? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Get nearby vehicle's ID & check if player is near that vehicles boot eg? (/showthread.php?tid=255969)



Get nearby vehicle's ID & check if player is near that vehicles boot eg? - HP - 18.05.2011

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?


Re: Get nearby vehicle's ID & check if player is near that vehicles boot eg? - __ - 18.05.2011

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


Re: Get nearby vehicle's ID & check if player is near that vehicles boot eg? - HP - 18.05.2011

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

Thanks.