Home   Help Search Login Register  

Author Topic: using vehiclechat  (Read 2208 times)

0 Members and 1 Guest are viewing this topic.

Offline Rone

  • Members
  • *
using vehiclechat
« on: 23 Jan 2009, 17:09:54 »
hello,

i am doing a coop mission in which the players each use a bike to go to a meeting place.
I wanted to make a private message appear when a player gets on his bike, using vehiclechat:

Code: [Select]
this addeventhandler ["getin", {unit vehiclechat "blabla"}]
but nothing happens...
Is there a peculiar way to use the "vehiclechat" command?
Sorry if this question is stupid, i am a complete  noob. :-[

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: using vehiclechat
« Reply #1 on: 23 Jan 2009, 17:11:31 »
Information about the event are passed into the function, {}, in the _this array.
Code: [Select]
this addeventhandler ["getin", {(_this select 0) vehiclechat "blabla"}]
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Rone

  • Members
  • *
Re: using vehiclechat
« Reply #2 on: 23 Jan 2009, 17:28:35 »
hello spooner,
Ty for your help.
i put
Code: [Select]
this addeventhandler ["getin", {(_this select 0) vehiclechat "blabla"}]in the init of the car but no message appear :scratch:
when i use sidechat instead of vehiclechat, it works... :dunno:

Offline Worldeater

  • Former Staff
  • ****
  • Suum cuique
Re: using vehiclechat
« Reply #3 on: 23 Jan 2009, 20:19:32 »
Sending the message immediately won't work. It seems like the game hasn't realized that you're in the car already.

The solution is to create a script that waits before it sends the message and run that script from the eventhandler:

Code: (Initialization field of the vehicle) [Select]
this addEventHandler ["GETIN", { "It's a hundred and six miles to Ortego..." execVM "sendVehicleMsg.sqf" }]
Code: (sendVehicleMsg.sqf) [Select]
waitUntil { (vehicle player) != player }; // wait until the game knows were inside
sleep 1;                                  // it's lying: it still doesn't know! So wait some more...
(vehicle player) vehicleChat _this;
try { return true; } finally { return false; }

Offline Rone

  • Members
  • *
Re: using vehiclechat
« Reply #4 on: 23 Jan 2009, 21:04:20 »
Ty Worldeater,
i test that.

edit: works perfectly; thanks for your help. :clap:
« Last Edit: 23 Jan 2009, 23:39:24 by Rone »

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: using vehiclechat
« Reply #5 on: 24 Jan 2009, 03:38:04 »
There is nothing like immediately spotting the obvious error to make you miss the real problem. Sorry!
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)