AttachTrailerToVehicle
#1

The trailer is not attaching,it spawns right to the car,but not attaching

PHP код:
else if(IsPlayerInRangeOfPoint(playerid50, -75.0189,-1121.8265,0.8185) && PlayerData[playerid][Job] == 5//&& //StaticVeh[vehicleid][vJob] == 5)
    
{//Trucker
        
new randn random(sizeof(TruckerCP));
        
SetPlayerCheckpoint(playeridTruckerCP[randn][0], TruckerCP[randn][1], TruckerCP[randn][2], 4.0);
        
SetDestination(playeridTruckerCP[randn][0], TruckerCP[randn][1], TruckerCP[randn][2]);
        
PTruckerCP[playerid] = randn;
        
VJob[playerid] = CreateVehicle(515, -75.0189,-1121.8265,0.8185+10,171.193211, -1);
        new 
Float:Pos[3], Float:rotationtrailer;
        
GetVehiclePos(VJob[playerid], Pos[0], Pos[1], Pos[2]);
        
GetVehicleZAngle(Vjob[playerid] ,rotationtrailer);
        
TrailerID[playerid] = CreateVehicle(435Pos[0]+6Pos[1]+6Pos[2]+6rotationtrailer11, -1);
        
AttachTrailerToVehicle(TrailerID[playerid], VJob[playerid]);
        
SendClientMessage(playeridCOLOR_YELLOW"Take a trailer and deliver to the checkpoint!");
        new 
enginelightsalarmdoorsbonnetbootobjective;
        
GetVehicleParamsEx(VJob[playerid], enginelightsalarmdoorsbonnetbootobjective);
        
SetVehicleParamsEx(VJob[playerid], enginelightsalarm1bonnetbootobjective);
        
PutPlayerInVehicle(playeridVJob[playerid], 0);
    } 
Reply
#2

the code seems to be well, but give a little bit timer for a sync and than attach.

for example
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;

Reply
#3

solved it with this:

PHP код:
SetTimerEx("AttachTrailer"10000"i"playerid); 
PHP код:
function AttachTrailer(playerid)
 {
     new 
Float:pXFloat:pYFloat:pZ;
    
GetPlayerPos(playerid,pX,pY,pZ);
    new 
Float:vXFloat:vYFloat: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;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)