Crymeisbad 10 Posted April 20, 2013 So I'm working on a script so I can change the attributes of a lot of vehicles at once by using a Switch. The script I'm using works in singleplayer without any issue, but the problem occurs when I player multiplayer. For me, vehicles load in flawlessly and have the correct gear it should load with, but the other player is not shown moving and he cannot kill me. The other player sees the vehicle as if the code has not executed, they can not enter vehicles as if there was a massive desync, but yet he can see me moving in realtime. If anyone has any idea why my simple code is not working correcting, it'd help alot if you can tell me. In the vehicle init field, I execute this: nul = [this, "Hunter_B_Basic"] execVM "Ammobox\vehicleRespawnTimes.sqf"; vehicleRespawnTimes.sqf: _vehicle = _this select 0; _type = _this select 1; clearItemCargo _vehicle; clearMagazineCargo _vehicle; clearWeaponCargo _vehicle; switch (_type) do { case ("Hunter_B_Basic"): { veh = [_vehicle, 600, 9999999, 0, FALSE, FALSE, "nul = [this, 'Hunter_B_Basic'] execVM 'Ammobox\vehicles.sqf';"] execVM "scripts\vehiclerespawn.sqf"; nul = [this, "Hunter_B_Basic"] execVM "Ammobox\vehicles.sqf"; }; case ("Hunter_B_AT"): { veh = [_vehicle, 600, 9999999, 0, FALSE, FALSE, "nul = [this, 'Hunter_B_AT'] execVM 'Ammobox\vehicles.sqf';"] execVM "scripts\vehiclerespawn.sqf"; nul = [this, "Hunter_B_AT"] execVM "Ammobox\vehicles.sqf"; }; }; This last part, I execute it from the previous one separately so that it doesn't run the vehicles.sqf multiple times. vehiclerespawn.sqf is the vehicle respawn code that pretty much everyone uses, so no need for me to repost it here. Vehicles.sqf (This is where I feel the error is, it is what takes the actions onto the vehicle, adding gear and what not): _vehicle = _this select 0; _type = _this select 1; clearItemCargo _vehicle; clearMagazineCargo _vehicle; clearWeaponCargo _vehicle; switch (_type) do { case ("Hunter_B_Basic"): { _vehicle addMagazineCargo ["Chemlight_green", 8]; _vehicle addMagazineCargo ["SmokeShellRed", 2]; _vehicle addMagazineCargo ["SmokeShellGreen", 2]; _vehicle addItemCargo ["FirstAidKit", 4]; }; case ("Hunter_B_AT"): { _vehicle addMagazineCargo ["Chemlight_green", 8]; _vehicle addMagazineCargo ["SmokeShellRed", 2]; _vehicle addMagazineCargo ["SmokeShellGreen", 2]; _vehicle addItemCargo ["FirstAidKit", 4]; _vehicle addWeaponCargo ["launch_NLAW_F", 1]; _vehicle addMagazineCargo ["NLAW_F", 3]; _vehicle addBackpackCargo ["B_FieldPack_cbr_AT", 2]; }; case ("Light_C_Heli"): { _vehicle setObjectTexture [0,"\A3\Air_F\mh9\data\heli_light01_ext_blue_co.paa"]; nul = [_vehicle] execVM "scripts\openhelidoors.sqf"; _vehicle animate ["AddDoors",1]; _vehicle animate ["AddBenches",0]; _vehicle lockCargo [2, true];_vehicle lockCargo [3, true];_vehicle lockCargo [4, true];_vehicle lockCargo [5, true]; _vehicle addMagazineCargo ["Chemlight_green", 8]; _vehicle addMagazineCargo ["SmokeShellRed", 2]; _vehicle addMagazineCargo ["SmokeShellGreen", 2]; _vehicle addItemCargo ["FirstAidKit", 4]; }; }; Also, I'd like to point out that in both .sqfs, I do have more switches available, for example I left my "Light_C_Heli" there since it shows that it makes more actions. Openhelidoors.sqf should cause any lag, but if anyone wants it, here you go: _heli = _this select 0; while {true} do { if((GetPos _heli select 2) < .25) then { _heli animate ['DoorL_Front_Open', 1]; _heli animate ['DoorR_Front_Open', 1]; } else { _heli animate ['DoorL_Front_Open', 0]; _heli animate ['DoorR_Front_Open', 0]; }; }; Share this post Link to post Share on other sites
cobra4v320 27 Posted April 20, 2013 I dont mess with MP very often but look at some of these commands instead of what you are currently using. addMagazineCargoGlobal addWeaponCargoGlobal addItemCargoGlobal clearWeaponCargoGlobal clearMagazineCargoGlobal clearItemCargoGlobal Share this post Link to post Share on other sites
super-truite 54 Posted April 20, 2013 I have a similar issue. I create some light and particle sources in a moving object named _object using: _lsource = "#lightpoint" createVehicle getpos _object; _psource = "#particlesource" createVehicle getPos _object; The parameters of the light/particle sources are well define and everything works fine in single player. In multiplayer, sometimes it is working, sometimes it is not! To be more precise, If I have only one object, no one sees the light/particles or someone I see it (I host the game) but the other player not. If I spawn several and apply the script to all, it is is working for some of the objects...?! This is driving me nuts! It could be completely unrelated to the op problem, but this question is: is there a tutorial in which the subtleties of SP versus MP scripting is explained? I have often some issues with that. full code if you need more details: _object = _this select 0; _li = "#lightpoint" createVehicle getpos _object; _li setLightBrightness 3; _li setLightAmbient[1, 1, 1]; _li setLightColor[1, 1, 1]; _li lightAttachObject [_object, [0,0,0.1]]; _ps = "#particlesource" createVehicle getPos _object; _ps setParticleParams [["\A3\data_f\ParticleEffects\Universal\Universal", 21, 16, 0,0],"",// File,Ntieth,Index,Count,Loop(Bool) "Billboard",0.2,50,[0,0,0],[0,0,0],1,4,1,0,[0.02,0.02,0.02,0],[[1,1,1,-4], [1,1,1,-4], [1,1,1,-2],[1,1,1,0]],[1.5,0.5],0.01,0.08,"","",_object]; _ps setParticleRandom[0.1,[0,0,0],[5,5,5],0,1,[0,0,0,0],1,1,360]; _ps setDropInterval 0.01; _ps1 = "#particlesource" createVehicle getpos _object; _ps1 setParticleCircle [0, [0, 0, 0]]; _ps1 setParticleRandom [0, [0.1, 0.1, 0], [0.2, 0.2, 0.4], 0.3, 0.25, [0, 0, 0, 0.1], 0, 0]; _ps1 setParticleParams [["\A3\data_f\ParticleEffects\Universal\Universal", 16, 12, 8,0], "", "Billboard", 1, 10, [0, 0, 0], [0, 0, 0.5], 0, 10.1, 7.9, 0.01, [2, 2, 2], [[1,1,1,-4], [1,1,1,-4], [1,1,1,-2],[1,1,1,0]], [0.125], 1, 0, "", "", _object]; _ps1 setDropInterval 0.005; _a = true; _object say3D "rocket"; while {_a} do { _object setvelocity [20,20,-50]; sleep 0.1; _Z = (getpos _object) select 2; if (_Z < 50) then { _logic2 = "Land_MetalBarrel_F" createvehicle (getpos _object); _boom = "HelicopterExploSmall" createvehicle (getpos _object); hideobject _logic2; deletevehicle _li; deletevehicle _ps1; deletevehicle _ps; _toxicgas = [_logic2,25] execVM "effectarea.sqf"; _a = false; }; }; deletevehicle _object; This script is to make a missile carrying my...devastating chemical weapon. Free WMD script for the one who helps me :) : http://img541.imageshack.us/img541/8360/2013041900013.jpg Share this post Link to post Share on other sites
killzone_kid 1331 Posted April 20, 2013 1. you are running infinite loop for animation without any sleep so it probably lags client like hell 2. if((GetPos _heli select 2) < .25) probably generates error and spams your rpt which lags client even more. Share this post Link to post Share on other sites
jasin 1 Posted April 21, 2013 Have a read through this Has some interesting info on locality and such. Share this post Link to post Share on other sites