Home   Help Search Login Register  

Author Topic: Add script into cpp file  (Read 4108 times)

0 Members and 1 Guest are viewing this topic.

Maximus-Sniper

  • Guest
Re:Add script into cpp file
« Reply #15 on: 25 Jul 2004, 20:26:27 »
Hei!
I found out one thing , I can't use that class EventHandlers:

class EventHandlers
            {
           init="[_this select 0] exec ""\BAB\Script\bulletcam\Init.sqs""; PosBullcam=loadFile ""\BAB\script\bulletcam\load.sqf""";
      };

Because I have two sniper in my addon, if i add them both to the same mission, I got the "Bullet Cam On" twise in the Action Menu in game..Why??

How can i fix that problem???

Or how can i make this line to class UserAction ???

class EventHandlers
            {
          init="[_this select 0] exec ""\BAB\Script\bulletcam\Init.sqs""; PosBullcam=loadFile ""\BAB\script\bulletcam\load.sqf""";
      };

Someone have a good answare? :)


           
« Last Edit: 26 Jul 2004, 09:52:25 by Maximus-Sniper »

Unnamed

  • Guest
Re:Add script into cpp file
« Reply #16 on: 27 Jul 2004, 07:42:41 »
Quote
So you have not read misinformation... I just explained the stuff poorly (again, as usual  )...

Shame :( It might have come in handy, hope they improve on it in OFP2. Some way of addons to call all the description.ext commands.

Not sure exactly what PreProcess file does, but I'd put money on it at least stripping away comments from functions. I dont think loadfile is bugged as such, it was probably never ment to handle comments.

Quote
Now i got my bullet camera to work perffect..
I only rename my description.ext to sniper.h the i only have to do is past this line into a mission description.ext file

Great news, as long as your now using exec to run your scripts and loadfile to load functions?

Quote
I got the "Bullet Cam On" twise in the Action Menu in game..Why??

You will get more if your sniper gets in and out of vehicles. For men, the init event is called everytime they leave a vehicle. I dont know the bullet cam script your using, but I'm guessing your adding an action to the player with the add action command?

You probably need a global variable to tell you when an action has been added, so you dont add any more. Or do you want two differnt cameras? Could you explain more about the actions your setting up and how you want to use them.

Maximus-Sniper

  • Guest
Re:Add script into cpp file
« Reply #17 on: 27 Jul 2004, 09:08:00 »
Hei Unnamed :)
Sorry man.
Yes i'am using exec and loadfile: Take a look

Here is the  init.sqs i call it for sniperinit.sqs:

player addaction ["Bullet camera on","\Bab\script\bulletcam\sniperTrackEryx.sqs"]
player addEventHandler ["fired",{_Missile = nearestObject [vehicle(player), _this select 4];[_missile] exec "\Bab\script\bulletcam\sniperfired.sqs"}]

track = false

Here is the SnipertrackEryx.sqs file:

_ID = _this select 2
player removeAction _ID
? !(track) : track = true ; player addaction ["Bullet camera off", "\Bab\script\bulletcam\sniperTrackEryx.sqs"];exit
? (track) : track = false; player addaction ["Bullet camera on", "\Bab\script\bulletcam\sniperTrackEryx.sqs"]

Here is the sniperload.sqs file:

_this call loadFile "\BAB\script\bulletcam\PosBullCam.sqf"

Here is the sniperfired.sqs file:

_Missile =  _this select 0
? isNull  _Missile : exit
? !(track) : exit
_ok = createDialog "Speed"
? !(_ok) : exit
setAccTime 0.01
_Type= typeOf _Missile

_cam = "camera" camcreate [0,0,0]
_cam cameraeffect ["internal", "back"]


sliderSetRange [100, 0.01, 1]
sliderSetSpeed [100, 0.5, 2.0]
sliderSetPosition [100, 0]
sliderSetRange [99, 0.1, 1]
sliderSetPosition [99, 1]
sliderSetSpeed [99, 0.1, .25]
sliderSetRange [98, -180, 180]
sliderSetPosition [98, 0]
sliderSetSpeed [98, 0.5, 2.0]
sliderSetRange [97, -15000, 15000]
sliderSetPosition [97, 0]
sliderSetSpeed [97, 0.5, 2.0]
#loop
? _Type != typeOf _Missile : goto "end"
[ _Missile ,_cam,(sliderPosition 99),(sliderPosition 98),(sliderPosition 97)] call PosBullcam
setAccTime (sliderPosition 100)
? ctrlvisible 100 : goto "loop"


