OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: newb on 13 Jan 2005, 10:43:04
-
Can anyone help me figure out why my global variables wont get updated on other comps when i run a script?
for example:
Comp A runs a script that adds 1 ebonum
but in comp B it doesnt get added.
I know i gota use some server client script but can anyone teach me? cause im a complete newb on this.
If you dont have the time at least tell me where i can look for it. cause im kinda in a pinch and i need to find out how to solve this fast.
Thanx, cheers
-
Without a bit of your code, can't really see what the problem is.
Have you assigned the variable somewhere ?
Like:
publicvariable "Zcount".
-
I stored
Artynum
Flagnum
FSOnum
in the init.sqs
I assigned them to all values of 0 and when i try to change either variables to 1 on comp A, the number isnt updated on comp B
i use a hint to print Artynum and etc... but it shows that the changes are only made on comp A
I have colleague that tells me i should put those global variables in a server script and have the clients update the variables through a loop. Unfortunately my weak programmer mind can hardly grasp the concept of that solution without a good reference or guidance.
Please try your best to help me. I need this solved by monday or im toast.
thank you for your time.
-
Still not enough information.
1) Make sure you have a GAME LOGIC trigger on your map named "server"
2) Make another trigger, called ONCE, that calls this script below.
; *****************************************************
; ** Operation Flashpoint Script File
; *****************************************************
Zcount = 0
#loop
?!(local server) : goto "Client_and_Server"
;------------ Client computers skip this bit
;------------ This part only runs on the Server
#Server_Only
NowSet = false
~5 ; wait 5 secs on the server
Zcount = Zcount + 1
publicvariable "Zcount"
publicvariable "NowSet"
NowSet = true
;---------------------------------------------
;------------ This part runs of all computers
#Client_and_Server
; the client computers will each wait until NowSet is True
; NowSet is made TRUE only by the server
; the server makes the NowSet variable public also
; the Zcount variable, also public, only has 1 added on the server
; but is "passed" to each client to read also
@NowSet ; wait for the server to set true (approx ever 5 secs)
titletext[format ["The Count is: %1", Zcount], "Plain down"]
goto "loop" ; both server and clients go back to start again
;---------------------------------------------
I havent tested but should work. But really its only to demonstrate the basics of Server-to-Client communications.
-
hey thanx for the help. the publicvariable function worked for me.
Here are a few line of codes:
_flag = FUPflag
?(player != BSO): hint "Unauthorized Action!"
?(player != BSO || BSOnum > 1):exit
?(player == BSO && Flagnum == 1): goto "blue"
?(player == BSO && Flagnum == 2): goto "green"
exit
#blue
_flag setflagtexture "Green.jpg";
Flagnum = Flagnum + 1;
exit
#green
_flag setflagtexture "Blue.jpg";
Flagnum = Flagnum - 1;
publicvariable "Flagnum"
publicvariable "FUPflag"
exit
::::end of codes::::
FUPflag is a flag pole that suppose to have a flag when it is initially planted at a location on the map but the puzzling thing is that when i swap the flag on 1 comp, it does not show any changes on the other, secondly is that when the flag swapper swaps the flag, the change can be seen and only for like 2 seconds, then the flag disappears.
Any idea whats causing this?
-
oh yeah i was told that my flag texture is only updated on the client side but not on the server. erm i looked through the flag & scoring system tute and i didnt really understand it.
http/www.ofpec.com/editors/resource_view.php?id=89
for example:
how does the script tell all the clients to synch with the server and then back again..
initially i thought public variable would have done the trick but somehow it does not update the textures applied onto the flag pole.
am i missing something?
-
alright problem solved...
bloody f***. I should have known. Its cause i used a jpg file instead of a .pac file.
gawd.. all this stress and work over something so idiotic is really unsatisfying.
F***!