Jump to content
Sign in to follow this  
DBR_ONIX

Trigger external program from within OFP..?http://

Recommended Posts

hi,

at first...thick praise on Kegetys and vectorbosson for this great work: -)

with this awesome tool some things are possible.

I have try a simple however complete script to generate with fwatch (only an example).

in the editor I placed 3 objects and by a script the type, the position and the direction was determined.

from this a text was then formatted and written with fwatch into the file named testscript.sqs

here the result:

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

_a=|;----------------------------

_a=|; Script created by fwatch

_a=|; Testscript.sqs / 21.07.2005

_a=|; Silola [Mapfact.net]

_a=|;----------------------------

_a=|

_a=|_obj = {TMYK_TCS01GL01} createvehicle [0,0,0]

_a=|_obj setpos [5425.5,6023.35,-0.071434]

_a=|_obj setdir 351.987

_a=|~0.1

_a=|_obj = {TMYK_TCS02GL01} createvehicle [0,0,0]

_a=|_obj setpos [5405.17,6055.36,-0.5]

_a=|_obj setdir 0

_a=|~0.1

_a=|_obj = {TMYK_TCS22GL01} createvehicle [0,0,0]

_a=|_obj setpos [5444.65,6054.58,-0.5]

_a=|_obj setdir 136.425

_a=|~1

_a=|exit

now only the string "_a=|" removed.

this can be done with a normal text editor with one operation.

then, testscript.sqs looks like this:

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

;----------------------------

; Script created by fwatch

; Testscript.sqs / 21.07.2005

; Silola [Mapfact.net]

;----------------------------

_obj = {TMYK_TCS01GL01} createvehicle [0,0,0]

_obj setpos [5425.5,6023.35,-0.071434]

_obj setdir 351.987

~0.1

_obj = {TMYK_TCS02GL01} createvehicle [0,0,0]

_obj setpos [5405.17,6055.36,-0.5]

_obj setdir 0

~0.1

_obj = {TMYK_TCS22GL01} createvehicle [0,0,0]

_obj setpos [5444.65,6054.58,-0.5]

_obj setdir 136.425

~0.1

exit

at the end, the script is finished and can be used.

realy cool: -)

thx again and bye

silola [ mapfact.net ]

Share this post


Link to post
Share on other sites

I suggest you add SQL connection code to the program. That would be great wink_o.gif

Please do that...

Share this post


Link to post
Share on other sites

Hmm, being able to connect to a database would mean putting a server/username/password in the misison, no? Unless it was entered in a dialouge by someone (host/admin). Not ideal.. It's easier to use FWATCH to create a file, and create a simple program to read this data, change it into a query and run that, or oposite way around (Get data, save to file and read with FWATCH)

As for the saving objects script, why not store the objects in an FWATCH file via one script, then read them back and setpos the objects using the data? That way no editing is needed

So :

myObjectPOS=[123,421,1]

myObjectDIR=141

myObjectHLT=0.4

You can generate the varible name with

FORMAT ["%1POS",name _object] smile_o.gif

- Ben

Share this post


Link to post
Share on other sites
Hmm, being able to connect to a database would mean putting a server/username/password in the misison, no? Unless it was entered in a dialouge by someone (host/admin). Not ideal..

That is not exactly true. The server owner could easily create a private addon that he adds to his dedicated server, the addon containing the necessary logins and passwords, then he would do this when wishing to connect to the database:

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

?(server != local this) : exit

[] exec "/dbaddon/connect.sqs"

While at it the addon could also abstract the sql calls...

The result set could then be accessed by many different ways:

1. From global space.

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

["SELECT * FROM players"] exec "/dbaddon/query.sqs"

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

SQL_Resultset = loadfile ":sql ""SELECT * FROM players"" ";// or something similar depending on how its implemented in the external program...

2. By passing the value straight on

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

_resultset = ["SELECT * FROM players"] loadfile "/dbaddon/query.sqf";// dunno if functions can be called from addons but thats not the point to get arguing about...

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