#End
? (getpos _cam select 1 == 0) or !(_Type != typeOf _Missile) : goto "SkipSlowEnd"
 setAccTime 0.2
~0.85
#SkipSlowEnd
_cam cameraeffect ["terminate", "back"]
 camdestroy _cam
closedialog 0
setAccTime 1
exit

Here is the PosBullcam.sqf file:

private ["_Cam", "_Zoom", "_Missile", "_Rotate ","_zView"];
_Missile = _This select 0;
_Cam = _this select 1;
_Zoom = _This select 2;
_Rotate = _This select 3;
_zview = _This select 4;

_cam camsetpos getpos _missile;
_cam camSetFov _Zoom;
_cam camsettarget [((getpos _missile select 0) + ((sin (getdir _Missile + _Rotate  ))* 5000 )), (getpos _missile select 1)+ (((cos (getdir _Missile +_Rotate  ))* 5000 )) , ((getPos _Missile   select 2)+(velocity _Missile select 2))+ _zview ];
_cam   camcommit 0;
ctrlSettext [101,format["%1  meters",(_Missile distance player)]] ;
ctrlSettext [102,format["%1 m/s",( (Speed  _missile )* 1000 ) / 3600  ]];
ctrlSettext [103,format["%1", velocity _Missile   ]];

Here is the description.ext i call it for sniper.h:

#define CT_STATIC                  0
#define CT_BUTTON                  1
#define CT_EDIT                     2
#define CT_SLIDER                  3
#define CT_COMBO                  4
#define CT_LISTBOX               5
#define CT_TOOLBOX               6
#define CT_CHECKBOXES            7
#define CT_PROGRESS               8
#define CT_HTML                     9
#define CT_STATIC_SKEW         10
#define CT_ACTIVETEXT            11
#define CT_TREE                     12
#define CT_3DSTATIC               20
#define CT_3DACTIVETEXT         21
#define CT_3DLISTBOX            22
#define CT_3DHTML                  23
#define CT_3DSLIDER               24
#define CT_3DEDIT                  25
#define CT_OBJECT                  80
#define CT_OBJECT_ZOOM         81
#define CT_OBJECT_CONTAINER   82
#define CT_OBJECT_CONT_ANIM   83
#define CT_USER                     99


#define ST_HPOS                  0x0F
#define ST_LEFT                  0
#define ST_RIGHT               1
#define ST_CENTER               2
#define ST_UP                     3
#define ST_DOWN                  4
#define ST_VCENTER            5

#define ST_TYPE                  0xF0
#define ST_SINGLE               0
#define ST_MULTI               16
#define ST_TITLE_BAR         32
#define ST_PICTURE            48
#define ST_FRAME               64
#define ST_BACKGROUND         80
#define ST_GROUP_BOX         96
#define ST_GROUP_BOX2         112
#define ST_HUD_BACKGROUND   128
#define ST_TILE_PICTURE      144
#define ST_WITH_RECT         160
#define ST_LINE                  176

#define ST_SHADOW               256
#define ST_NO_RECT            512

#define ST_TITLE               ST_TITLE_BAR + ST_CENTER


#define IDC_OK                  1
#define IDC_CANCEL            2


#define TextColor         0.08, 0.08, 0.12
#define InvTextColor   0.35, 0.38, 0.36


#define FontS "tahomaB24"
#define FontM "tahomaB36"

#define FontHTML "courierNewB64"
#define FontHTMLBold "courierNewB64"
#define FontMAP "courierNewB64"
#define FontMAIN "SteelfishB64"
#define FontMAINCZ "SteelfishB64CE"
#define FontTITLE "SteelfishB128"
#define FontTITLEHalf "SteelfishB64"
#define FontBOOK "garamond64"
#define FontNOTES "AudreysHandI48"

class RscText   {type = 0;
      idc = -1;
      style = 0;
      h = .04;
       colorBackground[] = {0, 0, 0, 0};
      colorText[] = {.08, .08, .12, .75};
      font = FontS;
      size = .02;};

