bullkanox 5 Posted April 19, 2017 Hi, i need to know if i can detect what player is executing the script, and then depending of the name of the player send it to the box. thanks for support!!! _fnc_group = [["player_1", box_1], ["player_2", box_2]]; _fnc_select = (_fnc_group select 0) select 1; if (cash< 100) then { hint "no money to buy this!" } else { cash = cash - 100; _fnc_select addWeaponCargoGlobal ["rhs_weap_m4a1_blockII_bk", 1]; _fnc_select addMagazineCargoGlobal ["rhs_mag_30Rnd_556x45_Mk318_Stanag", 1]; hintSilent parseText format["<t color='#00FF3C'>thanks for for you buy</t>"]; }; Share this post Link to post Share on other sites
pierremgi 4853 Posted April 20, 2017 You are in multiplayer and you want to work on a cash variable and some equipment for the player. So, just work in the initPlayerLocal.sqf which is a specific script (add it into the mission root if not already present). With this script, cash and equipment will concern the player only. To "couple" a box with a player: - you can spawn the box in this initPlayerLocal.sqf. So the box is identified locally and you just have to fill this box. There is nothing more to do; - or place in advance as much boxes as playable units, name them box1, box2... and add them as a variable attached to the player: * in init field of playable units: this setVariable ["mybox",box1]; (and so on...) * in initPlayerLocal: _myBox = player getVariable "mybox"; // now you refer to the right box. Share this post Link to post Share on other sites
bullkanox 5 Posted April 20, 2017 Thanks Pierremgi for your support. I continue trying to solve how I could get to solve my idea and I get to do the following code and I work! [Google translate =)] _fnc_grupo = [[p1, p2], [stash_1, stash_2]]; _fnc_buscar_player = (_fnc_grupo select 0) find player; // search 1° group array / result: p1 (work) _fnc_buscar_gabinete = (_fnc_grupo select 1) select _fnc_buscar_player; // search 2° group / Result: Stash_1 (work) if (dinero < 100) then { hint "No tienes el dinero suficiente para comprar esto!" } else { dinero = dinero - 100; _fnc_buscar_gabinete addWeaponCargoGlobal ["rhs_weap_m4a1_blockII_bk", 1]; _fnc_buscar_gabinete addMagazineCargoGlobal ["rhs_mag_30Rnd_556x45_Mk318_Stanag", 1]; hintSilent parseText format["<t color='#00FF3C'>Gracias por tu compra</t>"]; }; Share this post Link to post Share on other sites
Grumpy Old Man 3545 Posted April 20, 2017 You need to store the cash on the player object. As of right now dinero is a global variable and the same for all players if it's a public variable. _dinero = _fnc_buscar_player getVariable ["MyDineros",0]; systemchat format ["%1 has %2 dineros!",_dinero]; //will return 0 ------------------------------------- _dinero = _fnc_buscar_player setVariable ["MyDineros",1500]; _dinero = _fnc_buscar_player getVariable ["MyDineros",0]; systemchat format ["%1 has %2 dineros!",_dinero]; //will return 1500 Handle the dineros like that, not like a global variable. Cheers 1 Share this post Link to post Share on other sites