Home   Help Search Login Register  

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

0 Members and 1 Guest are viewing this topic.

Maximus-Sniper

  • Guest
Add script into cpp file
« on: 23 Jul 2004, 01:28:38 »
Hei
How di i add script files into my cpp file to work???
And where inn the cpp file so i put it in?
And what should i write inn cpp file?
I will add a bulletcamera to my addon. If not i have to copy all those files into my mission ebery time and make some trigger and use the radio to Turn on and off the bulletcamera, how do i get it to work inn my cpp file??

I got two script to work but not the bullet cam script its about 4 files in the bullet cam, init.sqs, fired.sqs, PosBullCam.sqf and description.ext How do i do that to get them all to work.. take a look:

.
.
.
.
class UserActions
      {
      class Selfheal
      {
         displayName = "First Aid";
         position = "axisgoggles";
         radius = 1.00000;
         condition = "(Format [{%1},BaB_heal] != {false}) && (player == this)";
         statement = "this exec {\bab\script\heal.sqs}";
      };
      class sniperslow
      {
         displayName = "Sniper Slow";
         position = "axisgoggles";
         radius = 1.00000;
         condition = "(Format [{%1},sniper_slow] != {false}) && (player == this)";
         statement = "this exec {\bab\script\sniperslow.sqs}";
      };
      class sniperbulletcam
      {
         displayName = "Sniper Bullet Camera";
         position = "axisgoggles";
         radius = 1.00000;
         condition = "(Format [{%1},sniper_bullet_camera] != {false}) && (player == this)";
         statement = "this exec {\bab\script\init.sqs}";
      };
.
.
.
.
Can i load more tha one file? And how, how do i fix this problem??

please help
« Last Edit: 23 Jul 2004, 04:37:11 by Maximus-Sniper »

Offline Peter_Bullet

  • Members
  • *
  • "The evil that men do lives on and on"
Re:Add script into cpp file
« Reply #1 on: 23 Jul 2004, 07:13:11 »
Okay, so, are you asking that how do you add BulletCamera script to your config?  ???

If so, I can help... you need an eventhandlers class inside your vehicle class  :P. Here is an example:


      class EventHandlers
      {
         Init=[_this select 0]exec "\Epl_Gr3\Scripts\Init.sqs";
      }; //End the class EventHandlers

If you want bullet camera, you just change the "Init" with "Fired" And after that you type the parameters and the path, like above (In the script, remember to use the parameter "_this select 0" as the unit...  8)

I hope this helps.... If not, let me know! ;)
« Last Edit: 23 Jul 2004, 07:16:25 by Epeli »

Maximus-Sniper

  • Guest
Re:Add script into cpp file
« Reply #2 on: 23 Jul 2004, 10:20:18 »
tnx man :)

I put so this line into my vehicle class:

class EventHandlers
      {
      init=[_this select 0] exec "\BAB\Scripts\Init.sqs"; then {_this call loadFile ""\BAB\script\load.sqf""};
      };

and i use call loadfile .....
because its 3 more files in that bullet camera script i got from this site (bullet camera v1.2)

take a look inside my load.sqs file:

_this call loadFile "\BAB\script\PosBullCam.sqf";
_this call loadFile "\BAB\script\description.ext";
_this call loadFile "\BAB\script\fired.sqs"

so i hope its correct???

Offline Peter_Bullet

  • Members
  • *
  • "The evil that men do lives on and on"
