Results 1 to 9 of 9

Thread: Problem with switch and multiplayer

  1. #1

    Question Problem with switch and multiplayer

    Hey guys im trying this:

    if (playerSide == west) then {
    execVM "scripts\stand_weap_all.sqf";
    switch (player) do {
    case s1: { execVM "scripts\stand_weap_gf.sqf"; };
    case s2: { execVM "scripts\stand_weap_at.sqf"; };
    case s3: { execVM "scripts\stand_weap_san.sqf"; };
    case s4: { execVM "scripts\stand_weap_lmg.sqf"; };
    case s5: { execVM "scripts\stand_weap_rifle.sqf"; };
    case s6: { execVM "scripts\stand_weap_smaw.sqf"; };
    case s7: { execVM "scripts\stand_weap_gf.sqf"; };
    case s8: { execVM "scripts\stand_weap_at.sqf"; };
    case s9: { execVM "scripts\stand_weap_san.sqf"; };
    case s10: { execVM "scripts\stand_weap_lmg.sqf"; };
    case s11: { execVM "scripts\stand_weap_rifle.sqf"; };
    case s12: { execVM "scripts\stand_weap_smaw.sqf"; };
    };
    };

    But not all players are there so the switch crashed cause its trying to ask on an object that dosent exist... any ideas?

  2. #2
    In the stand_weap_gf.sqf etc scripts try something like if !(isNull _soldier) then.... etc.
    Fire And Smoke for ArmA2: JTD_FireAndSmoke v0.2

    For better future effects addons, please vote for this ticket.

  3. #3
    Could just use command typeof to check player units class and make it give weapons based on classes instead of nonflexible unit names.

  4. #4
    But if im not interestet in using typeof since I allready know which players is what... then what would you surgest shk... the script fails because the players dosent exist... if im trying s11 it tries s1 first and fails... I think its because s1 isent an object

  5. #5
    Then you will need to sort out which units exist prior to processing them. Use a loop using isNull as I showed before to weed out the non-objects, placing the remaining objects into an array or something. Then process everything in the array.
    Last edited by DMarkwick; Feb 15 2010 at 19:07.

  6. #6
    Change it to a string?

    _str = str player;
    switch _str do {
    case "s1" :{};
    case "s2" :{};

  7. #7
    strange im still having some issues... it looks like it helped:

    if (playerSide == west) then {
    _str = str player;
    execVM "scripts\stand_weap_all.sqf";
    switch (_str) do {
    case "s1": { hint "1"; execVM "scripts\stand_weap_gf.sqf"; };
    case "s2": { hint "2"; execVM "scripts\stand_weap_at.sqf"; };
    case "s3": { hint "3"; execVM "scripts\stand_weap_san.sqf"; };
    case "s4": { hint "4"; execVM "scripts\stand_weap_lmg.sqf"; };
    case "s5": { hint "5"; execVM "scripts\stand_weap_rifle.sqf"; };
    case "s6": { hint "6"; execVM "scripts\stand_weap_smaw.sqf"; };
    case "s7": { hint "7"; execVM "scripts\stand_weap_gf.sqf"; };
    case "s8": { hint "8"; execVM "scripts\stand_weap_at.sqf"; };
    case "s9": { hint "9"; execVM "scripts\stand_weap_san.sqf"; };
    case "s10": { hint "10"; execVM "scripts\stand_weap_lmg.sqf"; };
    case "s11": { hint "11"; execVM "scripts\stand_weap_rifle.sqf"; };
    case "s12": { hint "12"; execVM "scripts\stand_weap_smaw.sqf"; };
    };
    };

    now I get the "10" hint and the player name is "s10"... running the mission in editor mode gives me all the weapons and items that the script should... but as hosted server I dont...

    the script is:

    hint "running";
    player addWeapon "DDAM_MG62_optic";
    player addMagazine "100Rnd_762x51_M240";
    player addMagazine "100Rnd_762x51_M240";
    player addMagazine "100Rnd_762x51_M240";
    player addMagazine "100Rnd_762x51_M240";

    player addWeapon "ACE_GLOCK18";

    player addMagazine "ACE_33RND_9X19_G18";
    player addMagazine "ACE_33RND_9X19_G18";
    player addMagazine "ACE_33RND_9X19_G18";
    player addMagazine "ACE_33RND_9X19_G18";

    player addMagazine "ACE_BANDAGE";
    player addMagazine "ACE_MORPHINE";
    hint "done";

    now I get the hint "done" så the file is run but the items dosent get added... does it need a sleep or something?

    ---------- Post added at 10:36 PM ---------- Previous post was at 10:16 PM ----------

    Hmm tried with

    waitUntil { alive player };

    but that still didnt work but the sleep 1; did :S

  8. #8
    When switching weapons, it always needs to be done "in the game", not in briefing. Thus sleep 1 or waituntil {time>0} is needed.

  9. #9

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •