Home   Help Search Login Register  

Author Topic: Global variables problem  (Read 1541 times)

0 Members and 2 Guests are viewing this topic.

newb

  • Guest
Global variables problem
« 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

Offline Gnat

  • Addons Depot
  • Former Staff
  • ****
  • I Bite!
    • Gnats
Re:Global variables problem
« Reply #1 on: 13 Jan 2005, 12:38:25 »
Without a bit of your code, can't really see what the problem is.

Have you assigned the variable somewhere ?
Like:
Code: [Select]
publicvariable "Zcount".

newb

  • Guest
Re:Global variables problem
« Reply #2 on: 13 Jan 2005, 15:33:57 »
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.

Offline Gnat

  • Addons Depot
  • Former Staff
  • ****
  • I Bite!
    • Gnats
Re:Global variables problem
« Reply #3 on: 13 Jan 2005, 16:24:32 »
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.

Code: [Select]
; *****************************************************
; ** 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.

newb

  • Guest
Re:Global variables problem
« Reply #4 on: 14 Jan 2005, 03:59:52 »
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?

newb

  • Guest
Re:Global variables problem
« Reply #5 on: 14 Jan 2005, 09:19:25 »
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?

newb

  • Guest
Re:Global variables problem
« Reply #6 on: 14 Jan 2005, 09:50:35 »
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***!