09.08.2011, 16:33
You need this function
Using [ pawn ] [ /pawn ] tags sometimes fixes it.
pawn Код:
stock GetClosestVehicle(playerid)
{
new Float:x, Float:y, Float:z;
new Float:dist, Float:closedist=9999, closeveh;
for(new i=1; i < MAX_VEHICLES; i++)
{
if(GetVehiclePos(i, x, y, z))
{
dist = GetPlayerDistanceFromPoint(playerid, x, y, z);
if(dist < closedist)
{
closedist = dist;
closeveh = i;
}
}
}
return closeveh;
}
pawn Код:
if(strcmp(cmd, "/policetrunk", true) == 0)
{
if(PlayerInfo[playerid][pMember] == 3 || PlayerInfo[playerid][pLeader] == 3)
{
if(PlayerInfo[playerid][pDuty] == 1)
{
new vehicleid = GetClosestVehicle(playerid);
new Float:x, Float:y, Float:z;
GetVehiclePos(vehicleid, x, y, z);
if(IsPlayerInRangeOfPoint(playerid, 10.0, x, y, z)) // vehicle is within 10.0 radius
{
if(vehicleid == LSPDCAR[1])
{
//give player some stuff&open the cars trunk
}
else if(vehicleid == LSPDCAR[2])
{
//give player some stuff&open the cars trunk
}
else
{
SendClientMessage(playerid, COLOR_GREY, "You are not close to a LSPD Vehicle");
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, "You are not close to a car.");
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, "You are not on Duty.");
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, "You are not a Member of the LSPD.");
}
return 1;
}