Home   Help Search Login Register  

Author Topic: Server side \ local side scripting  (Read 1391 times)

0 Members and 1 Guest are viewing this topic.

Offline franj

  • Members
  • *
Server side \ local side scripting
« on: 01 Apr 2007, 18:37:22 »
Hi all
this is my first post here, i really hope someone can help me!

i created a shooting range in MP with two scripts:

Code: [Select]
puntuacion =0
cualificacion =0

Hint format["bienvenido al campo de tiro de DSF"]
~5
hint format["esta ronda es de familiarizacion asi que gasta todo el cargador disparando a los blancos"]
~7
hint format["Preparado!"]
b1 setdammage 1
b2 setdammage 1
b3 setdammage 1
b4 setdammage 1
b5 setdammage 1
b6 setdammage 1
b7 setdammage 1
b8 setdammage 1

#inicio
~15

b1 setdammage .7
~1
#bucle_b1
?(!alive b1) : goto "salto_b1"
?!someammo recluta : goto "fin"
~1
goto "bucle_b1"
#salto_b1
puntuacion = puntuacion + 1
~1
hint format ["puntuacion %1", puntuacion]
~5
b2 setdammage .7
~1
#bucle_b2
?(!alive b2) : goto "salto_b2"
?!someammo recluta : goto "fin"
~1
goto "bucle_b2"
#salto_b2
puntuacion = puntuacion + 1
~1
hint format ["puntuacion %1", puntuacion]
~5
b3 setdammage .7
~1
#bucle_b3
?(!alive b3) : goto "salto_b3"
?!someammo recluta : goto "fin"
~1
goto "bucle_b3"
#salto_b3
puntuacion = puntuacion + 1
~1
hint format ["puntuacion %1", puntuacion]
~5
b4 setdammage .7
~1
#bucle_b4
?(!alive b4) : goto "salto_b4"
?!someammo recluta : goto "fin"
~1
goto "bucle_b4"
#salto_b4
puntuacion = puntuacion + 1
~1
hint format ["puntuacion %1", puntuacion]
~5
b5 setdammage .7
~1
#bucle_b5
?(!alive b5) : goto "salto_b5"
?!someammo recluta : goto "fin"
~1
goto "bucle_b5"
#salto_b5
puntuacion = puntuacion + 1
~1
hint format ["puntuacion %1", puntuacion]
~5
b6 setdammage .7
~1
#bucle_b6
?(!alive b6) : goto "salto_b6"
?!someammo recluta : goto "fin"
~1
goto "bucle_b6"
#salto_b6
puntuacion = puntuacion + 1
~1
hint format ["puntuacion %1", puntuacion]
~5
b7 setdammage .7
~1
#bucle_b7
?(!alive b7) : goto "salto_b7"
?!someammo recluta : goto "fin"
~1
goto "bucle_b7"
#salto_b7
puntuacion = puntuacion + 1
~1
hint format ["puntuacion %1", puntuacion]
~5
b8 setdammage .7
~1
#bucle_b8
?(!alive b8) : goto "salto_b8"
?!someammo recluta : goto "fin"
~1
goto "bucle_b8"
#salto_b8
puntuacion = puntuacion + 1
~1
hint format ["puntuacion %1", puntuacion]
~5
#fin
recluta exec "cualificacion.sqs"
exit

this one is the first one

and the second one is the same, a bit different...
the problem is...
i intented to run only in one machine meanswhile the other is only observing, but the script runs in both clients causing problemas with targets (where only must have one target poping up, theres two)

any idea?

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Server side \ local side scripting
« Reply #1 on: 01 Apr 2007, 21:11:44 »
Include a gamelogic, name it whatever you want (for example, server) and at the beginning of your script include:
Code: [Select]
?!local server:exit
GLs are only locals for the server, so you may use this criteria for force scripts to run only on the server side.

But then you are using hints, and hint command is local to the machine where you execute it, so only the server would see hints.
puntuacion is a global var, you may public it (publicVariable varName) command.

You may have scripts that executes, but only in client sides waiting for changes in this var (compare its value with its old value stored somewhere else), if puntuation changes, then you show the hint.

BTW, I'm not really the most adequate one to talk about MP  :whistle:

Offline sharkattack

  • Former Staff
  • ****
Re: Server side \ local side scripting
« Reply #2 on: 02 Apr 2007, 19:35:12 »
i found this helpfull

http://www.ofpec.com/forum/index.php?topic=28815.0

worth a look
"HOLY SARDINE" - see Shark-Attack meet his match

Offline franj

  • Members
  • *
