Rexxenexx 0 Posted April 27, 2008 When the script executes this is the code: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> deleteVehicle _vcl; _vcl = _type createVehicle _pos; _vcl setdir _dir; _vcl setpos _pos; sleep 1; _vcl addAction ["Terrain low/high","terrain_switch.sqf"]; _vcl addMagazineCargo ["10Rnd_127x99_M107",30]; _vcl addMagazineCargo ["5Rnd_762x51_M24",30]; _vcl addMagazineCargo ["15Rnd_9x19_M9",20]; _vcl addWeaponCargo ["M107",2]; _vcl addWeaponCargo ["M24",2]; _vcl addMagazineCargo ["PipeBomb",8]; For some reason on the dedicated server it doesn't add the Cargo. I've even tried <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _vclname = vehicleVarName _this; _vcl SetVehicleVarName _vclname; _vcl Call Compile Format ["%1=_this; PublicVariable ""%1""",_vclname]; But not even that works. Share this post Link to post Share on other sites
beta 0 Posted April 27, 2008 Checking the biki, the addWeaponCargo and addMagazineCargocommands have local effects. So, I guess you would need to have the server tell all the clients to add these weapons/ammo to the vehicle. The hard part (the part I could never figure out) was how to send the clients the reference to the vehicle so they can do whatever to it. I hope you find an answer, if you do, make sure you post it here as I would be interested in seeing it! Share this post Link to post Share on other sites
Rexxenexx 0 Posted April 27, 2008 I'm still working on this right now. Seriously its harder than it should be, but I got it working properly. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> if (!local server) exitWith {}; was at the top of the script. Without it two would spawn when it was killed the first time and no ammo would be in one, but ammo would be in the twin. Plus both would respawn in the initial position once destroyed. I changed it to: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> if (local server) exitWith {}; and the executing script looks like: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> deleteVehicle _vcl; _vcl = _type createVehicle _pos; _vcl SetVehicleVarName _vclname; _vcl Call Compile Format ["%1=_this; PublicVariable ""%1""",_vclname]; _vcl setvelocity [0,0,0]; _vcl setdir _dir; _vcl setpos _pos; _vcl addMagazineCargo ["10Rnd_127x99_M107",30]; _vcl addMagazineCargo ["5Rnd_762x51_M24",30]; _vcl addMagazineCargo ["15Rnd_9x19_M9",20]; _vcl addWeaponCargo ["M107",2]; _vcl addWeaponCargo ["M24",2]; _vcl addMagazineCargo ["PipeBomb",8]; The vehicle is also a mobile respawn. The "Call Compile Format" line has to be there otherwise you will respawn in the middle of the ocean. Note: the way it is now it doesn't work when you preview it OR locally host it. I'm still trying to grasp this total disconnect between dedicated server and local serving. It just seems like a total f'up in programming. If I learn anything more I'll post. Share this post Link to post Share on other sites
DrBobcat 0 Posted April 29, 2008 Actually, I find BIS' approach to multiplayer scripting to be quite malleable, if not a little complicated at times. Locality depends on many different factors, but the most important one, in my opinion, is where the code is actually being executed. For example, take a trigger that has been placed in the editor by the mission designer and it runs a function named test.sqf. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> // test.sqf if (isServer) then exitWith {}; hint "I am not the server!"; Assuming the host is a dedicated server, all the players will see the aforementioned hint in the upper left corner of their screen. However, because the player and server are one and the same when locally hosted, the host would NOT see that message. If we were to revise the condition... <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> ... if ((isServer) && !(local player)) exitWith {}; hint "I could be the server, or I could be a player"; ... ... a local host would still receive the message and a dedicated server would not. For more information, I highly recommend you read this. If you would like to ask a more direct question, please either continue to write in this thread or send a PM. Good luck! - dRb Share this post Link to post Share on other sites