Re:Add script into cpp file
« Reply #3 on: 23 Jul 2004, 13:25:53 »
I'm sorry dude, but I know nothing of how you write function files, so I'm not sure...  :-[ Though that's the way how you execute the script... Though I recommend using the event fired like:

      class EventHandlers
      {
         Fired=[_this select 0]exec "\Epl_Gr3\Scripts\Fired.sqs";
      }; //End the class EventHandlers

Then you just script the Camera effect and stuff inside the Fired.sqs script... But I know nothing about functions, they seemed too complicated when I looked at snypir's tutorial a while ago....  :-[

Unnamed

  • Guest
Re:Add script into cpp file
« Reply #4 on: 23 Jul 2004, 22:22:45 »
Hi,

For the event handlers use this instead:

Code: [Select]
class EventHandlers
      {
      init="[_this select 0] exec ""\BAB\Scripts\Init.sqs"" ; MyFUnction call loadFile ""\BAB\script\load.sqf""";
      };

Eventhandles called from the cpp are strings so you have:

Code: [Select]
class EventHandlers
{
Init="";
};

Any quotes you use within that string need to be doubled up:

Code: [Select]
class EventHandlers
{
Init="MyName=""Buba""";
};

Loadfile loads up a function into a global variable, without pre-processing it. So it will not be as fast as a function loaded with PreProcess. BTW you can only load functions within a cpp using LoadFile. To load your function into a variable called MyFunction use this:

Code: [Select]
init="[_this select 0] exec ""\BAB\Scripts\Init.sqs"" ; MyFunction=loadFile ""\BAB\script\load.sqf"" ; [""Buba""] Call MyFunction";

You can only use LoadFile with *.sqf files. You cant use it with *.sqs or *.ext files.

Description.ext can not be included in your addon, you will have to copy that manually into your mission folder. Your sqs files can be included, but you just call them the same way you call any other script.
Code: [Select]
Code: [Select]

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:Add script into cpp file
« Reply #5 on: 23 Jul 2004, 23:16:06 »
Ok, I know I'm not helping much, but I just need to comment on a couple of things... :P

Quote
You can only use LoadFile with *.sqf files. You cant use it with *.sqs or *.ext files.
I beg to differ...

You can use call loadFile on *.sqs, but there's some to be noted; the *.sqs is treated as sort of semi-function, so ~ delays won't work (as they don't in functions), but you don't need the ; at the sentences end, as you do in functions...

(Actually if I remember correctly you can preprocessFile *sqs's too...)

But that's in the mission editor, not in the config....

And, you can include description.ext in your addon, but not as *.ext... (I'm not sure that the whole description.ext would be wise to be distributed in an addon anyway...)

But, you can include for example the class titleRsc portion of the description ext (or dialogs) by using a file called *.h..

So you can include yay_my_titleRsc.h in your addon. Then it's used in a mission by including it (like in C, C++...) by adding this to the missions description.ext:
#include <addon_pbo_name\yay_my_titleRsc.h>

But, if the mission maker is already using titleRsc, that cannot be used.
Same goes for dialogs...

So with this method you should be able include a whole description.ext into an addon (as unwise as it could be)...

Quote
Loadfile loads up a function into a global variable, without pre-processing it. So it will not be as fast as a function loaded with PreProcess.
I'm not so sure about this... OFP does not have compiler for it's scripting language...

loadFile does have a bug though... You can not have any   comments like:  //  /**/  or comment "Blah blah" in your functions... It will result in 'Unknown Operator' errors...
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Unnamed

  • Guest
Re:Add script into cpp file
« Reply #6 on: 24 Jul 2004, 02:38:33 »
Quote
I beg to differ...
You can use call loadFile on *.sqs, but there's some to be noted; the *.sqs is treated as sort of semi-function, so ~ delays won't work (as they don't in functions), but you don't need the ; at the sentences end, as you do in functions...

I was trying to keep it simple. Unless Maximus really wants to ask about strings and the call function, but was to shy to come right out and say it :)

Quote
So with this method you should be able include a whole description.ext into an addon (as unwise as it could be)...

You can include any files you want into an addon. But Description.ext will not be called from within it, its called from the mission folder. So there is little point in including it, unless its just for reference?

Maximus-Sniper

  • Guest
Re:Add script into cpp file
« Reply #7 on: 24 Jul 2004, 02:54:16 »
Tnx for all help, i got it work like 50% :)
I canche a bit in my init.sqs :

player addaction ["Bullet camera on","\Bab\script\TrackEryx.sqs"]
player  addEventHandler ["fired",{_this exec "\Bab\script\fired.sqs"}]

track = false

PosBullcam = preprocessFile  "PosBullCam.sqf"

validation = false

Please help if you see something wrong

Then a chance a bit in fired.sqs:

_Missile = nearestObject [vehicle(player), _this select 4]
? 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.5
#SkipSlowEnd
_cam cameraeffect ["terminate", "back"]
 camdestroy _cam
closedialog 0
setAccTime 1
exit

help if something is wrong her

Then a use a another script from another bullet cam (TrackEryx.sqs) :

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

use it to got the Bullet Cam on and Off in the user menu in game.. If work help need :)

The i past the worse file :(  PosBullCam.sqf ) :

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   ]];