_resultset = loadfile ":sql ""SELECT * FROM players"" ";

_resultset

As far as i understand it would be really easy to add the mysql c api to fwatch, testdll or any other clone for someone even less genius than many on this board. Unfortunately im not that experienced with compiling c/c++ programs so i didnt manage to do it myself (also a proof of my geniousity)...

Share this post


Link to post
Share on other sites

this approch needs definately more attention once ArmA is out ...

there are so many great things you can do with this thumbs-up.gif

Share this post


Link to post
Share on other sites

I have no idea how these things work so this probably goes in the 'stupid questions bin', but anyway icon_rolleyes.gif

Would it be in any way possible to 'link' Fwatch with DXDLL so that you could for example 'detect' the DXDLL FPS output (which it prints on the screen) and use that value in some script?

Share this post


Link to post
Share on other sites
Would it be in any way possible to 'link' Fwatch with DXDLL so that you could for example 'detect' the DXDLL FPS output (which it prints on the screen) and use that value in some script?

Yes but you can get the FPS easier by running a script that waits one frame and measures how long it took.

Share this post


Link to post
Share on other sites

It'd be easier using

HINT FORMAT ["%1",loadfile ":fps"]

no?

Hmm, on the subject of DXDLL > FWATCH connection, how about a way of changing the settings from inside a script?

Like when you get nearly hit by a grenade, your screen goes very glowy (Glare at full etc).

Or when you die, your screen goes B/W etc (Just examples, theres many uses tounge2.gif)

- Ben

Share this post


Link to post
Share on other sites
It'd be easier using

HINT FORMAT ["%1",loadfile ":fps"]

no?

No because for that to work the user would need fwatch (a version where such would be implemented) and that would be pointless when you can do the same thing without adding that dependency, for example something like:

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

_t = time

~0.001

hint format["%1", 1/(time - _t)]

should work (unless the fps is higher than 1000). You're better off spending a bit more time in development to save the users from having to install dozens of things to get your mission/script working.

A "dxdll + fwatch" like combination could allow much more interesting things though, like drawing functions that would allow drawing basic shapes directly into textures that could be used to do HUD's or MFD's etc.

Share this post


Link to post
Share on other sites

I just noticed a cheating possibilty that should probably be noted.

What if i edit the fwatch\data\true.sqf

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

true

Share this post


Link to post
Share on other sites

It could be interesting to have something like FWatch call a script engine where FWatch could parse the 'command' to know what script file to load and then pass that any remaining parameters.

From there of course, the script would be expected to return a valid .sqs file, but internally, you could have it do any type of work you wanted.

Something like Python, Perl or even VBScript.

The mind boggles.

Share this post


Link to post
Share on other sites
A "dxdll + fwatch" like combination could allow much more interesting things though, like drawing functions that would allow drawing basic shapes directly into textures that could be used to do HUD's or MFD's etc.

Funny.... I was going to suggest the exact same thing. If there were a way to essentially make resource overlays on the screen that could be changed during play (unlike normal OFP resources), then there would be a whole lot of doors opened. Especially if there was easy access to the OFP fonts and resource shapes, so that the 'fake' resources would look just like 'real' ones. I actually have a very specific use for this if it is ever implemented.

Another essential feature would be the ability to run an external program, as well as pass it parameters. In addition, including some way for this external program to return data to OFP would just be perfect.

Perhaps it is already there and I just missed it, but that didn't seem to be included. Obviously Fwatch does this already (e.g. "wget.exe"), but to make the function publically available would allow anyone to add whatever functionality to Fwatch they could dream up, without you having to do it all yourself wink_o.gif.

Quote[/b] ]Something like Python, Perl or even VBScript.

The mind boggles.

Someone at OFPEC was supposedly working on a complier that would translate C++ into OFP script, but I don't know what ever happened to it...

------

