Home   Help Search Login Register  

Author Topic: Money > For East Side Kill  (Read 2678 times)

0 Members and 2 Guests are viewing this topic.

Offline Silent Sniper

  • Members
  • *
  • I hired a hitman to kill my llama
Money > For East Side Kill
« on: 26 Jul 2006, 02:59:41 »
Hey, im making a mission which spawns in units on the east side, for each east unit that the player kills they gain say.. £50
Im wondering how i would go about this, remember these east units are being camcreated. not placed in the editor and they will keep spawning in in waves. i might need help with camcreation aswell with this.

i used the search if this has already been asked, i couldnt find anything on this.
« Last Edit: 26 Jul 2006, 03:10:44 by Silent Sniper »
If you havent played ofp you havent lived

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Money > For East Side Kill
« Reply #1 on: 26 Jul 2006, 03:26:45 »
First of all camCreated enemies will not provide much of a challenge, you better use createUnit instead.  :)

Just add a "KILLED" event handler to each unit as it is created.  The createUnit command allows this.  The event handler reports who has been killed and by whom and can execute a script to increment the killer's score.

« Last Edit: 26 Jul 2006, 03:28:43 by Mr.Peanut »
urp!

Offline Silent Sniper

  • Members
  • *
  • I hired a hitman to kill my llama
Re: Money > For East Side Kill
« Reply #2 on: 26 Jul 2006, 04:21:02 »
ok thanks for that, but ive never used event handlers before, im a bit useless at scripting looking through the COMREF and stuff but im hopeless
*Edit*
looking at Event Handlers from Igor's tut, any other help is welcomed.
*Edit 2*
Event handlers would do the job but this is a multiplayer mission and it says its not compatible with them
« Last Edit: 26 Jul 2006, 04:27:37 by Silent Sniper »
If you havent played ofp you havent lived

Offline Silent Sniper

  • Members
  • *
  • I hired a hitman to kill my llama
Re: Money > For East Side Kill
« Reply #3 on: 26 Jul 2006, 15:13:39 »
Right i desperatley need help with this, this is what i have so far,

The addons needed are
ECP
Beans zombies
editorupgrade102

and i think objects1 by kegetys not sure on that one tho,
alot of these scripts are modifcations of D Murphy mans money tut mission so creds to him on that.
if necessary i wouldnt mind making it a joint money pool that all the players share, aslong as this becomes a working MP mission.
If you havent played ofp you havent lived

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Money > For East Side Kill
« Reply #4 on: 26 Jul 2006, 20:17:42 »
What you are trying to do is similar to any scoring system in MP, for which there are many examples in the forums. There are also many examples of respawn scripts. I am presuming this is a COOP mission where east side kills zombies.

Since enemy zombie  units are AI and belong to the server, the "KILLED" eventhandler will fire on the server.

This is your zomres1.sqs
Code: [Select]
; *****************************************************
; ** Operation Flashpoint Script File
; *****************************************************

#zomres
"z_1" createUnit [getMarkerPos "zomres1", groupzom]
this AddEventHandler ["killed",{_this exec "enemykill.sqs"}]
~15
goto "zomres"
exit

Issues:
1) in MP want createUnit command run on server only. Add a game logic to your mission and name it server. Then add if not (local server) then {exit} to the top of scripts to be run on server only.
2) you are adding a zombie to group groupzom every 15 seconds.  You will soon have more than the 12 units per group allowed. Count number of living members in group and respawn if less than 12.

So instead try:
zombspawn.sqs
Code: [Select]
; *****************************************************
; ** Operation Flashpoint Script File
; *****************************************************
if not(local server) then {exit}
_grp = _this select 0
_pos = _this select 1
;I've never used zombie addon so just add all types of zombies to array below
_z_types = ["z_1","z_2","z_3",...]
_nz_types = count _z_types
#loop
~2
if (({alive _x} count units _grp) == 12) then {goto "loop"}
#spawnloop
_z_n = random _nz_types
_z_n = _z_n  - (_z_n % 1)
(_z_types select _z_n) createUnit [_pos, _grp,{this addEventHandler ["killed",{_this exec "enemykill.sqs"}]},0.5,"PRIVATE"]
~1
if (({alive _x} count units _grp) < 12) then {goto "spawnloop"}
goto "loop"
exit

Now you just have to add one zombie leader for each zombie group you want and put the following in its init field:
Code: [Select]
[group this, getMarkerPos "zomres1"] exec "zombspawn.sqs"
Make sure you have added a game logic named server to the mission.

Now for enemykill.sqs
Code: [Select]
_moneyernt=25
playercounter=playercounter+_moneyernt
exit
The thing to keep in mind in MP is that each player can have a different value for playercounter, so the group pool must be communicated via the publicVariable command.  playercounter will be the pooled funds.

enemykill.sqs
Code: [Select]
_moneyernt=25
playercounter = playercounter + _moneyernt
publicVariable "playercounter"
exit

There are other issues in MP.  With the addAction command,  the action happens only on the machine of the player who did the action, so your removeAction command will only remove the action on the one players machine. Also, all hints will only display on one player's machine.

The best model for MP is to define a bunch of flags, and then use triggers and publicVariable to make sure everything works okay.  Here is an example. In your init.sqs
Code: [Select]
ss_displayfunds = FALSEThen put a trigger on your map with condition ss_displayfunds. In activation put
Code: [Select]
hint format ["%1 pounds remaining",playercounter]; ss_displayfunds = FALSEThen anywhere in any of your scripts when you want all players to see remaining funds insert the following:
Code: [Select]
ss_displayfunds = TRUE
publicVariable "ss_displayfunds"