got lot of error in upper screen in game. But this work if i copy this in to ,y mission folder.. How do i add this in my addon.???  
And my load.sqf look like this:

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

i'am not sure if this are correct.


About the description.ext, then i have allwas to copy inn mission folder, but thats ok..If i gor every thing to work i only need to copy one file into mission folder.. thats ok, but only need a help for the rest of the files over here..
Tnx allot again for the help i got :)

So how do the class eventhandles look if somebody got it to work??
Here is mine:

class EventHandlers
            {
         Â Â Â init="[_this select 0] exec ""\BAB\Script\Init.sqs"" ; MyFunction=loadFile ""\BAB\script\PosBullCam.sqf"" ; [""Buba""] Call MyFunction";
      };


do i have to change something here???

Tnx for your all answares and help... it's work like 50% better than 0% :)


BACK AGAIN :)

It'a seems to be 80% ok now, i Only got one error: I still have to copy PosBullCam.sqf  into my mission folder :(
How do i add the PosBullCam.sqf file into my addon???

I only change a bit inn init.sqs:

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

track = false

PosBullcam = preprocessFile  "PosBullCam.sqf"

validation = false


And set back the orginal fired.sqs:

_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.5
#SkipSlowEnd
_cam cameraeffect ["terminate", "back"]
 camdestroy _cam
closedialog 0
setAccTime 1
exit

So how do i fix the PosBullCam.sqf into my addon and cpp file????

If i remove the PosBullCa,.sqf from my mission folder i got this error before i got into my mission : "script PosBullCam.sqf not found"

How do i fix that?? I dont want to copy the file into my mission folder every time a make a new mission..

Someone have a answare??
Please help me
« Last Edit: 24 Jul 2004, 04:16:52 by Maximus-Sniper »

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:Add script into cpp file
« Reply #8 on: 24 Jul 2004, 08:13:02 »
Quote
got lot of error in upper screen in game. But this work if i copy this in to ,y mission folder.. How do i add this in my addon.???
You have that MyFunction=loadFile ""\BAB\script\PosBullCam.sqf"", right?
That is actually exactly the same as MyFunction = preprocessFile "possBullCam.sqf" in your mission...
So, you should rename that MyFunction to PosBullcam :)
That should take care of the problem...

You may got a bit confused from the Unnamed's and my posts above; the loadFile does exactly the same as the preprocessFile does... (you can use loadFile instead of preprocessFile in missions too, with no probs other than the bug I mentioned...)

So if you have MyFunction=loadFile ""\BAB\script\PosBullCam.sqf"" in your cpp in some unit init eventHandler, you will have a function called MyFunction to use when ever that unit in is the mission...

Oh, and remove the line [""Buba""] Call MyFunction from the eventHandler because that was just Unnamed's example, nothing to do with your addon and you don't even need to call that function from there... :)
What Unnamed meant was that you can call the function from the init EH if you need to...

Quote
About the description.ext, then i have allwas to copy inn mission folder, but thats ok
Yes, it would be much wiser to keep it this way, it's common use anyways...

As I said, you could easily include the whole description.ext in your AddOn, but it has that side effect of overriding the mission makers description.ext...
So if you have Dialogs configed in the description.ext and the mission maker also uses dialogs, there will most likely be a CTD which annoys the hell out of everybody :) ...

So keep the description.ext as a separate file...

Quote
So there is little point in including it, unless its just for reference?
[offtopic]
Well, the next MCAR beta will include a usage of this ::)
Very pointless one, but still.. ;D

There're 'add banners' you can use in missions if you want to be a 'MCAR Team KissAss' ;D ;D ;D
[/offtopic]
« Last Edit: 24 Jul 2004, 08:18:40 by HateR_Kint »
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Maximus-Sniper

  • Guest