That said, since this topic seems to be dug up once more: is there any new word on either of these tools? I've started editing with Fwatch, but since it hasn't really been 'officially' released, I'm hesitant to use it too much. I haven't really used Vektorboson's tool, since it isn't as 'neatly packaged' as Fwatch is.

Either way, perhaps a new thread should be started for Fwatch and/or Vektorboson's tool?

Share this post


Link to post
Share on other sites

Another essential feature would be the ability to run an external program, as well as pass it parameters. In addition, including some way for this external program to return data to OFP would just be perfect.

To extend functionality, my personal approach was/is to create an API, so you could create DLLs which were loaded by my version.

Regarding external programs: You would have to do some kind of query, whether the external program has delivered the data/has terminated. But I think this shouldn't be too complicated with some kind of stub script that returns false/true.

Quote[/b] ]That said, since this topic seems to be dug up once more: is there any new word on either of these tools? I've started editing with Fwatch, but since it hasn't really been 'officially' released, I'm hesitant to use it too much. I haven't really used Vektorboson's tool, since it isn't as 'neatly packaged' as Fwatch is.

Either way, perhaps a new thread should be started for Fwatch and/or Vektorboson's tool?

When I get around in the far future to finish my tool, I'll make my own thread. And I think that fwatch was released "officialy" it being on OFP.info.

The question is, whether this approach of "hacking" OFP will still be possible with ArmAss, as I guess every modder will switch to ArmAss. So perhaps there isn't any sense in finishing it at all.

Share this post


Link to post
Share on other sites

ive got a problem with fwatch

the CNC mod has created a new building system for CNC CTI where you can build your buildings with a GUI menu and easy put it on the ground because it is following the mouse cursor.

now they have send me the scripts and ive tested it on my own comp. but the fwatch.exe isnt be able to get my mouse pos.

tested it with some player sidechat and have seen that the mouse position stucked on [640,512, true,false,false].

why is the fwatch.exe only on my comp not working huh.gif

using w2k SP4 system

AMD Athlon 64bit 3000+

786 MB DDR 400

Omega drivers for Radeon 9800 XT

FLASHPOINTBETA.EXE (1.96)

Kerio Personal Firewall

fwatch.exe -mod=... -mod=... -nosplash

pls help me!

PS: i will try the log thing and send you the file later @Keg

btw you have created a fantastic program smile_o.gif

Share this post


Link to post
Share on other sites
ive got a problem with fwatch

the CNC mod has created a new building system for CNC CTI where you can build your buildings with a GUI menu and easy put it on the ground because it is following the mouse cursor.

now they have send me the scripts and ive tested it on my own comp. but the fwatch.exe isnt be able to get my mouse pos.

tested it with some player sidechat and have seen that the mouse position stucked on [640,512, true,false,false].

why is the fwatch.exe only on my comp not working huh.gif

using w2k SP4 system

AMD Athlon 64bit 3000+

786 MB DDR 400

Omega drivers for Radeon 9800 XT

FLASHPOINTBETA.EXE (1.96)

Kerio Personal Firewall

fwatch.exe -mod=... -mod=... -nosplash

pls help me!

PS: i will try the log thing and send you the file later @Keg

btw you have created a fantastic program smile_o.gif

The mouse is very quickly recentered, what speed is the loop that checks the mouse position?

Try lowering it, see if the value changes

Thats a nice idea, using the mouse to move the buildings around.. I hated placing buildings in CTI tounge2.gif

- Ben

Share this post


Link to post
Share on other sites

it gots a small delay but thats not the matter because the script is working on T-Ds comp perfectly.

only my comp cant get the values.

*tested in ingame editor

Share this post


Link to post
Share on other sites

I think that the FWatch is hooking to flashpointresistance.exe so you could try to rename the game executable... This is just a quick guess wink_o.gif

Share this post


Link to post
Share on other sites

hmm when im using loadfile command is the fwatch.exe activated so fwatch can send me the vars [512,640,true,false,false] but why cant it detect my mouse?

are you sure that it will help to rename FLASHPOINTBETA to FLASHPOINTRESISTANCE?