class RscEdit   
   {
          type = CT_EDIT;
         idc = -1;
         style = ST_LEFT;
          font = FontHTML;
         sizeEx = 0.02;
         colorText[] = {0, 0, 0, 1};
         colorSelection[] = {0.5, 0.5, 0.5, 1};
          autocomplete = true;text = ;
         };

class RscPicture   
   {
         type = CT_STATIC;
         idc = -1;
         style = ST_PICTURE;
         colorBackground[] = {0, 0, 0, 1};
         colorText[] = {1, 1, 1, 1};
         font = FontS;size = 0;
         };

class RscTextSmall   
   {
         type = CT_STATIC;
         idc = -1;
         style = ST_LEFT;
         h = 0.04;
          colorBackground[] = {0, 0, 0, 0};
         colorText[] = {.08, .08, .12, .75};
         font = FontS;
         size = 0.7;};



class RscBackground   {type = 0;
         idc = -1;
         style = 80;
         x=.15;
         y=.15;
         w=.7;
         h = 0.7;
         text = "";
         colorBackground[] = {1, 1, 1, 1};
         colorText[] = {0, 0, 0, 0};
         font = FontS;
         sizeEx = 0;
         };

class RscTitle   {   
         type = 0;
         idc = -1;
         style = 32+2;
         x=.15;
         y=.164;
         w=.7;
         h = 0.06;
         text = "";
         colorBackground[] = {1, 1, 1, 1};
         colorText[] = {.08, .08, .12, 1};
         font = FontM;
         sizeEx = 1.0714 * 0.03;
         };

class RscActiveText     {  type = CT_ACTIVETEXT;  
         idc = -1;
         style = ST_LEFT;
         color[] = {1, 1, 1, 1};
         colorActive[] = {1, 0, 0, 1};
          font = FontM;
          sizeEx = 0.04;
         soundEnter[] = {"ui\ui_over", 0.2, 1};soundPush[] = {, 0.2, 1};soundClick[] = {"ui\ui_ok", 0.2, 1}; soundEscape[] = {"ui\ui_cc", 0.2, 1}; default = false;    Â Â Â Â Â Â Â Â Â };


class RscSlider       { type = CT_SLIDER;
         
         idc = -1;
         style = ST_HPOS;
         selection ="display";
         Zoom =0.1;
         
         color[] = {0, 0, 0, 0.8};
         colorBackground[] = {1, 1, 1, 0.75};
            colorText[] = {0.08, 0.08, 0.12, .75};
            size = 0.8;
             angle = 0;
            font = FontS;
            
            };
class RscButton  Â Â Â { type = CT_BUTTON;idc = -1;style = ST_CENTER;colorText[] = {0, 0, 0, 1};font = FontHTML; sizeEx = 0.015; soundPush[] = {, 0.2, 1}; soundClick[] = {"ui\ui_ok", 0.2, 1}; soundEscape[] = {"ui\ui_cc", 0.2, 1}; default = false;   };
   
class Speed
{
     idd = -1;
 Â Â Â  movingEnable = 1;
   controlsBackground[] = {};
      objects[] = {};

 Â Â Â  controls[]={AccelerateTime  , DistanceText,dot,SpeedText ,vel,xpos,ypos,zoom,RotationText ,UpDownText ,ZoomText
      };
    class RotationText : RscTextSmall   {
   Â Â Â 
   x = 0.76 ; y = 0.36; w = 0.22; h = 0.03; sizeEx = 0.02;text = "Up Down caméra"; action = "";
     
      };
     class xpos : RscSlider {
   Â Â Â  idc = 97;
   x = 0.76 ; y = 0.39; w = 0.22; h = 0.035; sizeEx = 0.02; action = "";
     
      };
   class UpDownText : RscTextSmall   {
   Â Â Â 
   x = 0.76 ; y = 0.43; w = 0.22; h = 0.03; sizeEx = 0.02;text = "Rotation caméra"; action = "";
     
      };
    class ypos : RscSlider {
   Â Â Â  idc = 98;
   x = 0.76 ; y = 0.46; w = 0.22; h = 0.035; sizeEx = 0.02; action = "";
     
      };   
    class ZoomText : RscTextSmall   {
   Â Â Â 
   x = 0.76 ; y = 0.50; w = 0.22; h = 0.03; sizeEx = 0.02;text = "Zoom"; action = "";
     
      };
   class zoom: RscSlider {
   Â Â Â  idc = 99;
   x = 0.76 ; y = 0.53; w = 0.22; h = 0.035; sizeEx = 0.02; action = "";
     
      };

