AttachObjectToVehicle
#1

Hey, I got a little problem over here, I created this cmd that loads the forklift cargo on the truck. The only problem is once I use the cmd the object or the cargo doesn't get attached on the truck but on the back of the forklift .
Here are the codes.
pawn Код:
CMD:loadtruck(playerid, params[])
{
    new vehicleid = GetPlayerVehicleID(playerid);
    new truckid = GetClosestCar(playerid);
    new Float:X,Float:Y,Float:Z;
    GetVehiclePos(truckid, X,Y,Z);
    if(IsAForklift(vehicleid))
    {
    if(ForkliftLoaded[vehicleid] == 0) return SendClientMessage(playerid, COLOR_DARKRED,"[SERVER] {FFFFFF}There is no cargo on this forklift.");
    if(!IsATruck(truckid) && IsPlayerInRangeOfPoint(playerid, 10, X,Y,Z))
    {
    if(TruckLoaded[truckid] == 0)
    {
    DestroyObject(ForkliftObject[vehicleid][vObject]);
    TruckObject[truckid][vObject] = CreateObject(964, 0, 0.9, -0.12, 0, 0, 0);
    AttachObjectToVehicle(TruckObject[truckid][vObject], truckid, 0.000000, -3.890041, 0.120000, 0.000000, 0.000000, 0.000000);
    TruckLoaded[truckid] = 1;
    ForkliftLoaded[vehicleid] = 0;
    }
    else return SendClientMessage(playerid, COLOR_DARKRED,"[SERVER] {FFFFFF}This truck can't carry more cargo.");
    }
    else return SendClientMessage(playerid, COLOR_DARKRED,"[SERVER] {FFFFFF}You aren't near any cargo truck.");
    }
    else return SendClientMessage(playerid, COLOR_DARKRED,"[SERVER] {FFFFFF}You must be a driver of a forklift to load a forklift.");
    return 1;
}
Reply
#2

Use the map editor, create the forklift at 0, 0, 0 position. Then create the object you "load" and get it to your desired position. Then get the positions of that object, those will be your OFFSETS to use in AttachObjectToVehicle.
Reply
#3

I used a tool for that, but thats not the problem, I mean once the forklift is near the truck to load the object to the truck it attaches to object on the forklift again and the meaning of this code is attach it to the truck.
Reply
#4

You could maybe indent it properly.
Reply
#5

Quote:
Originally Posted by Mitchy
Посмотреть сообщение
You could maybe indent it properly.
I have no idea what you just said.
Reply
#6

Bump
Reply
#7

Wouldn't 'GetClosestCar(playerid)' be the vehicle that the player is IN? Clearly you want the closest vehicle that the player is NOT in.
Reply
#8

I taught this line
pawn Код:
if(!IsATruck(truckid) && IsPlayerInRangeOfPoint(playerid, 10, X,Y,Z))
Should prevent it from doing that.
Reply
#9

Bump
Reply
#10

Bump
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)