Results 1 to 6 of 6

Thread: Help with object scripting & intercepting menu commands

  1. #1

    Help with object scripting & intercepting menu commands

    I'm a bit new to scripting (but not with using C++) and still trying to figure a couple of things out that aren't apparent.

    Firstly, how to i intercept a menu command, in this instance the "Get in as..." command?

    How do i determine the position on the vehicle that the player is trying to get in?

    How do i determine the class the player is?

    And finally how do you boot someone from a vehicle?

    I have tried looking on the help section and couldn't find anything that looks like object definitions that would help and tried looking through some code for domination but gave up after trying to unravel the messing coding style.

    Any help would be appreciated.

  2. #2
    Firstly, how to i intercept a menu command, in this instance the "Get in as..." command?
    You add an event handler of type "GetIn". Your code is passed an array with vehicle, position (not geographic), and the unit who entered the vehicle.

    How do i determine the position on the vehicle that the player is trying to get in?
    Not sure what you mean here? Geographic or not. The position given above from the event handler is the "role" in the vehicle, eg driver, gunner, cargo so on. If you want the position of the actual vehicle then using the vehicle pased above you do
    PHP Code:
    getPos vehicle 
    How do i determine the class the player is?
    You kan use the command typeOf. Or you can use the command isKindOf to check if a unit is a Tank or a Man or some variation of a BRDM for example.

    And finally how do you boot someone from a vehicle?
    There is moveOut which has no animation or you can force the player to do the action GetOut.

    If you want to do some kind of check to see if people are allowed to get into certain vehicles you need to attach an event handler to all the vehicles that are limited. In your event handling code you check if that person is allowed in the vehicle if not then you move him out.

  3. #3
    Private First Class
    Join Date
    Sep 9 2010
    Posts
    14
    Author of the Thread
    Sweet, Ta.

    Will try that. May take some time though since i can't even get a ammo refill script to work in a MP map.

  4. #4
    Ammo refill can be tricky in MP, if you add weapons or magazine after the game has really begun it get's tricky with JIP's. One solution some uses is to use local ammo boxes.

  5. #5
    Private First Class
    Join Date
    Sep 9 2010
    Posts
    14
    Author of the Thread
    Also, where do you define the "addEventHandler[type, command]". Just in any script or does it need to go into a specific script file. Obviously the command element of it can be a different script file but not sure how to initially declare the EventHandler override.

    And does it need to be initialised in anyway with the in game editor?

    Ta.

  6. #6
    Depends on the event handler. One place you can do it is in the init.sqf:
    Code:
    waitUntil {isNil "car"}; //car must have been initialized first
    car addEventHandler ["GetIn", {moveOut (_this select 2);}];
    I'm pretty sure you can't get away with just running this on the server (eg. using if (isServer) then { bla bla. };.

Posting Permissions

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