Jump to content
Sign in to follow this  
beta

Need help with event handlers and script spawning

Recommended Posts

The Script:

//check if running on server

if (! (local server)) then {exit};

//type of vehicle

_vehicleType = _this select 0;

//respawn point of vehicle

_respawnPoint = _this select 1;

//vehicle spawn delay in seconds

sleep 1.0;

//create the new vehicle, orient it (doesnt seem to be working for second dead vehicle)

_newVehicle = _vehicleType createVehicle getPos _respawnPoint;

_newVehicle setDir direction _respawnPoint;

player sideChat format["Vehicle created, name: %1", _newVehicle];

//listen for the new vehicle's death, then run the script again

_newVehicle addEventHandler ["killed", {[_vehicleType, _respawnPoint] spawn respawnPRarmaVehicle;}];

player sideChat format["Event handler created, name: %1", _newVehicle];

The init of the vehicle:

this addEventHandler ["killed", {["Truck5t_PRARMA", BLUFOR_1stsection_truck_respawn] spawn respawnPRarmaVehicle;}];

The debug output:

(on the first vehicle's destruction)

Vehicle created, name: 14A27000# 638002: 5T_Closed.P3D

Event handler created, name: 14A27000# 638002: 5T_Closed.P3D

(on the second vehicle's destruction)

Vehicle created, name: 0x100

Event handler created, name: 0x100

The Problem:

The script seems to be working for the first vehicle (original placed via the editor), it creates the new vehicle and adds it event handler.

The new name seems to be ok.

However, when the second vehicle is destroyed, the third vehicle's name is 0x100 and it is not created nor is the event handler added.

I think that the third vehicle having the name 0x100 means something went wrong with it's creation.

Don't know what went wrong or why, that's why I posted here smile_o.gif

Edit: Fixed a typo.

Share this post


Link to post
Share on other sites
Quote[/b] ]Maybe you should take a look at this script by norrin, it may help you out abit with ideas/problem solving. Anyway, good luck.

Thanks for this script link. If I can't it working with event handlers I will probably use canMove and canFire and such.

Also, if a command fails to be processed, will it give an error in the script/function or will it just skip it and go to the next command?

If it skips it, that would explain the vehicle's name being 0x100, looks a lot like a null value.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×