A similar system should be used for adding/removing actions and positioning the sandbags to make sure all players see the same thing. Here is another example. In your init.sqs
Code: [Select]
ss_sand1 = FALSE
Then put a trigger on your map with condition ss_sand1. In activation put
Code: [Select]
[] exec "buysand1.sqs"; ss_sand1 = FALSE

And in your mission itself the init for defhq:
Code: [Select]
sandbg1=defhq addaction ["Level 1 Sandbags [£250]","buysand1_cmd.sqs"]
Then you also need this script buysand1_cmd.sqs
Code: [Select]
ss_sand1 = TRUE
publicVariable "ss_sand1"

Now the flag variable ss_sand1 will be set to true on all machines, and the trigger will run the script buysand1.sqs on all machines.  This guarantees that for all players: the group funds are the same, the hints are displayed, the buy sandbag type 1 action is removed, and the sandbags are repositioned.l

« Last Edit: 27 Jul 2006, 00:08:31 by Mr.Peanut »
urp!

Offline Silent Sniper

  • Members
  • *
  • I hired a hitman to kill my llama
Re: Money > For East Side Kill
« Reply #5 on: 26 Jul 2006, 21:24:23 »
just testing now mate thanks a million, ill get back on it with the results.

Right i get two errors with the new zombspawn script,
1) _pos this select 0 expected type boolean or something
2) (z_types select _z_n) createUnit [_pos, _grp,"this AddEventHandler ["killed",{_this exec "enemykill.sqs"}] unknown operator killed

any ideas? i havent tested the new server sided varibles in MP yet i will when i get the chance but they should be fine

hang on posted just after your edit ill try the rest of it out now.
« Last Edit: 26 Jul 2006, 21:45:57 by Silent Sniper »
If you havent played ofp you havent lived

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Money > For East Side Kill
« Reply #6 on: 26 Jul 2006, 21:43:36 »
Better make sure you are using the last edits I just put up. I am notorious for reposting to fix bugs.

Edit:Just added a few missing underscores before variables.. try again...
« Last Edit: 26 Jul 2006, 21:52:04 by Mr.Peanut »
urp!

Offline Silent Sniper

  • Members
  • *
  • I hired a hitman to kill my llama
Re: Money > For East Side Kill
« Reply #7 on: 26 Jul 2006, 22:27:58 »
one error down one to go

(_z_types select _z_n) createUnit [_pos, _grp,"this addEventHandler ["|#|killed",{_this exec "enemykill.sqs"}]"] Error unknown operator "killed"

thats how the message comes up, i cant see why it should tho, killed is a proper event handler that ive been using before?
If you havent played ofp you havent lived

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Money > For East Side Kill
« Reply #8 on: 26 Jul 2006, 22:30:25 »
That just means that there is a generic syntax error in there somewhere. Better try putting it as {killed} instead of "killed".

Also if you put
Code: [Select]
hint format["%1",(_z_types select _z_n)] on the line before the createUnit what do you get?
« Last Edit: 26 Jul 2006, 22:34:43 by Mr.Peanut »
urp!

Offline Silent Sniper

  • Members
  • *
  • I hired a hitman to kill my llama
Re: Money > For East Side Kill
« Reply #9 on: 26 Jul 2006, 22:42:58 »
ok now the zombies are spawning like crazy which is nice thanks a bunch.

but getting this error now _this exec [enemykill|#|.sqs] unknown operator enemykill

syntax error again? if so i dunno how i could fix that since the script complains if its not like that but now its complains that it cant excute with it like that when a zombie is killed

this happens when a new spawned zombie is killed.
btw i get the z_1 to z_3 appear in a hint depending on which one spawns when i put that in before the createunit
« Last Edit: 26 Jul 2006, 22:47:48 by Silent Sniper »
If you havent played ofp you havent lived

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Money > For East Side Kill
« Reply #10 on: 26 Jul 2006, 23:55:46 »
Well, better make it {enemykill.sqs} instead of "enemykill.sqs".  Or if that does not work then ""enemykill.sqs"".

Well better make it:
Code: [Select]
{this addEventHandler ["killed",{_this exec "enemykill.sqs"}]}
I just searched the forums and this is how it should be used.  It might also require two more arguments:
Code: [Select]
... createUnit [_pos,_grp,{this addEventHandler ["killed",{_this exec "enemykill.sqs"}]},0.5,"PRIVATE"]
Where 0.5 is the skill (0-1) and "PRIVATE" is the rank. Can use other ranks too.



« Last Edit: 27 Jul 2006, 00:07:01 by Mr.Peanut »
urp!

Offline Silent Sniper

  • Members
  • *
  • I hired a hitman to kill my llama
Re: Money > For East Side Kill
« Reply #11 on: 27 Jul 2006, 00:37:45 »
now it works an absolute treat thanks so much you've helped me loads, basically done it for me which i feel bad about, thank you for your time ;)
still gotta test in MP tho but hopefully that should be fine thanks to all the effort you made.
a true OFPEC member 8)
if i have any other bugs that i cant fix which i hope i dont ill post em here, gonna goto bed in a min :)

Going on holiday for 2 weeks in a day so you wont hear from me but i may be back at this after that.
« Last Edit: 27 Jul 2006, 03:19:31 by Silent Sniper »
If you havent played ofp you havent lived

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Money > For East Side Kill
« Reply #12 on: 27 Jul 2006, 04:06:56 »
No problem. 
urp!