Re:Add script into cpp file
« Reply #9 on: 24 Jul 2004, 12:10:33 »
Hei|
First of all I will thanks you all guys for heelping me :)

This class evenhandles work perfect :)

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

I'll thank you all again :)

I only have the description.ext file again, but i see that it would be hard to get work... :)
But if someone like to work with that, i' will be very thankfull....
Or how do I put this description.ext into another mission description.ext???
:)

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:Add script into cpp file
« Reply #10 on: 24 Jul 2004, 21:57:35 »
You better keep the description.ext as a separate file in your addon zip/rar/whatever...

Much easier and reduces the chances of description.ext conflicts...
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Maximus-Sniper

  • Guest
Re:Add script into cpp file
« Reply #11 on: 25 Jul 2004, 01:24:40 »
Hi HateR_Kint
Yes i understand that.
But if i want to edit a new mission, exsemple if i download a mission and i want to put my description.ext info to the new mission description.ext, but how?? I was trying to cop.y the info from my description.ext into the missions description.ext, but dosen't work.
And i have to use the description.ext form my bulletcam to work.
How do i do that to get the new mission to work??

Unnamed

  • Guest
Re:Add script into cpp file
« Reply #12 on: 25 Jul 2004, 03:19:04 »
Quote
Well, the next MCAR beta will include a usage of this
Very pointless one, but still..

Huh...MCar has an entire Description.ext file in the addon, used to override the mission Description.ext?

Quote
As I said, you could easily include the whole description.ext in your AddOn, but it has that side effect of overriding the mission makers description.ext...

Wow..After the numerous post I read saying you cant call dialogs from addons I'm a bit suprised. I know about include files e.t.c bit U thought you still had to call the dialogs from the missions Description.ext?

I cant help thinking how problematic it would be for OFP to have to check every addon for a description.ext.

If more than one addon is used, which description.ext is used and in what order?

Are each of the Description.ext files included in these addons all executed one after another?

Most files in addons are given a specific path, does OFP differ when it comes to Description.ext?

I could understand it looking in the default mission directory when the mission starts, and including Description.ext in a mission pbo. And I know you can declare somethings like sounds\identities in both Addons and Description.ext.

But this addon version of Description.ext appears to be the exception to the rule?

Where in danger of going off topic (in not already), perhaps you could write a tutorial?

I dont think I have read\seen anything along these lines on any of the forums, in fact they generaly say the opposite. If I remember correctly?

Cheers
« Last Edit: 25 Jul 2004, 03:35:12 by Unnamed »

Maximus-Sniper

  • Guest
Re:Add script into cpp file
« Reply #13 on: 25 Jul 2004, 03:57:47 »
Hei all :)

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 :

#include <my_addon\sniper.h>

i read it on one of the post frome HateR_Kint :)

So i will now thank you all guys for heelping me.
Cya all, maybe a found another problem some day  ::)

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:Add script into cpp file
« Reply #14 on: 25 Jul 2004, 14:18:48 »
Quote
Huh...MCar has an entire Description.ext file in the addon, used to override the mission Description.ext?
No... It's just a *.h that has a few titleRsc 's 'coded' in it and it's just included in some missions description.ext with #include, just like M-S has now done with his bullet cam...
But that has one downside (also warning to you M-S) that if someone uses his/her own titleRsc (dialogs in your case M-S?) in his/her mission you can not use the #include because it causes at least 'member already defined' errors if not CTD...

That's why we have the titleRsc code also available as separate file so if someone already uses his/her own he/she can copy/paste only the MCAR relevant stuff to his/her description.ext...

So that's why Maximus-Sniper, you should also include the *.h you use as a separate file too...

Quote
Wow..After the numerous post I read saying you cant call dialogs from addons I'm a bit suprised. I know about include files e.t.c bit U thought you still had to call the dialogs from the missions Description.ext?
No no... You've misundertsood me...
You still need to preprocess the *.h in the missions description.ext by using the #include... As you already know...

So, no, you can not call a dialog straight from any *.pbo, you still need to 'call' it via a missions description.ext...

So you have not read misinformation... I just explained the stuff poorly (again, as usual ;) )...
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

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 :)