AttachObjectToVehicle -
RALL0 - 19.07.2013
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;
}
Re: AttachObjectToVehicle -
RajatPawar - 19.07.2013
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.
Re: AttachObjectToVehicle -
RALL0 - 19.07.2013
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.
Re: AttachObjectToVehicle -
Mitchy - 19.07.2013
You could maybe indent it properly.
Re: AttachObjectToVehicle -
RALL0 - 19.07.2013
Quote:
Originally Posted by Mitchy
You could maybe indent it properly.
|
I have no idea what you just said.
Re: AttachObjectToVehicle -
RALL0 - 19.07.2013
Bump
Re: AttachObjectToVehicle -
Joe Staff - 19.07.2013
Wouldn't 'GetClosestCar(playerid)' be the vehicle that the player is IN? Clearly you want the closest vehicle that the player is NOT in.
Re: AttachObjectToVehicle -
RALL0 - 20.07.2013
I taught this line
pawn Код:
if(!IsATruck(truckid) && IsPlayerInRangeOfPoint(playerid, 10, X,Y,Z))
Should prevent it from doing that.
Re: AttachObjectToVehicle -
RALL0 - 20.07.2013
Bump
Re: AttachObjectToVehicle -
RALL0 - 21.07.2013
Bump