AttachTrailerToVehicle - Must stream vehicles how ? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: AttachTrailerToVehicle - Must stream vehicles how ? (
/showthread.php?tid=142149)
AttachTrailerToVehicle - Must stream vehicles how ? -
shotyoudie - 17.04.2010
Hi,
Mine AttachTrailerToVehicle isnt working so i looked ok wiki and i said: Both vehicles need to be streamed but how??
piece of code where it's been used:
Код:
public OnPlayerEnterRaceCheckpoint(playerid)
{
new Veh = GetPlayerVehicleID(playerid);
new Float:X,Float:Y,Float:Z;
if(PlayerIsTrucker[playerid] == -1 && GetVehicleModel(GetPlayerVehicleID(playerid)) == TRUCK)
{
if(IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid)))
{
DetachTrailerFromVehicle(GetPlayerVehicleID(playerid));
}
DisablePlayerRaceCheckpoint(playerid);
TextDrawHideForPlayer(playerid, Driv);
TextDrawShowForPlayer(playerid, DrivGas);
GetPlayerPos(playerid,X,Y,Z);
PlayerTrailer = CreateVehicle(584,X,Y+2,Z,0.0,1,1,60);
AttachTrailerToVehicle(PlayerTrailer,GetPlayerVehicleID(playerid));
new rand = random(sizeof(checkpoints));
SetPlayerRaceCheckpoint(playerid,0,checkpoints[rand][0],checkpoints[rand][1],checkpoints[rand][2],228.6482,1477.7711,10.1840,checkpoints[rand][3]);
}
Dont look to identation

and yes there is no return 1; becaus is not everything, and i dont show it all
Pleas help
~Shotyoudie
Re: AttachTrailerToVehicle - Must stream vehicles how ? -
MadeMan - 17.04.2010
What do you mean with "isnt working" ?
Does the trailer spawn?
Re: AttachTrailerToVehicle - Must stream vehicles how ? -
MPKaboose - 17.04.2010
Quote:
Originally Posted by MadeMan
What do you mean with "isnt working" ?
Does the trailer spawn?
|
even if the trailer spawns where its streamed it
wont be attached to the truck or vehicle trust me I tried
Re: AttachTrailerToVehicle - Must stream vehicles how ? -
MadeMan - 17.04.2010
Quote:
Originally Posted by MPKaboose
even if the trailer spawns where its streamed it wont be attached to the truck or vehicle trust me I tried
|
Right, because trailer takes time to spawn.
You can use a timer then.
pawn Код:
forward AttachTrailer(trailerid, vehicleid);
public AttachTrailer(trailerid, vehicleid)
{
AttachTrailerToVehicle(trailerid, vehicleid);
}
pawn Код:
public OnPlayerEnterRaceCheckpoint(playerid)
{
new Veh = GetPlayerVehicleID(playerid);
new Float:X,Float:Y,Float:Z;
if(PlayerIsTrucker[playerid] == -1 && GetVehicleModel(Veh) == TRUCK)
{
if(IsTrailerAttachedToVehicle(Veh))
{
DetachTrailerFromVehicle(Veh);
}
DisablePlayerRaceCheckpoint(playerid);
TextDrawHideForPlayer(playerid, Driv);
TextDrawShowForPlayer(playerid, DrivGas);
GetPlayerPos(playerid,X,Y,Z);
PlayerTrailer = CreateVehicle(584,X,Y+2,Z,0.0,1,1,60);
SetTimerEx("AttachTrailer", 2000, false, "ii", PlayerTrailer,Veh);
new rand = random(sizeof(checkpoints));
SetPlayerRaceCheckpoint(playerid,0,checkpoints[rand][0],checkpoints[rand][1],checkpoints[rand][2],228.6482,1477.7711,10.1840,checkpoints[rand][3]);
}
Re: AttachTrailerToVehicle - Must stream vehicles how ? -
shotyoudie - 17.04.2010
Quote:
Originally Posted by MadeMan
Quote:
Originally Posted by MPKaboose
even if the trailer spawns where its streamed it wont be attached to the truck or vehicle trust me I tried
|
Right, because trailer takes time to spawn.
You can use a timer then.
pawn Код:
forward AttachTrailer(trailerid, vehicleid); public AttachTrailer(trailerid, vehicleid) { AttachTrailerToVehicle(trailerid, vehicleid); }
pawn Код:
public OnPlayerEnterRaceCheckpoint(playerid) { new Veh = GetPlayerVehicleID(playerid); new Float:X,Float:Y,Float:Z; if(PlayerIsTrucker[playerid] == -1 && GetVehicleModel(Veh) == TRUCK) { if(IsTrailerAttachedToVehicle(Veh)) { DetachTrailerFromVehicle(Veh); } DisablePlayerRaceCheckpoint(playerid); TextDrawHideForPlayer(playerid, Driv); TextDrawShowForPlayer(playerid, DrivGas); GetPlayerPos(playerid,X,Y,Z); PlayerTrailer = CreateVehicle(584,X,Y+2,Z,0.0,1,1,60); SetTimerEx("AttachTrailer", 2000, false, "ii", PlayerTrailer,Veh); new rand = random(sizeof(checkpoints)); SetPlayerRaceCheckpoint(playerid,0,checkpoints[rand][0],checkpoints[rand][1],checkpoints[rand][2],228.6482,1477.7711,10.1840,checkpoints[rand][3]); }
|
Gonna try it, Thx