OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: 22jacket on 29 May 2006, 23:38:34

Title: working in multiplayer
Post by: 22jacket on 29 May 2006, 23:38:34
Hi..I have got a script..where targets get shot..drop down and then pop back up,,but i cannot get it to work in multiplayer..can any one help...

script below..

?!(local server):exit
_targ = _this select 0
_x = getpos _targ select 0
_y = getpos _targ select 1
_type = typeof _targ
_dir = getdir _targ

~5
deletevehicle _targ

_newtarg = _type camcreate [_x, _y, 0.9]
_newtarg addeventhandler ["killed",{_this exec "popup.sqs"}]
_newtarg setdir _dir
_newtarg setdamage 0.8

exit
Title: Re: working in multiplayer
Post by: nominesine on 30 May 2006, 11:37:23
What is not working? What happens when you run the script? What should happen? How do you execute the script? If you give a little more information it might be possible to help you.
Title: Re: working in multiplayer
Post by: 22jacket on 30 May 2006, 16:20:22
hi...sorry about that,...the script makes a target go down when shot..then come back up 5 secs later..when in multiplayer...i can see them..pop up and down when shot..but the other players shoot once and cannot see the target come back up......any ideas..
Title: Re: working in multiplayer
Post by: subroc on 30 May 2006, 16:51:14
the camCreate is a local command and doesnÂ't work in multiplayer, try using createVehicle instead.
Title: Re: working in multiplayer
Post by: 22jacket on 30 May 2006, 16:55:49
do i just delete camcreate and insert create vehicle and save...
Title: Re: working in multiplayer
Post by: bedges on 30 May 2006, 17:17:22
yup...

Code: [Select]
?!(local server):exit
_targ = _this select 0
_x = getpos _targ select 0
_y = getpos _targ select 1
_type = typeof _targ
_dir = getdir _targ

~5
deletevehicle _targ

_newtarg = _type createvehicle [_x, _y, 0.9]
_newtarg addeventhandler ["killed",{_this exec "popup.sqs"}]
_newtarg setdir _dir
_newtarg setdamage 0.8

exit

whether or not it works is another matter entirely... ;)
Title: Re: working in multiplayer
Post by: 22jacket on 30 May 2006, 22:17:27
no joy..tried i with the same results...
Title: Re: working in multiplayer
Post by: Garcia on 31 May 2006, 08:14:45
if you are trying to create a unit use createunit instead...
Title: Re: working in multiplayer
Post by: 22jacket on 31 May 2006, 14:45:11
all i want to do is get a target E to come up and down when shot...with a 5-10 second interval.....or just reset the targets when they have been shot at...
Title: Re: working in multiplayer
Post by: Garcia on 31 May 2006, 16:37:52
well, does it work in multiplayer?...errm, of course I mean does it work in editor when you try it, or doesn't it work at all?
Title: Re: working in multiplayer
Post by: 22jacket on 31 May 2006, 21:26:32
it works in editor and online..but only i can see the targets coming back up...when i played with other players..once they shoot down a target they casnnot see it any more..but i can ???
Title: Re: working in multiplayer
Post by: Seven on 01 Jun 2006, 15:19:50
Do you have a GameLogic on your map called server?
Title: Re: working in multiplayer
Post by: Flaber on 01 Jun 2006, 15:53:56
There is no need to delete and create the targetE, you only have to setDammage to 0 or 0.x the targetE

I have a firing camp and when you go close to a soldier (with and addAction) he popup the targets using setdammage.


I can give you the script if you want.. ah.. and work 100% in mp.




Title: Re: working in multiplayer
Post by: 22jacket on 01 Jun 2006, 19:31:29
 that would be great cheers...cheers/...thank you...u can get me at jacket11@htomail.com
once again thanks
jacket
Title: Re: working in multiplayer
Post by: Flaber on 02 Jun 2006, 01:23:17
I prefer to left the script here, so anybody can use it.

In this case there are 6 firing camps (sniper ..mg ..... )

Things to take care of:
- each targetE has a var name, use your owns to identify each target.
in this case ... for "campo1" the var names of the targetE objects are:
ac_1
ac_2
ac_3
....
- As you can see i have use two ways to respawn the targets...
one by one (ac_1 SetDammage 0.0;)

and using and array of objects with a foreach sentence:
_ldra4 = [ra_31,ra_32,ra_33,ra_34,ra_35,ra_36,ra_37,ra_38,ra_39]

