SA-MP Forums Archive
Its impossible? - 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)
+--- Thread: Its impossible? (/showthread.php?tid=304895)



Its impossible? - TouhGear - 20.12.2011

How its impossible?

How i open boot or bonnet I have a out of car, exaple behind the car?


Re: Its impossible? - §с†¶e®РµРe - 20.12.2011

SetVehicleParamsEx


Re: Its impossible? - TouhGear - 20.12.2011

Yeas, but when i have behind the car, not in the car?


Re: Its impossible? - Gamer_Z - 20.12.2011

Quote:
Originally Posted by TouhGear
Посмотреть сообщение
Yeas, but when i have behind the car, not in the car?
SetVehicleParamsEx uses vehicleID param, not PlayerID so you can do it while not in the car.


Re: Its impossible? - TouhGear - 20.12.2011

some can give me code?


Re: Its impossible? - Gamer_Z - 20.12.2011

https://sampwiki.blast.hk/wiki/SetVehicleParamsEx


Re: Its impossible? - kizla - 20.12.2011

pawn Код:
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vid,engine,lights,alarm,doors,1,1,objective);



Re: Its impossible? - TouhGear - 20.12.2011

Код:
CMD:openbonnet(playerid, params[])
{
	new vid;
	new engine,lights,alarm,doors,bonnet,boot,objective;
	GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
	SetVehicleParamsEx(vid,engine,lights,alarm,doors,1,boot,objective);
	return 1;
}
like this?

But how make this? When i do not have any car at the, server say: you are not close to any car

How make this?


Re: Its impossible? - Gamer_Z - 20.12.2011

Quote:
Originally Posted by TouhGear
Посмотреть сообщение
Код:
CMD:openbonnet(playerid, params[])
{
	new vid;
	new engine,lights,alarm,doors,bonnet,boot,objective;
	GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
	SetVehicleParamsEx(vid,engine,lights,alarm,doors,1,boot,objective);
	return 1;
}
like this?
vid is the VehicleID, you need to know it!
when a player is in the car you want it then you can use
vid = GetPlayerVehicleID(playerid);

else assign an id to the vehicle at creation for later use.
another way is to loop all vehicles and compare distances and pick the closest one to your X Y Z point.

(eg:
pawn Код:
getPlayerClosestVehicle(playerid, Float:maximumDistance=-1.0)
{
    if(!IsPlayerConnected(playerid))
        return -1;

    new
        closestVehicle = -1,
        Float:closestDistance = -1.0,
        Float:currentDistance = 0.0,
        Float:x0, Float:y0, Float:z0,
        Float:x1, Float:y1, Float:z1;

    GetPlayerPos(playerid, x0, y0, z0);
    for(new checkVehicle; checkVehicle < MAX_VEHICLES; checkVehicle++)
    {
        if(!GetVehicleModel(checkVehicle)) // jeżeli pojazd o ID 'checkVehicle' ma model o ID '0' to pomijamy go
            continue;
        GetVehiclePos(checkVehicle, x1, y1, z1);
        currentDistance = floatsqroot(floatadd(floatadd(floatpower(floatsub(x0, x1), 2), floatpower(floatsub(y0, y1), 2)), floatpower(floatsub(z0, z1), 2)));
        if((maximumDistance == -1.0 || currentDistance < maximumDistance) && (closestDistance == -1.0 || currentDistance < closestDistance))
        {
            closestDistance = currentDistance;
            closestVehicle = checkVehicle;
        }
    }
    return closestVehicle;
}
)


Re: Its impossible? - TouhGear - 20.12.2011

now how make the command?

Код:
CMD:openbonnet(playerid, params[])
{
             new vid = GetPlayerClosestVehicle(1.0, playerid);        
	new engine,lights,alarm,doors,bonnet,boot,objective;
	GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective);
	SetVehicleParamsEx(vid,engine,lights,alarm,doors,1,boot,objective);	
return 1;
}
?