Harkonin 0 Posted October 30, 2003 K I've got a script thats titled delete.sqf but its actually a script. The goal of this script is to delete dead units but leave their weapons. Now heres the problem, it works in SP but in MP its only working Server side. I.E. - you see ammo on the map but when you get there its empty space.Much thanks if anyone can help me execute this client side. Heres the script - _Deadguy = _this select 0 _mags = magazines _Deadguy _guns = weapons _Deadguy _magcount = count magazines _corpse _guncount = count weapons _corpse @ delete ~100 ? (getDammage _Deadguy <= 0) : exit _wpnh = "weaponholder" createVehicle [(getPos _Deadguy select 0) - 2 + (random 2*2),(getPos _Deadguy select 1) - 2 + (random 2*2),0] _c = 0 while "_c <= (_magcount - 1)" do {_wpnh addmagazineCargo [format ["%1",(_mags select _c)],1]; _c = _c + 1} _c = 0 while "_c <= (_guncount - 1)" do {_wpnh addweaponCargo [format ["%1",(_guns select _c)],1]; _c = _c + 1} deleteVehicle _Deadguy exit Share this post Link to post Share on other sites
Harkonin 0 Posted October 31, 2003 24 views and nobody knows? Killswitch where are you dude, lol. Share this post Link to post Share on other sites
bmgarcangel 0 Posted October 31, 2003 So, You're deleting the soldier, then creating in his place magazines, right Share this post Link to post Share on other sites
raedor 8 Posted October 31, 2003 i think you make this with killed EH, right? then read this (official comref): Quote[/b] ]MP notes: "Killed" and "Hit" event handlers are executed where given unit is local. and when is delete true? Share this post Link to post Share on other sites
raedor 8 Posted October 31, 2003 first script (opened with killed EH):<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">#start ? ! isNull deadMan: goTo "else" deadMan = _this select 0 publicVariable "deadMan" exit #else ~random 1 goTo "start" second script (opened in init.sqs):<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">#start ~1 ? isNull deadMan: goTo "start" deadMan exec "script3.sqs" deadMan = objNull publicVariable "deadMan" goTo "start" third script:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _deadguy = _this _mags = magazines _Deadguy _guns = weapons _Deadguy _magcount = count magazines _deadguy _guncount = count weapons _deadguy ~100 ? (getDammage _Deadguy < 0.95): exit _wpnh = "weaponholder" createVehicle [(getPos _Deadguy select 0) - 2 + (random 2*2),(getPos _Deadguy select 1) - 2 + (random 2*2),0] _c = 0 while "_c <= (_magcount - 1)" do {_wpnh addmagazineCargo [format ["%1",(_mags select _c)],1]; _c = _c + 1} _c = 0 while "_c <= (_guncount - 1)" do {_wpnh addweaponCargo [format ["%1",(_guns select _c)],1]; _c = _c + 1} ? ! local _deadguy: exit deleteVehicle _Deadguy exit this line in init.sqs (additionaly to the opening of the second script):<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">deadMan = objNull not tested... Share this post Link to post Share on other sites
bmgarcangel 0 Posted October 31, 2003 man oh man. I hate very advanced looking scripts. In reality, it looks pretty good man. Going to try it out right now, even though......I didn't ask for it hehe Share this post Link to post Share on other sites
Harkonin 0 Posted October 31, 2003 Delete is the condition of when the action takes place. @delete means whenever delete = true to execute. Share this post Link to post Share on other sites
raedor 8 Posted November 1, 2003 k, then put the<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">@deleteline in the third script, before ~100. does this work like you want? Share this post Link to post Share on other sites
Harkonin 0 Posted November 1, 2003 No the original script was fine the only problemis executing globally. You've got the right idea but the first two scripts are a waste of cpu cycles that continuously loop. And with this format its still not global. Wheres Killswitch when you need him? Got a nice bottle of Dalwhinnie here........... Share this post Link to post Share on other sites
crashdome 3 Posted November 1, 2003 You probably knew this, but.... addweaponcargo and addmagazinecargo are local only IF you can publicVariable an array of integers that represent items... i.e make a table: 0=M16 1=AK47 2=AK74 etc... and publicVariable an array such as weapons=[1,2,3,4,5] you are set The only other way is to maybe capture "magazines _DeadGuy" on each machine before you delete the body, but I am not sure if that will return anything if the units aren't local to the machine..... This is a tough one.... Share this post Link to post Share on other sites
RED 0 Posted November 1, 2003 You could use the CoC network service to transmit the string names of each weapon to all clients. RED Share this post Link to post Share on other sites
raedor 8 Posted November 1, 2003 you cant publicvariable arrays... the second script is global, cos it's opened in init.sqs. and you have only one loop, and that's in this second script... maybe "weapons" and "magazines" does not work, when the corpse is not local. then you'd have to make 4 more variables to give kind of weapons, number of weapons, kind of ammo and number of ammo to the clients. Share this post Link to post Share on other sites
RED 0 Posted November 1, 2003 You can public variable arrays with the CoC network service RED Share this post Link to post Share on other sites
raedor 8 Posted November 1, 2003 oh yes, this looks good. but 4 new variables will work properly, too. Share this post Link to post Share on other sites
crashdome 3 Posted November 2, 2003 you cant publicvariable arrays... you're right.. sorry, I've been using CoC_NS for too long.... Share this post Link to post Share on other sites
raedor 8 Posted November 2, 2003 hehe, in germany nobody writes NS as a short form for a longer word: this means Nationalsozialismus... Share this post Link to post Share on other sites
killswitch 19 Posted November 2, 2003 Hmm... would this do it: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> ; ; ammosprinkler.sqs ; ; Usage ; ; [unit] exec "ammosprinkler.sqs" ; ; Or, to prevent the deletion of the dead corpse (possibly due to having some ; other nifty script do it ; ; [unit, false] exec "ammosprinkler.sqs" ; ; Some constants. Edit them to your liking ; Name of this script. If you choose to rename it, change _THISSCRIPT ; to the same name. Default: "ammosprinkler.sqs" _THISSCRIPT = "ammosprinkler.sqs" ; How long before the corpse is removed and the ammo is created where it was _REMOVEDELAY = 100 ; The "wait until unit is dead"-loop delay _DEADDELAY = 1 ; The "search for a WeaponHolder" loop delay and search timeout _SEARCHDELAY = 1 _SEARCHTIMEOUT = 20 ;----------------------------------------------------------------------------------- ; No need to edit below this ;----------------------------------------------------------------------------------- ?(count _this == 0 && local player): hint "Error: "+ _THISSCRIPT + " called with no parameters! Exiting."; exit ?(count _this == 0): exit _dude = _this select 0 _bDelete = true ; Someone is possibly overriding the default value for deleting the dead body ?count _this > 1: _bDelete = _this select 1 ; Script is called with all three parameters. Jump to the label indicated by ; the third parameter. ?count _this > 2: goto (_this select 2) #init ?local _dude: [_dude, _bDelete, "local"] exec _THISSCRIPT; exit [_dude, _bDelete, "nonlocal"] exec _THISSCRIPT exit #local #localwait ~_DEADDELAY ?alive _dude: goto "localwait" _wpns = weapons _dude _mags = magazines _dude _magcount = count _mags _wpncount = count _wpns ~_REMOVEDELAY ?(getDammage _dude < 0.95): exit _pos = getPos _dude _wpnh = "WeaponHolder" createVehicle _pos _c = 0 while "_c < _magcount" do {_wpnh addMagazineCargo [format ["%1",(_mags select _c)],1]; _c = _c + 1} _c = 0 while "_c < _wpncount" do {_wpnh addWeaponCargo [format ["%1",(_wpns select _c)],1]; _c = _c + 1} ~(2+_SEARCHTIMEOUT) ?(!isNull _dude && _bDelete): deleteVehicle _dude ; all done locally exit #nonlocal #nonlocalwait ~_DEADDELAY ?alive _dude: goto "nonlocalwait" _wpns = weapons _dude _mags = magazines _dude _magcount = count _mags _wpncount = count _wpns ~_REMOVEDELAY ?(getDammage _dude < 0.95): exit ; On the machine where the unit was local, a WeaponHolder is created. Here, we ; just wait for it to appear and snag it. _tstamp = _time _timeout = _tstamp + _SEARCHTIMEOUT #nlloop ~_SEARCHDELAY _wpnh = nearestObject [_dude, "WeaponHolder"] ?((_time < _timeout) && isNull _wpnh): goto "nlloop" ; Just a failsafe: Did we get it? If not, just give up, exit and hope some other dead soldier ; will generate a proper ammo pile for players to loot. ?isNull _wpnh: exit ; Ok, we have a WeaponHolder created on some other machine where _dude was local. ; If its empty, fill it to spec. If it isn't empty, it probably means ; that some other guy died nearby and we got hold of that one instead. ; If so, TS - just give that holder even more ammo. _c = 0 while "_c <= (_magcount - 1)" do {_wpnh addmagazineCargo [format ["%1",(_mags select _c)],1]; _c = _c + 1} _c = 0 while "_c <= (_wpncount - 1)" do {_wpnh addweaponCargo [format ["%1",(_wpns select _c)],1]; _c = _c + 1} ; all done non-locally exit That contraption monitors units both locally and everywhere else. When unit dies, it sleeps for _REMOVEDELAY seconds and then replaces the corpse with a WeaponHolder and fills it with the weapons and magazines the deceased had at the time of his demise. I have only briefly tested it by starting both a dedicated server and a client on my computer. This means that the script hasn't been properly tested under adverse conditions, i.e. with network delays and all that real life stuff that scripts succumb to. NB: If a new guy respawns, he needs to have that script attached to him again, both remotely and locally. How to do that is left as an exercise... Ok, pick it apart, bash it, abuse it and see if you can make it suit your needs. Peace, out! Share this post Link to post Share on other sites
Harkonin 0 Posted November 2, 2003 Christ I'm gonna have to get you a case of your favorite Single Malt for Christmas. CHEERS! Share this post Link to post Share on other sites
Chill 0 Posted November 2, 2003 How can you make a trigger that deletes all the dead bodies inside a trigger area? Share this post Link to post Share on other sites
Chill 0 Posted November 7, 2003 Ok!! do you type "easy" into the activation field? lol Share this post Link to post Share on other sites
Harkonin 0 Posted November 8, 2003 no you type #start ?(Wanteasy == 0):goto"answer" #answer goto "start" lol Share this post Link to post Share on other sites