    class AccelerateTime : RscSlider {
   Â Â Â  idc = 100;
   x = 0.76 ; y = 0.81; w = 0.22; h = 0.035; sizeEx = 0.02; action = "";
     
      };
   class DistanceText: RscEdit   {
   Â Â Â  idc = 101;
   style = ST_MULTI + ST_NO_RECT;
   x = 0.76 ; y = 0.74; w = 0.22; h = 0.035; sizeEx = 0.02; action = "";
     
      };
     class SpeedText : RscEdit   {
   Â Â Â  idc = 102;
   style = ST_MULTI + ST_NO_RECT;
   x = 0.76 ; y = 0.67; w = 0.22; h = 0.035; sizeEx = 0.02; action = "";
     
      };
   class Vel: RscEdit   {
   Â Â Â  idc = 103;
   style = ST_MULTI + ST_NO_RECT;
   x = 0.76 ; y = 0.60; w = 0.22; h = 0.035; sizeEx = 0.02; action = "";
     
      };class Dot : RscTextSmall      {
   Â Â Â 
   x = 0.5 ; y = 0.5; w = 0.01; h = 0.01; sizeEx = 0.02; text = "+"
     
      };   
};


And here is the line I use in my cpp file:

class EventHandlers
      {
      init="[_this select 0] exec ""\BAB\Script\bulletcam\sniperInit.sqs""; PosBullcam=loadFile ""\BAB\script\bulletcam\PosBullcam.sqf""";
      };

I put that line under class CfgVehicles in my cpp file.

You got right about that when i get out of a Vehicle the the "Bullet Camera On" got twis :( Thats all info i can get you. The Bulletcam i use, did i found here, i serarh for Bulletcam i i found one I like "Bullet Camera   uiox   1.2 " Big thank to Uiox for this nice bulletcam. its with two demo mission. I only want one camera. :)
Iam not good i scripting i only copy and past :) and try a lot of time.. :)
But it's work only if i don't add the same sniper in my mission or when i got out from a  Vehicle.
But i dont know how to fix that problem. :( Somebody have?? please msg me :)

Sorry about my English :)
« Last Edit: 27 Jul 2004, 09:10:47 by Maximus-Sniper »

Unnamed

  • Guest
Re:Add script into cpp file
« Reply #18 on: 29 Jul 2004, 10:36:48 »
You can check to make sure your scripts are only executed once per mission.

Allocate a unique global varable (make it unique to you, you dont want mission\addon makers using the same variable name by mistake), and check if its been defined.

See the tag system here http://www.ofpec.com/tags_about.php for your variable names

Code: [Select]
If (Format["%1",UNN_Initialised_Snipers]=="scalar bool array string 0xfcffffef") Then {UNN_Initialised_Snipers=True ; ....}
So the code in the If condition will be called once, at the start of the mission.

Maximus-Sniper

  • Guest
Re:Add script into cpp file
« Reply #19 on: 29 Jul 2004, 16:12:46 »
Hei Unnamed
Thank alot, I got it to work now.
I use a class Action like this into my cpp:

.
.
.
class sniperbulletcam
      {
         displayName = "Bullet Camera";
         position = "axisgoggles";
         radius = 1.00000;
         condition = "(Format [{%1},Bullet_Camera] != {false}) && (player == this)";
         statement = "this exec {\bab\script\bulletcam\sniperinit.sqs}"; PosBullcam=loadFile ""\BAB\script\bulletcam\PosBullcam.sqf"";
      };
.
.
.
.
And i change a bit in my sniperinit.sqs file like this:

_player= _this
_player addaction ["Bullet camera on","\Bab\script\bulletcam\sniperTrackEryx.sqs"]
_player addEventHandler ["fired",{_Missile = nearestObject [vehicle(player), _this select 4];[_missile] exec "\Bab\script\bulletcam\sniperfired.sqs"; PosBullcam=loadFile "\BAB\script\bulletcam\PosBullcam.sqf"}]
track = false

PosBullcam=loadFile "\BAB\script\bulletcam\PosBullcam.sqf"

validation = false


And now it's work perffect :)
But if someone see somthing wrong or something to change, i like to hear :)

Thank alot everyone for heelping me :)