Author Topic: Link and Unlink issues  (Read 1530 times)

Offline topg3ar

  • Rank: Private
  • *
  • Posts: 33
Link and Unlink issues
« on: December 25, 2009, 08:28:46 am »
Hey guys, Merry christmas to all, have a good one.

Now, in my mod im building a chopper gunner seat system where you can have the option of being able to sit inside your chopper and fire down on the soldiers. To start this i have done the following:
Inside the _helicopter.gsc file
Code: [Select]
chopper.requiredDeathCount = owner.deathCount;

chopper.team = heli_team;
chopper.pers["team"] = heli_team;

chopper.owner = owner;
level.ownerplayer = chopper.owner; // Thats my input
chopper thread heli_existance();



//chopper thread heli_trig_interval( level.heli_trigger, level.heli_hardpoint_timer );

level.chopper = chopper;

thread attachPlayer(); // Thats my input

The attachPlayer() function is below:
Code: [Select]
attachPlayer()
{
self endon("disconnect");
self endon("death");

level.ownerplayer = self;
level.ownerplayer linkTo( level.chopper, "tag_player", ( 0,0,0 ), ( 0,0,0 ) );

wait 10;

level.ownerplayer unLink();
}
That function was made by me so tell me if anything is wrong.

ok the problem is that the player gets placed in the chopper, Here's a video of it so far: http://www.xfire.com/video/1c5a31/  , im happy with this for now but once the 10 seconds is over from the wait 10; cod4 crashes with this error:

recursive error: G_VehUnLinkPlayer: player is not in a vehicle

ive have tried many things to fix this and none have succeeded, im posting this here because in your awesome x4 mod you have used these linkTo and unLink functions for the ac130 system, hoping you would know something about it.

Thanks guys for helping in advance.

Top °<|: D

Offline PatmanSan

  • Administrator
  • Rank: Private
  • *****
  • Posts: 2527
Re: Link and Unlink issues
« Reply #1 on: December 25, 2009, 10:55:54 am »
The player is not really IN the AC-130. The ac-130 model is linked to an script_origin entity, which is spawned center-map just above the buildings. The player is linked to that entity too, but somewhat lower (the player is hidden, otherwise it would look silly). So the player is not linked to the vehicle's tag_player, which might be related to your problem.

To test this theory, you can try spawning a script_origin entity, linking it to the vehicle's tag_player, and linking the player to this new entity instead.


level.chopper_link = spawn("script_origin", level.chopper getTagOrigin("tag_player"));
level.chopper_link linkto(level.chopper, "tag_player", (0,0,0), (0,0,0));
level.chopper_link setmodel("tag_origin");

level.ownerplayer = self;
level.ownerplayer linkTo(level.chopper_link, "tag_origin", ( 0,0,0 ), ( 0,0,0 ));


You have to precache the xmodel "tag_origin" somewhere before you can use this code.
precacheModel("tag_origin");

And of course you have to unlink both the player from the level.chopper_link and the level.chopper_link from the chopper itself when you're done.