simonwa1 0 Posted January 10, 2008 Okey, got yet another problem. I create a vehicle using createVehicle. When that vehicle is killed an event is pulled off. With the event the vehicle 'object name' is passed. The object name look something like this "43435 m113ambul.p3d 42432", that is with spaces. My problem is that i cant send this object futher to other files because execVM dont accept spaces in argument. And I cant send it as a string, because it will be useless since there is no function to convert strings to 'object name'... ?? What should I do .. ? Arma game-engine feels to stupid sometimes.. Answers appriciated! Share this post Link to post Share on other sites
loyalguard 15 Posted January 10, 2008 Try only passing the "object" and not the "object's name". I find it easier to get the name on the receiving end (after it is passed) than on the sending end. This way you are passing a "pointer" to the object which is simpler that passing the object's name. Example (not necessarily formatted according to your need here or checked for syntax): Say we have a M113 named "ambu". Instead of this: [name ambu] execVM "script.sqf"; Try this: [ambu] execVM "script.sqf" Also, did you give the object a name in the Editor? It looks like it is passing the name of the model not the name of the object. I don't know if this is symptomatic of what I described above or because the object doesn't have a name to pass. Good luck! p.s. It is sometime easier to diagnose problems if you post the actual code you are using in order to more easily find potential problems and make sure we are focusing in the right area. Share this post Link to post Share on other sites
simonwa1 0 Posted January 10, 2008 Here's the context: Vehicle1 (has no name given in editor!! Init field: this addEvenhandler ["killed", {_this execVM "script.sqf"}] <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">script.sqf: _veh = _this select 1 (which in this case is like 3254345 m113ambul 454) _blabla = execVM _veh "script2.sqf"; //Generate error because _veh contain spaces, without being a string deleteVehicle _veh; Share this post Link to post Share on other sites
loyalguard 15 Posted January 10, 2008 I'm not sure is this is the problem (assuming this is what your code looks like), but the line in the script where you assign _veh should use select 0 (the unit killed) instead of select 1 (the killer). Example: _veh = _this select 0; Also, in the line where you execute script2.sqf, the argument should be before execVM, not after. Example: _blabla = _veh execVM "script2.sqf"; Barring those possible syntax problems, I'm not sure what else the problem could be. I can try making a demo mission to try something similar to see if I can work it out but I can't do it until tomorrow. Maybe someone else will have an answer in the meantime! Share this post Link to post Share on other sites
simonwa1 0 Posted January 10, 2008 Quote[/b] ]_veh = _this select 0; Also, in the line where you execute script2.sqf, the argument should be before execVM, not after. Example: _blabla = _veh execVM "script2.sqf"; Of course Im just tired, in the actual script the syntax is correct. I've made anoher solution to this purpose. I can't take any more of this buggy game-engine tonight . But I would really like to know how to accomplish this, sending spaced object names... Share this post Link to post Share on other sites
Planck 1 Posted January 10, 2008 No idea where or why you get such a silly object name. M113Ambul is the classname of the M113 Ambulance, the model name is M113Ambulance.p3d. The same goes for the OFP version. Anything tagged onto the beginning or end in the way of numbers and spaces is meaningless. m113ambul.p3d from your first post is not an ArmA model, I have no idea where it comes from. Planck Share this post Link to post Share on other sites
UNN 0 Posted January 10, 2008 Quote[/b] ]But I would really like to know how to accomplish this, sending spaced object names... 99.8% of the time you should not need to use the object pointer (or object name as you call it). There is the odd occasion when it does come in handy, but not for vehicles. Like I said, it's an object pointer rather than a self contained object. It points to a whole load of data, the numbers and letters you posted in your original post, will just be an internal reference for Arma. Without knowing what’s in Script2.sqf, I can only guess at what you want to do. But the usual case is, passing the objects name, assigned in the editor. Or the name assigned by yourself, using script commands. To a respawn script. If that’s the case then the setVehicleVarName and vehicleVarName commands, will do what you want. See the example at the bottom of the page I linked to. For the record if you really do need to pass Arma's internal object reference to other scripts, then convert it to a string: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_veh=_This Select 0; _Ref=Format ["%1",_veh]; _sP=[_Ref] execVM "script2.sqf"; If that doesn't help, then post the content of Script2.sqf as well. Share this post Link to post Share on other sites
simonwa1 0 Posted January 10, 2008 Quote[/b] ]m113ambul.p3d from your first post is not an ArmA model, I have no idea where it comes from. It might have been written as m113ambulace.p3d. I just took it out of my memory . Quote[/b] ]For the record if you really do need to pass Arma's internal object reference to other scripts, then convert it to a string: But I need to convert it back to the object-datatype, as most of the commands requiers object as the datatype, right?. Or did you have something else in your mind? Share this post Link to post Share on other sites
sickboy 13 Posted January 10, 2008 The whole problem if you ask me is that you use deleteVehicle _veh, in the first script. You use execVM while passing the vehicle object to Script2, but before it actually is launched (execVM has a small latency IIRC) you already deleted the object. Use deleteVehicle inside Script2 instead. Also to be better able to help it would be preferred to post all scripts Share this post Link to post Share on other sites
UNN 0 Posted January 10, 2008 Quote[/b] ]But I need to convert it back to the object-datatype, as most of the commands requiers object as the datatype, right?. As SickBoy pointed out, it's an object-datatype until you delete it, so no need to convert anything. Share this post Link to post Share on other sites
simonwa1 0 Posted January 10, 2008 Quote[/b] ]The whole problem if you ask me is that you use deleteVehicle _veh, in the first script. _veh is actually passed to script2. When I try to use _veh in script2 the engine in complaining about ']' and such is missing, because there is spaces in _veh, and it will not be parsed correct. Quote[/b] ]As SickBoy pointed out, it's an object-datatype until you delete it, so no need to convert anything. Then it says somthing: Type string, expected object. Share this post Link to post Share on other sites
loyalguard 15 Posted January 10, 2008 simonwa1- We're trying to help...but one of the things that is limiting us is you only giving us piecemeal information. As SickBoy and I have suggested, if you give us the actual code your are working with (i.e. the entire script(s) or at least major portions that deal with the topic at hand) we can see what you are actually working with and trying to accomplish. If you are hesitant to share the actual code for some reason I can understand, but it will make it harder for us to pinpoint the problem. Share this post Link to post Share on other sites
sickboy 13 Posted January 11, 2008 I know what your problem is, besides that you delete the vehicle before accessing it's properties. You think that _veh contains the object's class name which you can use to spawn another one This is false. Before you delete the vehicle, you need: [*] typeOf _veh; to get the classname for the vehicle (which is a lot different from what you saw, it should be something like "M113Ambul" instead of "m113ambulance.p3d 42452 234" etc etc), [*] getPos _veh; to get the position of the vehicle It's very simple. I'll give an example that works flawless: Script1.sqf: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">private ["_veh"]; _veh = _this select 0; // Killed eventhandler gives the killed object in array _this, position 0 _veh execVM "script2.sqf"; Script2.sqf: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">private ["_type", "_pos", "_newVeh"]; // _this = the vehicle object, because it was passed at the execVM _type = typeOf _this; // _type now contains the class name of the vehicle _pos = getPos _this; // _pos now contains the position of the vehicle deleteVehicle _this; // _this now becomes an objNull because it is deleted, but variables _pos and _type still contain the data you need _newVeh = _type createVehicle _pos; // This will recreate the same vehicle on the same position as the other vehicle. _newVeh contains the object reference to this new vehicle And otherwise, why not do it all at once: Script1.sqf: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">private ["_type", "_pos", "_veh", "_newVeh"]; _veh = _this select 0; // Killed eventhandler gives the killed object in array _this, position 0 _type = typeOf _veh; // _type now contains the class name of the vehicle _pos = getPos _veh; // _pos now contains the position of the vehicle deleteVehicle _veh; // _veh now becomes an objNull because it is deleted, but variables _pos and _type still contain the data you need _newVeh = _type createVehicle _pos; // This will recreate the same vehicle on the same position as the other vehicle, _newVeh contains the object reference to this new vehicle Share this post Link to post Share on other sites
simonwa1 0 Posted January 13, 2008 Thanks for all your answers!! Quote[/b] ]If you are hesitant to share the actual code for some reason I can understand, but it will make it harder for us to pinpoint the problem. Hehe, nope. Im just too lazy to write down the complete context . And since I've made an another solution i don't have that script now. But if someone would still be intrested I'll try again. From my memory: script1.sqf: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _veh = _this; //=non-editor named vehicle _trg = createTrigger; _trg setTriggerActivation[bla bla bla]; _trg setOnactivation "nothing = " + str(_veh) + "execVM 'script2.sqf'; do some more.." (cant remember the exact triggerfunctionsname) script2.sqf: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> deleteVehicle _this; //error halt here This was basically the whole thing. Share this post Link to post Share on other sites