21.07.2013, 18:31
Hey guys, so I created this command and it works fine except for one thing. So the system is all about loading and delivery, so a forklift is loaded and it's on his way to load the truck, once someone uses the command /loadtruck the object won't attach to the truck but on the back of the forklift however I don't understand why. 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;
}