Re: Server side \ local side scripting
« Reply #3 on: 02 Apr 2007, 22:53:15 »
hlpful a lot!
but i cant manage to work :(

i try to explain better the situation:
I have a shooting range with 8 targets, an ammo box with an M16 and one mag, and two guys. Recruit and supervisor. with this post i put a gamelogic too with the code u told me.

the game logic names "server" and has this code
Code: [Select]
?(local server):[] exec "inicio.sqs"
code for inicion:
Code: [Select]
puntuacion =0
cualificacion=0

publicVariable "puntuacion"
publicVariable "cualificacion"

~1
removeallweapons recluta
removeallweapons Supervisor
~1
b1 setdammage 1
b2 setdammage 1
b3 setdammage 1
b4 setdammage 1
b5 setdammage 1
b6 setdammage 1
b7 setdammage 1
b8 setdammage 1

#inicio
~30

b1 setdammage .7
~1
#bucle_b1
?(!alive b1) : goto "salto_b1"
?!someammo recluta : goto "fin"
~1
goto "bucle_b1"
#salto_b1
puntuacion = puntuacion + 1
~1
b2 setdammage .7
~1
#bucle_b2
?(!alive b2) : goto "salto_b2"
?!someammo recluta : goto "fin"
~1
goto "bucle_b2"
#salto_b2
puntuacion = puntuacion + 1
b3 setdammage .7
~1
#bucle_b3
?(!alive b3) : goto "salto_b3"
?!someammo recluta : goto "fin"
~1
goto "bucle_b3"
#salto_b3
puntuacion = puntuacion + 1
~5
b4 setdammage .7
~1
#bucle_b4
?(!alive b4) : goto "salto_b4"
?!someammo recluta : goto "fin"
~1
goto "bucle_b4"
#salto_b4
puntuacion = puntuacion + 1
~5
b5 setdammage .7
~1
#bucle_b5
?(!alive b5) : goto "salto_b5"
?!someammo recluta : goto "fin"
~1
goto "bucle_b5"
#salto_b5
puntuacion = puntuacion + 1
~5
b6 setdammage .7
~1
#bucle_b6
?(!alive b6) : goto "salto_b6"
?!someammo recluta : goto "fin"
~1
goto "bucle_b6"
#salto_b6
puntuacion = puntuacion + 1
~5
b7 setdammage .7
~1
#bucle_b7
?(!alive b7) : goto "salto_b7"
?!someammo recluta : goto "fin"
~1
goto "bucle_b7"
#salto_b7
puntuacion = puntuacion + 1
~5
b8 setdammage .7
~1
#bucle_b8
?(!alive b8) : goto "salto_b8"
?!someammo recluta : goto "fin"
~1
goto "bucle_b8"
#salto_b8
puntuacion = puntuacion + 1
~5
#fin
[] exec "cualificacion.sqs"

code for cualificacion
Code: [Select]
recluta RemoveMagazine "20Rnd_556x45_Stanag"
recluta addmagazine "20Rnd_556x45_Stanag"
~10
puntuacion =0
cualificacion =0

publicVariable "puntuacion"
publicVariable "cualificacion"


b1 setdammage 1
b2 setdammage 1
b3 setdammage 1
b4 setdammage 1
b5 setdammage 1
b6 setdammage 1
b7 setdammage 1
b8 setdammage 1
#random
~10
_ran = random 8

?(_ran <= 1): goto "b1"
?(1 < _ran) && (_ran <= 2): goto "b2"
?(2 < _ran) && (_ran <= 3): goto "b3"
?(3 < _ran) && (_ran <= 4): goto "b4"
?(4 < _ran) && (_ran <= 5): goto "b5"
?(5 < _ran) && (_ran <= 6): goto "b6"
?(7 < _ran) && (_ran <= 8): goto "b7"
?(_ran <= 8): goto "b8"

#b1
b1 setdammage .7
~1
#bucle_b1
?(!alive b1) : goto "salto_b1"
?!someammo recluta : goto "fin"
~1
goto "bucle_b1"
#salto_b1
puntuacion = puntuacion + 1
~1
goto "random"
~5

#b2
b2 setdammage .7
~1
#bucle_b2
?(!alive b2) : goto "salto_b2"
?!someammo recluta : goto "fin"
~1
goto "bucle_b2"
#salto_b2
puntuacion = puntuacion + 1
~1
goto "random"
~5

#b3
b3 setdammage .7
~1
#bucle_b3
?(!alive b3) : goto "salto_b3"
?!someammo recluta : goto "fin"
~1
goto "bucle_b3"
#salto_b3
puntuacion = puntuacion + 1
~1
goto "random"
~5

#b4
b4 setdammage .7
~1
#bucle_b4
?(!alive b4) : goto "salto_b4"
?!someammo recluta : goto "fin"
~1
goto "bucle_b4"
#salto_b4
puntuacion = puntuacion + 1
~1
goto "random"
~5

#b5
b5 setdammage .7
~1
#bucle_b5
?(!alive b5) : goto "salto_b5"
?!someammo recluta : goto "fin"
~1
goto "bucle_b5"
#salto_b5
puntuacion = puntuacion + 1
~1
goto "random"
~5

#b6
b6 setdammage .7
~1
#bucle_b6
?(!alive b6) : goto "salto_b6"
?!someammo recluta : goto "fin"
~1
goto "bucle_b6"
#salto_b6
puntuacion = puntuacion + 1
~1
goto "random"
~5

#b7
b7 setdammage .7
~1
#bucle_b7
?(!alive b7) : goto "salto_b7"
?!someammo recluta : goto "fin"
~1
goto "bucle_b7"
#salto_b7
puntuacion = puntuacion + 1
~1
goto "random"
~5

#b8
b8 setdammage .7
~1
#bucle_b8
?(!alive b8) : goto "salto_b8"
?!someammo recluta : goto "fin"
~1
goto "bucle_b8"
#salto_b8
puntuacion = puntuacion + 1
~1
goto "random"
~5
#fin
publicvariable "porcentaje"
porcentaje = puntuacion * 100 / 20
~10

exit

and i created a code lines for the two players can see the score:

Code: [Select]
#inicio
hint format["puntuacion %1",puntuacion]
~5
hint format["cualificacion %1",cualificacion]
~5
?porcentaje < 1:goto "cualificacion"
goto "inicio"
#cualificacion
~1
hint format["cualificacion %1 sobre 100",porcentaje]
~5
exit

and almost work, but not completely, when i run the game in offline mode it works, except the part where i need to show the porcentaje, in online, it works, but the cose seems to not work propertly.

Hope it helps to see better the problem

Cheers!