Needing help with a Equipment-from-Trunk-script.
#2

You need this function

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;
}
Quote:
Originally Posted by Chenjiang
Посмотреть сообщение
yes i know the identiation sucks here, but i can fix that up later, it always gets kinda lacky when i copy/paste it from pawn to a forum.
Using [ pawn ] [ /pawn ] tags sometimes fixes it.
Reply


Messages In This Thread
Needing help with a Equipment-from-Trunk-script. - by Chenjiang - 09.08.2011, 15:16
Re: Needing help with a Equipment-from-Trunk-script. - by MadeMan - 09.08.2011, 16:33
[No subject] - by Chenjiang - 09.08.2011, 19:16

Forum Jump:


Users browsing this thread: 1 Guest(s)