mindstorm 8 Posted January 22, 2015 I have a script SetAmmo.sqf which I call when a player joins the server, and after a respawn: removeGoggles player; player addBackpackGlobal "B_Carryall_ocamo"; sleep 1; player addMagazineGlobal "30Rnd_65x39_caseless_mag"; sleep 1; player addWeaponGlobal "arifle_MX_SW_F"; removeAllPrimaryWeaponItems player; player addPrimaryWeaponItem "optic_LRPS"; sleep 0.5; player setAmmo ["arifle_MX_SW_F", 1]; player addWeaponGlobal "ItemMap"; removeBackpack player; The script is executed on the client. I got some issues with this script, only when the mission is running on a dedicated server! When connecting the gogles get removed, the weapon is added but there is no magazine in the weapon (therefore ammo =0). After a respawn the script however works as suppose to, and the player gets one magazine with 1 bullet in it. I've allready added the sleeps hoping they would help but they don't. Anny suggestions? Share this post Link to post Share on other sites
das attorney 857 Posted January 22, 2015 If you call (as opposed to spawn) then it could be an issue if done from unscheduled environment (you don't mention where you call from so I'm guessing). Try spawning the script instead of calling and it should respect the sleeps. Also, it might be worth using waitUntil {time > 1}; as well at the top of the script to be on the safe side. Share this post Link to post Share on other sites
dreadedentity 278 Posted January 22, 2015 This sounds like an issue with the setAmmo command. Try using addMagazineAmmoCargo: removeGoggles player; player addBackpackGlobal "B_Carryall_ocamo"; sleep 1; player addMagazineAmmoCargo ["30Rnd_65x39_caseless_mag", 1, 1]; //directly adds 1 magazine with 1 bullet to the player sleep 1; player addWeaponGlobal "arifle_MX_SW_F"; removeAllPrimaryWeaponItems player; player addPrimaryWeaponItem "optic_LRPS"; sleep 0.5; /* player setAmmo ["arifle_MX_SW_F", 1]; */ //no need for this now player addWeaponGlobal "ItemMap"; removeBackpack player; Share this post Link to post Share on other sites
mindstorm 8 Posted January 22, 2015 (edited) This sounds like an issue with the setAmmo command. Try using addMagazineAmmoCargo: removeGoggles player; player addBackpackGlobal "B_Carryall_ocamo"; sleep 1; player addMagazineAmmoCargo ["30Rnd_65x39_caseless_mag", 1, 1]; //directly adds 1 magazine with 1 bullet to the player sleep 1; player addWeaponGlobal "arifle_MX_SW_F"; removeAllPrimaryWeaponItems player; player addPrimaryWeaponItem "optic_LRPS"; sleep 0.5; /* player setAmmo ["arifle_MX_SW_F", 1]; */ //no need for this now player addWeaponGlobal "ItemMap"; removeBackpack player; addMagazineAmmoCargo doesnt work. It doesn't even work when I login in as admin and use it trough debug console. I've changed my script to this piece of awsomeness and this worked. Gotta love this game. while {currentMagazine player == ""} do { player removeWeaponGlobal (primaryWeapon player); sleep 0.1; player addBackpackGlobal "B_Carryall_ocamo"; sleep 0.1; player addMagazineGlobal "30Rnd_65x39_caseless_mag"; sleep 0.1; player addWeaponGlobal "arifle_MX_SW_F"; sleep 0.1; removeAllPrimaryWeaponItems player; sleep 0.1; player addPrimaryWeaponItem "optic_LRPS"; sleep 0.1; player setAmmo ["arifle_MX_SW_F", 1]; }; Edit. To soon. Now it doesn't add the optics. Seriously BIS get your stuff together. Well for some weird reason addPrimaryWeaponItem doesn't work on my dedicated server untill a units dies and respawns. If I execute this on the server, global or local it just doens't work. (entity is my player object, and yes that excists). entity addPrimaryWeaponItem "optic_LRPS"; After the first death my script starts working, and I also get the optics. And ofcourse the exec it from console also works. What on earth is this. Edited January 22, 2015 by mindstorm Share this post Link to post Share on other sites
dreadedentity 278 Posted January 23, 2015 addMagazineAmmoCargo doesnt work. It doesn't even work when I login in as admin and use it trough debug console. That's because you're supposed to use a container in the command instead of an object (uniformContainer, vestContainer, backpackContainer), so the command should look like this: (vestContainer player) addMagazineAmmoCargo ["30Rnd_65x39_caseless_mag", 1, 1]; To be fair, I should have paid more attention when I wrote that little piece of code, but if that's the extent of your debugging ability you're going to have a bad time. This is how I currently imagine you: Share this post Link to post Share on other sites
mindstorm 8 Posted January 23, 2015 but if that's the extent of your debugging ability you're going to have a bad time. This is how I currently imagine you: That is seriously uncalled for. Can you imagine me creating a mission and thinking its working perfectly every time. Then when I launch it on a dedicated server I can spend annother 4-8 hours creating workarounds for bugs? Just to give you an idea, a list bugs I encountered with my latest mission. These only occure when I host it on a dedicated server. setDamage on static objects does not transfer to clients setVariable with global flag not working if used just after creating a vehicle Group names set in the editor trough a synced group name object don't work SetDir not working if used with attachTo on dedicated server And now I can add addMagazineGlobal and addPrimaryWeaponItem to the list. Also, since I'm added a backpack and a vest I'd probably have to use backpackContainer instead of vestContainer. Anyway. Thank you for taking the time in helping me. Share this post Link to post Share on other sites
dreadedentity 278 Posted January 24, 2015 I believe the setDamage on static objects issue has been known since A2. A workaround for this would be to save the destroyed objects into an array and iterate through that array, locally destroying all those objects upon client loading. I see in that issue ticket, KK seems to have pinpointed the issue to a few causes. The solution is very simple: you literally wait until those conditions are met. I give you this: DE_addVariable = { // [object, [setVariable variable, value]] _obj = _this select 0; _var = _this select 1; _curFrame = diag_frameno; waitUntil {(diag_frameno > _curFrame) && {time > 0}}; _obj setVariable [_var select 1, _var select 2, true]; }; //proper usage: _obj createVehicle ["someVehicle", [1000,1000,0], [], 0, "CAN_COLLIDE"]]; [_obj, ["owner", player]] spawn DE_addVariable; //keep going happily with your code Lag more or less depends on your connection, and how much stuff is on your map. No matter how much they optimize it, you will eventually have too much stuff on your map. FYI, you're not going to be able to run an 80-slot wasteland server on a home connection. I'm not really sure what you mean about the group names. I need a picture or something. setDir works on dedicated server last time I checked, but you need to use setPos to synchronize direction over the net. This is specifically mentioned on the wiki in the notes. addMagazineGlobal does accept a global argument so it should work just fine. If it's not working, you may have something FT-worthy. I'm curious, does your mission use any mods? addPrimaryWeaponItem does not accept a global argument (according to the wiki), so I'm not really surprised the command failed when run by dedicated server. Use locally only. I may have been harsh in what I said, but that's the reality. You can't go about this like a bull in a china shop, smashing everything in your way. When you discover issues, you should find out why they are occurring, and learn more so you can overcome them Share this post Link to post Share on other sites