"_x setDammage 0.0" foreach _ldra4

this second one is more clean :D

If there is something that you don't understand.. please ask.. I'll try to do my best with my english.


Code: [Select]
; *****************************************************
; ** Autor: Flaber
; ** - 13ª Compañia TigerSharks -
; ** web: www.mtpstudios.net - www.ffaa.es
; *****************************************************
; ** Campo de tiro
; *****************************************************
; ** Ejecución del script (Execution)
; ** [_campo] exec "CampoDeTiro.sqs";
; ** Ejemplo (Example)
; ** [1] exec "CampoDeTiro.sqs";
; *****************************************************
; ** Necesitas una variable logica llamada "server"
; ** Hay varios campos de tiro, llama al script indicando el campo de tiro del que quieres levantar la dianas.
; ** cada campo de tiro tiene los nombres de las dianas que se corresponden.
; *****************************************************
; ** You Need a gameLogic called "server"
; ** There a few firing camps, call the script saying the firing camp whos targets will pop up
; ** Each firing camp has the var names of the targets which compose the camp.
; *****************************************************

_campo = _this select 0;

?!local server : goto "end" ;

? (_campo == 1): goto "campo1";
? (_campo == 2): goto "campo2";
? (_campo == 3): goto "campo3";
? (_campo == 4): goto "campo4";
? (_campo == 5): goto "campo5";
? (_campo == 6): goto "campo6";

; Campo de tiro de pistola (Pistol Firing Camp)
#campo1
ac_1 SetDammage 0.0;
ac_2 SetDammage 0.0;
ac_3 SetDammage 0.0;
ac_4 SetDammage 0.0;
ac_5 SetDammage 0.0;
ac_6 SetDammage 0.0;
ac_7 SetDammage 0.0;
ac_8 SetDammage 0.0;
ac_9 SetDammage 0.0;
ac_10 SetDammage 0.0;


goto "end"

; Campo de tiro Francotirador (Sniper Firing Camp)
#campo2
fr_1 SetDammage 0.0;
fr_2 SetDammage 0.0;
fr_3 SetDammage 0.0;
fr_4 SetDammage 0.0;
fr_5 SetDammage 0.0;
fr_6 SetDammage 0.0;
fr_7 SetDammage 0.0;
goto "end"

; Campo de tiro MA1A1 (Tank Firing Camp)
#campo3
bl1 SetDammage 0.0;
bl2 SetDammage 0.0;
bl3 SetDammage 0.0;
bl4 SetDammage 0.0;
bl5 SetDammage 0.0;
bl6 SetDammage 0.0;
goto "end"

; Campo de tiro Ametralladora pesada (MG Firing Camp)
#campo4
mg_1 SetDammage 0.0;
mg_2 SetDammage 0.0;
mg_3 SetDammage 0.0;
mg_4 SetDammage 0.0;
mg_5 SetDammage 0.0;
mg_6 SetDammage 0.0;
mg_7 SetDammage 0.0;
mg_8 SetDammage 0.0;
mg_9 SetDammage 0.0;
mg_10 SetDammage 0.0;
goto "end"

; Campo de tiro sub-fusil
#campo5
_ldra1 = [ra_1,ra_2,ra_3,ra_4,ra_5,ra_6,ra_7,ra_8,ra_9]
_ldra2 = [ra_11,ra_12,ra_13,ra_14,ra_15,ra_16,ra_17,ra_18,ra_19]
_ldra3 = [ra_21,ra_22,ra_23,ra_24,ra_25,ra_26,ra_27,ra_28,ra_29]

"_x setDammage 0.0" foreach _ldra1
"_x setDammage 0.0" foreach _ldra2
"_x setDammage 0.0" foreach _ldra3

goto "end"

; Campo de tiro fusil
#campo6
_ldra4 = [ra_31,ra_32,ra_33,ra_34,ra_35,ra_36,ra_37,ra_38,ra_39]
_ldra5 = [ra_41,ra_42,ra_43,ra_44,ra_45,ra_46,ra_47,ra_48,ra_49]
_ldra6 = [ra_51,ra_52,ra_53,ra_54,ra_55,ra_56,ra_57,ra_58,ra_59]

"_x setDammage 0.0" foreach _ldra4
"_x setDammage 0.0" foreach _ldra5
"_x setDammage 0.0" foreach _ldra6
goto "end"

#end
exit