Matosh 34 Posted June 15, 2012 I'm trying to put the new texture to the vehicle via script, but I keep getting a script error. if (typeOf _veh == "LAV25") then { _veh setVehicleI> Error position: <_veh == "LAV25") then { _veh setVehicleI> Error Undefined variable in expression: _veh if (typeOf _veh == "LAV25") then { _veh setVehicleInit "this setObjectTexture [0, ""lav_des_1.paa""]"; _veh setVehicleInit "this setObjectTexture [1, ""lav_des_2.paa""]"; processInitCommands; }; Share this post Link to post Share on other sites
giallustio 770 Posted June 15, 2012 How do you call the script? Share this post Link to post Share on other sites
Matosh 34 Posted June 15, 2012 from init.sqf ( execVM "lav25des.sqf"; ) Share this post Link to post Share on other sites
giallustio 770 Posted June 15, 2012 Yeah but...You need to pass a param to the script...For example: [name_vehicle] execVM "lav25des.sqf"; and change the script: _veh = _this select 0; if (typeOf _veh == "LAV25") then { _veh setVehicleInit "this setObjectTexture [0, ""lav_des_1.paa""]"; _veh setVehicleInit "this setObjectTexture [1, ""lav_des_2.paa""]"; processInitCommands; }; Share this post Link to post Share on other sites
Matosh 34 Posted June 15, 2012 [name_vehicle] Do I have to put vehicle classname or ? Share this post Link to post Share on other sites
mondkalb 1087 Posted June 15, 2012 String comparisons are very expensive and should be avoided whenever possible. So, instead of if (typeOf _veh == "LAV25") then {[/Code]use:[code]if (_veh isKindOf "LAV25") then {[/Code] Share this post Link to post Share on other sites
giallustio 770 Posted June 15, 2012 The name of the vehicle! In the editor give to the vehicle a name! Share this post Link to post Share on other sites
Matosh 34 Posted June 15, 2012 But I need the script to put a texture on a vehicle, that will spawn after the player completes the mission. Share this post Link to post Share on other sites
twirly 11 Posted June 15, 2012 (edited) When you spawn a vehicle using createvehicle... the vehicle is returned by createVehicle. So... [b][i]_veh[/i][/b] = createVehicle ["LAV25", position player, [], 0, "NONE"] ; Then call the script "lav25des.sqf" with the returned vehicle... nul = [[b][i]_veh[/i][/b]] execVM "lav25des.sqf"; lav25des.sqf:- _veh = _this select 0; if (_veh isKindOf "LAV25") then { _veh setVehicleInit "this setObjectTexture [0, ""lav_des_1.paa""]"; _veh setVehicleInit "this setObjectTexture [1, ""lav_des_2.paa""]"; processInitCommands; }; Edited June 15, 2012 by twirly Clarity Share this post Link to post Share on other sites
blackmamb 2 Posted June 15, 2012 Sorry i just have a quick question about that, for my personal knowledge. What's the use of the setVehicleInit in there? Why not simply go with something like _veh setObjectTexture [1, ""lav_des_2.paa""]; Only idea i have is this would be for some locality issues, but i don't really see the point here. Share this post Link to post Share on other sites
twirly 11 Posted June 15, 2012 I haven't tested the code.... and have no idea if those lines work or not. I have never used "setObjectTexture". I was simply showing how to get a handle to a spawned object....and then call another script with it. So... you are probably quite right and that part may still need sorting out. Share this post Link to post Share on other sites
blackmamb 2 Posted June 15, 2012 Ah alright. Cause i actually use this command sometimes (for stupid adversarial missions, mostly, painting things in blue or red). So i was wondering if the use of setinitvehicle was intentional, in order to achieve another hidden goal. Cause i know this command is local to the caller in an MP environment. Share this post Link to post Share on other sites
Matosh 34 Posted June 16, 2012 When you spawn a vehicle using createvehicle... the vehicle is returned by createVehicle. So... [b][i]_veh[/i][/b] = createVehicle ["LAV25", position player, [], 0, "NONE"] ; Then call the script "lav25des.sqf" with the returned vehicle... nul = [[b][i]_veh[/i][/b]] execVM "lav25des.sqf"; lav25des.sqf:- _veh = _this select 0; if (_veh isKindOf "LAV25") then { _veh setVehicleInit "this setObjectTexture [0, ""lav_des_1.paa""]"; _veh setVehicleInit "this setObjectTexture [1, ""lav_des_2.paa""]"; processInitCommands; }; So for example: player completes a mission, as reward he gets LAV-25, the moment when the vehicle is created script should put custom texture. Will this happen with your code, in your last message? Share this post Link to post Share on other sites
blackmamb 2 Posted June 16, 2012 (edited) Well, yeah, it should probably happen. You need to know when and how you're gonna call the script though. So if you're thinking about adding this to a custom mission you're making, shouldn't be much harder than that (except, probably don't create the LAV on the player position. Don't even use player if you're in a multiplayer environment). If you're thinking about adding it to domination, though,as i suspect, you'd better go to the appropriated thread to ask how to do that. Edited June 16, 2012 by BlackMamb Share this post Link to post Share on other sites
[aps]gnat 28 Posted June 16, 2012 If you want the texture just on one vehicle, then as twirly has guided you, you must run the setObjectTexture EVERY time you spawn a the LAV25, in the code immediately after spawning it. Share this post Link to post Share on other sites
Matosh 34 Posted June 16, 2012 (edited) Well, yeah, it should probably happen. You need to know when and how you're gonna call the script though.So if you're thinking about adding this to a custom mission you're making, shouldn't be much harder than that (except, probably don't create the LAV on the player position. Don't even use player if you're in a multiplayer environment). If you're thinking about adding it to domination, though,as i suspect, you'd better go to the appropriated thread to ask how to do that. Yes im doing it for domination, but that doesnt mean i have to go to domination thread. I created this thread for script help. Gnat;2172880']If you want the texture just on one vehicle' date=' then as twirly has guided you, you must run the setObjectTexture EVERY time you spawn a the LAV25, in the code immediately after spawning it.[/quote']Actually i was thinking to do on 2 more vehicles. _veh = createVehicle ["LAV25", whateverposition, [], 0, "NONE"]; This code should create a vehicle on whateverposition and script should put the textures on it, right? But another script will handle creating the vehicle (forgot to mention it on my previous message) so i need a script that will check for the designated vehicle and if vehicle is present, script should put textures on it or with addaction, player enters a vehicle > scroll down and select "Paint Vehicle", script is executed and puts texutes on it. Im beginner in this so here is an example, its probably not correct but it should give you idea. As i mentioned above that im doing this on domination, im going to post some domination thing here but i just wanted to show example how can script be executed and still im gonna need help with this script. I was thinking like this i_client.sqf GVAR(action_menus_vehicle) = [ [["LAV25"],"Put desert camo", "scripts\lav25des.sqf", -1000] ]; lav25des.sqf _veh = _this select 0; _caller = _this select 1; _id = _this select 2; _veh setVehicleInit "this setObjectTexture [0, ""pics\lav_des_1.paa""]"; _veh setVehicleInit "this setObjectTexture [1, ""pics\lav_des_2.paa""]"; processInitCommands; _veh removeaction _id; Edited June 16, 2012 by matosinec Share this post Link to post Share on other sites
blackmamb 2 Posted June 16, 2012 No, i believe you misunderstood me. I was not saying you should have asked that texture question in the domination thread, but that you should go ask there, unless you know that already of course, where exactly to call that script. Sorry if i came out offensive. Share this post Link to post Share on other sites
Matosh 34 Posted June 16, 2012 No problem, yeah i believe i misunderstood you. I already searched for it but no luck also if i ask there im not sure will someone reply so... Share this post Link to post Share on other sites
Matosh 34 Posted June 17, 2012 _veh = _this select 0; _caller = _this select 1; _id = _this select 2; _veh setVehicleInit "this setObjectTexture [0, ""pics\lav_des_1.paa""]"; _veh setVehicleInit "this setObjectTexture [1, ""pics\lav_des_2.paa""]"; processInitCommands; _veh removeaction _id; This actually works, but i got one question. When player is in vehicle and puts new textures will another player see it ? Share this post Link to post Share on other sites
[aps]gnat 28 Posted June 17, 2012 setVehicleInit ... processInitCommands My understanding (from BIKI) is thats exactly what those 2 commands are to ensure, all clients get the same info, but I'm no expert in the area. Share this post Link to post Share on other sites