im at work so i cant test it in this mom

Share this post


Link to post
Share on other sites

Nah, if FWATCH is mainly working, it's not the problem

He means if you have the 1.96 beta patch, and Fwatch launches FlashpointResistance (Say v1.46) it'll screw up, but you can rename the BETA file to the Reisistance.exe one, and it'll work

Not sure why it's not working, you have the most recent (Or same version as the other person) of Fwatch?

Tried redownloading it?

Thats all I can think of confused_o.gif

oh, do other Fwatch commands work okay, yeh?

- Ben

Share this post


Link to post
Share on other sites

hum tested everything changed resolution to 1024x786 75 Hz

windows 72Hz

tested Kegs diagnostic script everything was working especially the getmouse not

hmmm sad_o.gif

*edit: disabled firewall too position now constantly 512,384 sad_o.gif

Share this post


Link to post
Share on other sites

sry Keg for the big logfile

here one piece of it:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">fwatch: NewCreateFileA Users\[G-R] Jack Hammersmith\missions\killarea.Intro\:input getmouse 0 1 3

fwatch: NewCreateFileA Users\[G-R] Jack Hammersmith\scripts\:input getmouse 0 1 3

fwatch: NewCreateFileA scripts\:input getmouse 0 1 3

fwatch: filecheck

fwatch: filecheck return handle 1508

fwatch: NewCreateFileA scripts\:input getmouse 128 1 3

fwatch: command: input getmouse

fwatch: HandleCommand input getmouse, nomap 0

fwatch: HandleCommand created file C:\DOKUME~1\JACKHA~1.JAC\LOKALE~1\Temp\FWT34B.tmp

fwatch: ParseScript input getmouse, C:\DOKUME~1\JACKHA~1.JAC\LOKALE~1\Temp\FWT34B.tmp

fwatch: watchFile C:\DOKUME~1\JACKHA~1.JAC\LOKALE~1\Temp\FWT34B.tmp

fwatch: watchFile deleted C:\DOKUME~1\JACKHA~1.JAC\LOKALE~1\Temp\FWT34B.tmp

Share this post


Link to post
Share on other sites

I dont know what those exe files are that you sent me, but the log file doesnt really tell anything useful anyway since fwatch is working fine (Except that you are not using -nomap as instructed in the readme file). The getmouse function uses the GetCursorPos Win32 API function, I dont know why it wouldn't work for you though.

Share this post


Link to post
Share on other sites

Do you have access to another PC, or can send it to someone else to see if it works there?

To find out whether it's your PC or the mission that's stoping it working?

- Ben

Share this post


Link to post
Share on other sites

its my pc because i havent written the script.

T_D has created this script and it is working fine on his machine.

have seen a video of it where he moves his mouse and the building changed its position,

@Keg i have sent you one rar file 800KB it was 50MB unpacked dont ask me why,

it looks like my new browser has destroyed it. huh.gif

is it ok when i send you another version zipped?

Share this post


Link to post
Share on other sites

BTW, you REALLY should use the "-nomap" parameter. I forgot to turn it on at first, and Keg's Race mission ran like poop. Once I re-read the readme, and put that parameter in there, it suddenly ran just fine. Who knows... perhaps the lag from not having -nomap is causing your problems?

Oh yeah, that made me remember one more suggestion I had thought of for Kegetys: You should put some sort of "timeout" on the 'wget' function!

The first couple times I tried to play Fwatch Race, Flashpoint froze up on me and I had to reboot my computer. I finally realized that my firewall was blocking the traffic, and waiting for me to okay it. I guess OFP completely freezes when waiting for the results of a function, so since it was waiting for a response from the "wget" function (which was being blocked by my firewall), then it basically froze completely. This makes me wonder what would happen if someone wasn't connected to the internet at all, or was on a very slow dialup connection. Would their computer freeze like mine did? If this is the case, then having the function 'timeout' and return some sort of error code after a fixed delay would seem proper.

Just my 2 cents. smile_o.gif

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  

×