PHP код:
else if(IsPlayerInRangeOfPoint(playerid, 50, -75.0189,-1121.8265,0.8185) && PlayerData[playerid][Job] == 5) //&& //StaticVeh[vehicleid][vJob] == 5)
{//Trucker
new randn = random(sizeof(TruckerCP));
SetPlayerCheckpoint(playerid, TruckerCP[randn][0], TruckerCP[randn][1], TruckerCP[randn][2], 4.0);
SetDestination(playerid, TruckerCP[randn][0], TruckerCP[randn][1], TruckerCP[randn][2]);
PTruckerCP[playerid] = randn;
VJob[playerid] = CreateVehicle(515, -75.0189,-1121.8265,0.8185+10,171.1932, 1, 1, -1);
new Float:Pos[3], Float:rotationtrailer;
GetVehiclePos(VJob[playerid], Pos[0], Pos[1], Pos[2]);
GetVehicleZAngle(Vjob[playerid] ,rotationtrailer);
TrailerID[playerid] = CreateVehicle(435, Pos[0]+6, Pos[1]+6, Pos[2]+6, rotationtrailer, 1, 1, -1);
AttachTrailerToVehicle(TrailerID[playerid], VJob[playerid]);
SendClientMessage(playerid, COLOR_YELLOW, "Take a trailer and deliver to the checkpoint!");
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(VJob[playerid], engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(VJob[playerid], engine, lights, alarm, 1, bonnet, boot, objective);
PutPlayerInVehicle(playerid, VJob[playerid], 0);
}
the code seems to be well, but give a little bit timer for a sync and than attach.
PHP код:
SetTimerEx("AttachVehicleTimer",350,0,"ii",TrailerID[playerid],VJob[playerid]); // put this instead of AttachTrailerToVehicle
forward AttachVehicleTimer(veh1,veh2);
public AttachVehicleTimer(veh1,veh2)
{
AttachTrailerToVehicle(veh1,veh2);
return 1;
}
PHP код:
function AttachTrailer(playerid)
{
new Float:pX, Float:pY, Float:pZ;
GetPlayerPos(playerid,pX,pY,pZ);
new Float:vX, Float:vY, Float:vZ;
GetVehiclePos(TrailerID[playerid],vX,vY,vZ);
if((floatabs(pX-vX)<100.0)&&(floatabs(pY-vY)<100.0)&&(floatabs(pZ-vZ)<100.0)&&(TrailerID[playerid]!=GetPlayerVehicleID(playerid))) AttachTrailerToVehicle(TrailerID[playerid],GetPlayerVehicleID(playerid));
return 1;
}