How can i make it where if im around a car i can use /cartrunk instead of being inside of the car?
pawn Код:
CMD:cartrunk(playerid, params[])
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
new vehicle = GetPlayerVehicleID(playerid);
new string[128];
new pname[MAX_PLAYER_NAME];
if(Boot[vehicle] == 0)
{
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicle, engine, lights, alarm, doors, bonnet, boot, objective);
GetPlayerName(playerid, pname, sizeof(pname));
format(string, sizeof(string), "%s Has opened his/her's vehicle's trunk", pname);
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
SCM(playerid, COLOR_WHITE, "You have vehicle's trunk to {00FF00}[OPEN]");
Boot[vehicle] = 1;
SetVehicleParamsEx(vehicle, engine, lights, alarm, doors, bonnet, 1, objective);
}
else if(Boot[vehicle] == 1)
{
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicle, engine, lights, alarm, doors, bonnet, boot, objective);
Boot[vehicle] = 0;
SetVehicleParamsEx(vehicle, engine, lights, alarm, doors, bonnet, 0, objective);
GetPlayerName(playerid, pname, sizeof(pname));
format(string, sizeof(string), "%s Has pulled down his/her's vehicle's trunk", pname);
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
SCM(playerid, COLOR_WHITE, "You have vehicle's trunk to {FF0000}[CLOSED]");
}
}
return 1;
}
pawn Код:
stock GetClosestVehicle(playerid)
{
new
Float:fPos[3],
Float:distance = 30,
Float:curdistance,
currentVehicle;
for(new v = 0; v < MAX_VEHICLES; v++)
{
GetVehiclePos(v, fPos[0], fPos[1], fPos[2]);
curdistance = GetPlayerDistanceFromPoint(playerid, fPos[0], fPos[1], fPos[2]);
if(curdistance < distance)
{
currentVehicle = v;
distance = curdistance;
}
}
return currentVehicle;
}
pawn Код:
for(new i; i != MAX_VEHICLES; i++)
{
new Float:PosX,Float:PosY,Float:PosZ;
GetVehiclePos(i,PosX,PosY,PosZ);
if(IsPlayerInRangeOfPoint(playerid, 3.5, PosX,PosY,PosZ))
{
pawn Код:
stock IsPlayerNearAnyTrunk(playerid)
{
for(new vehicleid= 0; vehicleid < MAX_VEHICLES; vehicleid++)
{
if(GetVehicleModel(vehicleid) == 0) continue;
new Float:x, Float:y, Float:z;
GetVehicleTrunkPosition(vehicleid, x, y, z);
if(IsPlayerInRangeOfPoint(playerid, 5.0, x, y, z))
{
return vehicleid;
}
}
return -1;
}
GetVehicleTrunkPosition(vehicleid, &Float:x, &Float:y, &Float:z)
{
new Float:a, Float:z, Float:xo, Float:yo, Float:zo;
GetVehiclePos(vehicleid, x, y, z);
GetVehicleZAngle(vehicleid, a);
GetVehicleModelInfo(GetVehicleModel(vehicleid), VEHICLE_MODEL_INFO_SIZE, xo, yo, zo);
x += (-yo* floatsin(-a, degrees));
y += (-yo* floatcos(-a, degrees));
}