How to get near vehicle
#1

Hello sa-mp scripters I want to ask you how to get a vehicle who is near the player?
Thanks for help
Reply
#2

Код:
for(new i = 0; i < MAX_VEHICLES; i++)
{
    new Float:x, Float:y, Float:z;
    GetVehiclePos(i, x, y, z);
    if(IsPlayerInRangeOfPoint(playerid, 10.0, x, y, z))
    {
        // Do whatever you want with the vehicle that is near you. 'i' is the variable for the vehicle's ID.
        // Example: SetVehicleHealth(i, 200); 
        // Will set the vehicle near you on fire.
        // Removing the 'break' will set all the vehicles near you on fire.
        break;
    }
}
Reply
#3

Thanks it's working
Reply
#4

Thanx dude this code works for me too, but I want to know. Will it cause some brutal usages of cpu or ram? Becouse when on server you will have 500 vehicles and loop will start ..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)