Results 1 to 10 of 10

  Click here to go to the first Developer post in this thread.  

Thread: this addeventhandler Problems!

  1. #1
    Im making a map where I want 1000 points for killing a soldier and 10000 for killing a tank.

    I put in this in the init file on both.

    this addeventhandler ["Hit",{[_this select 1] exec "Hit.sqs"}]

    this addeventhandler ["Hit",{[_this select 1] exec "Hit3.sqs"}]

    hit.sqs = soldiers sqs file
    hit3.sqs = tanks sqs file

    hit.sqs
    ?!(player==_this select 0):exit
    Hint "test2"
    player addScore 1000
    exit

    hit3.sqs
    ?!(player==_this select 0):exit
    Hint "test2"
    player addScore 10000
    exit


    On my own server i can get it to work. (MP) But when i upload it to a dedicated. I only recive the 1000 points for the soldier i killed. It wont give me any points for the tank getting killed. (tank=bmp in this case)

    I have a game logic named Server. I tried to use this command on the tank. But it stop working both on dedi server and mine.
    this addeventhandler ["Hit",{server call{[_this select 1] exec "Hit3.sqs"}}]

    Plz help me

    Cain
    Don't give me that same old pack of lies
    I'll tell you the story how it really is
    Want me to carry on?

  2. #2
    Chief Warrant Officer
    Join Date
    Oct 12 2001
    Location
    Vermont , USA
    Posts
    3,160
    Quote from Comref:


    <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
    MP notes&#58; &#34;Killed&#34; and &#34;Hit&#34; event handlers are executed where given unit is local. All other event handlers are executed on all computers. Events added by addEventHandler may be different on each computer
    [/QUOTE]

  3. #3
    Staff Sergeant
    Join Date
    Nov 6 2002
    Location
    Sweden
    Posts
    362
    Author of the Thread
    Hmm, So these scrips are local? hmm i dont get it.

    But why does the Hit work on Soldiers but not on tanks and other vehicles? if i works on soldiers it should work on other things too.

  4. #4
    Hello cain2001&#33;

    *** *** As per snYpir&#39;s OFPEC Guide: Multiplayer Editing available here, this is what he had to say about eventhandlers:

    Quote Originally Posted by [b
    Quote[/b] ]snYpir&#39;s MP editing rule 7: Be prepared for a great deal of pain if you start handling events (especially player-activated ones such as map clicks) in multiplayer. Remember that map clicks are local, and as such the server will need to be notified (via publicvariable of course) that a map click has occurred, and the position of the click.
    Read this tutorial and you may find a way to get it to work. That is about all the help that I can be, if I was any help at all&#33;

    *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** Wadmann
    Check out my Camouflage collection&#33; Now with more tiger stripe&#33; Updated 31 July 2005.

  5. #5
    Quote Originally Posted by (cain2001 @ July 20 2004,20:00)
    Hmm, So these scrips are local? hmm i dont get it.

    But why does the Hit work on Soldiers but not on tanks and other vehicles? if i works on soldiers it should work on other things too.
    From what I remember, hit only works when vehicles get hit by explosive rounds.

    RED

  6.   This is the last Developer post in this thread.   #6
    BI Developer Suma's Avatar
    Join Date
    Jun 27 2001
    Location
    Czech Republic
    Posts
    3,708
    If you want to test kills, why using event "hit", and not "Killed" instead?
    Ondrej Spanel, BIS Lead Programmer

  7. #7
    Staff Sergeant
    Join Date
    Nov 6 2002
    Location
    Sweden
    Posts
    362
    Author of the Thread
    I tried Killed and it works better, but I still cant getthe script to work on the Dedic server. SnYpirs thing didt direct help me with anything.

  8. #8
    You will need to set a public variable on the local computer that the server will be waiting for, then execute scripts that way.

    A quick example of this would be:

    this addeventhandler ["Killed",{[_this select 1] exec "Hit.sqs"}]

    hit.sqs:

    <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
    Startscriptset1 = true
    publicvariable &#34;Startscriptset1&#34;
    [/QUOTE]

    Then have a script running on the server (could be ran from your init.sqs file)

    <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
    ?&#33;&#40;local server&#41;&#58; exit
    @Startscriptset1
    .....
    [/QUOTE]

    This could obviously be greatly expanded on, it is just a quick example.

    RED




  9. #9
    Staff Sergeant
    Join Date
    Nov 6 2002
    Location
    Sweden
    Posts
    362
    Author of the Thread
    Quote Originally Posted by (RED @ July 21 2004,19:12)
    You will need to set a public variable on the local computer that the server will be waiting for, then execute scripts that way.

    A quick example of this would be:

    this addeventhandler ["Killed",{[_this select 1] exec "Hit.sqs"}]

    hit.sqs:

    <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
    Startscriptset1 = true
    publicvariable &#34;Startscriptset1&#34;
    Then have a script running on the server (could be ran from your init.sqs file)

    <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
    ?&#33;&#40;local server&#41;&#58; exit
    @Startscriptset1
    .....
    [/QUOTE]

    This could obviously be greatly expanded on, it is just a quick example.

    RED[/QUOTE]
    Did get that script u wrote to work . Anway a m8 told me to put this in the init field. this addeventhandler
    Quote Originally Posted by [b
    Quote[/b] ]this addeventhandler ["Killed",{format [{Server call %1},(_this select 1) addscore 10000]}]
    &#39;

    it works perfect on my server but on dedi it stops working. Logic thing with the server name is still on. I dont see why it shouldt work? It so 100% clear&#33;

  10. #10
    Just a tip on "hit" EH:

    Hit doesn&#39;t work well on tanks or armored vehicles because the projectile fired at it must inflict ATLEAST 5% damage. So a single bullet from an M16 will not inflict enough damage for this event to activate. Now an M203 round might set it off (haven&#39;t tried it) and maybe a 30mm would also, a round from an M82 sniper rifle with an explosive round will set it off also.

    If you&#39;re wanting something to happen when a tank dies (like setting a score) then I would just use the "killed" EH instead like Suma suggested.


    I can&#39;t really comment on eventHandlers in MP because I don&#39;t have any experience in using them in MP. Please post here if you&#39;ve found anything out that would be useful.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •