Trunk Coordinates
#7

i made an example

pawn Code:
stock GetPosBehindVehicle (vehicleid, &Float:x, &Float:y, &Float:z, Float:offset=0.5)
{
      new Float:vehicleSize[3], Float:vehiclePos[3];
      GetVehiclePos(vehicleid, vehiclePos[0], vehiclePos[1], vehiclePos[2]);
      GetVehicleModelInfo(GetVehicleModel(vehicleid), VEHICLE_MODEL_INFO_SIZE,vehicleSize[0],vehicleSize[1], vehicleSize[2]);
      GetXYBehindVehicle(vehicleid, vehiclePos[0], vehiclePos[1], (vehicleSize[1]/2)+offset);
      x = vehiclePos[0];
      y = vehiclePos[1];
      z = vehiclePos[2];
      return 1;
}

GetXYBehindVehicle(vehicleid, &Float:q, &Float:w, Float:distance)
{
      new Float:a;
      GetVehiclePos(vehicleid, q, w, a);
      GetVehicleZAngle(vehicleid, a);
      q += (distance * -floatsin(-a, degrees));
      w += (distance * -floatcos(-a, degrees));
}

stock GetNearestVehicle(playerid, Float:dis) // some stock i have found around the forums
{
    new Float:X, Float:Y, Float:Z;
    if(GetPlayerPos(playerid, X, Y, Z))
    {
        new vehicleid = INVALID_VEHICLE_ID;
        for(new v, Float:temp, Float:VX, Float:VY, Float:VZ; v != MAX_VEHICLES; v++)
        {
            if(GetVehiclePos(v, VX, VY, VZ))
            {
                VX -= X, VY -= Y, VZ -= Z;
                temp = VX * VX + VY * VY + VZ * VZ;
                if(temp < dis) dis = temp, vehicleid = v;
            }
        }
        dis = floatpower(dis, 0.5);
        return vehicleid;
    }
    return INVALID_VEHICLE_ID;
}

CMD:trunkdeposit(playerid, params[])
{
    new Float:cPos[3], vID = GetNearestVehicle(playerid, 1);
    if(vID == INVALID_VEHICLE_ID) return SendClientMessage(playerid, -1, "Error. you must be near a car."); // if the player wasnt near from any car
    GetPosBehindVehicle(vID, cPos[0], cPos[1], cPos[2], 1.0); // getting the positions according to the stocks above ^
   
    if(!IsPlayerInRangeOfPoint(playerid, 1.0, cPos[0], cPos[1], cPos[2])) return SendClientMessage(playerid, -1, "Error. you must be near the trunk of the car."); // if player wasnt behind car
   
    // Other code here
    return 1;
}
Reply


Messages In This Thread
Trunk Coordinates - by AphexCCFC - 12.09.2013, 04:26
Re: Trunk Coordinates - by WopsS - 12.09.2013, 05:50
Re: Trunk Coordinates - by AphexCCFC - 12.09.2013, 06:52
Re: Trunk Coordinates - by Misiur - 12.09.2013, 07:41
Re: Trunk Coordinates - by AphexCCFC - 12.09.2013, 16:03
Re: Trunk Coordinates - by AphexCCFC - 12.09.2013, 17:45
Re: Trunk Coordinates - by Kirollos - 13.09.2013, 00:02
Re: Trunk Coordinates - by AphexCCFC - 13.09.2013, 00:19
Re: Trunk Coordinates - by Kirollos - 13.09.2013, 00:21
Re: Trunk Coordinates - by AphexCCFC - 13.09.2013, 01:17

Forum Jump:


Users browsing this thread: 1 Guest(s)