Jump to content
Sign in to follow this  
ravennx

Createveh woes

Recommended Posts

Ok guys... im looking to create a veh or object.

Ive got a script.. but what i want is it to Create at my exact position and Face the way the player is facing.

It creates usally in a random pos and not the same way player is facing.

Also Can I give these created veh names in the script somewhere.

Thanks for the help.

deletevehicle m2;

player playMove "AinvPknlMstpSlayWrflDnon_medic";

sleep 3.0;

WaitUntil {animationState player != "AinvPknlMstpSlayWrflDnon_medic"};

_mark = format["%M2StaticMG",(name player)];

deleteMarker _mark;

m2 = "M2StaticMG" createVehicle (position player);

m2 setdir (getdir player);

m2 addEventHandler ["killed", {handle = [_this select 0] execVM "scripts\bury.sqf"}];

_pos = position m2tent;

_mssg = format["%1's M2 Static",(name player)];

_medmark = createMarker [_mark, _pos];

_medmark setMarkerShape "ICON";

_medmark setMarkerType "Marker";

_medmark setMarkerColor "ColorredAlpha";

_medmark setMarkerText _mssg;

_medmark setMarkerSize [0.5, 0.5];

_medmark setMarkerDir 45;

exit

Share this post


Link to post
Share on other sites
Quote[/b] ]It creates usally in a random pos and not the same way player is facing.

Try something like this:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">m2=ObjNull;

m2 = "M2StaticMG" createVehicle [0,0,-1000];

WaitUntil {!(IsNull m2)};

m2 setdir (getdir player);

M2 SetPos (Player ModelToWorld [2,0,0]);

Quote[/b] ]Also Can I give these created veh names in the script somewhere.

You are already, at least the global variable you are assigning it to is m2.

If you want to give each one a unique variable, then the simplest way is use some sort of global counter. So the code could look like this instead:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">If ((TypeName "M2Count")!="SCALAR") Then

       {

       M2Count=0;

       }

       Else

       {

       M2Count=M2Count+1;

       };

_CurrM2=ObjNull;

_CurrM2="M2StaticMG" createVehicle [0,0,-1000];

WaitUntil {!(IsNull _CurrM2)};

_CurrM2 setdir (GetDir player);

_CurrM2 SetPos (Player ModelToWorld [2,0,0]);

[_CurrM2] Call Compile Format ["M2%1=(_This Select 0)",M2Count]

So now each M2 will be assign to variables M20,M21,M22....M25 and so on.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×