alleycat 28 Posted May 17, 2014 How to check for a player slot? The only way I found was to name the object in the editor and act on that, but the game keeps showing errors about it not existing if that player slot is not taken. if (!(isnil b")) then { if (b1 == player) then { }; }; Share this post Link to post Share on other sites
HazJ 1289 Posted May 17, 2014 if (!isNil "b1") then { if (b1 == player) then { }: }; waitUntil {!isNil "b1"}; if (isPlayer b1) then { }: Hope these help. :) Dirty Haz Share this post Link to post Share on other sites
alleycat 28 Posted May 17, 2014 Thanks, however it does not work in multiplayer. When the b1 unit is not used by a player it throws an error. Is there really no way to check for some things existence without the game throwing errors? Share this post Link to post Share on other sites
HazJ 1289 Posted May 17, 2014 Yes. These should work: waitUntil {!isNil "b1"}; if (isNil "b1") exitWith {}; if (isNil "b1") then {b1 = player}; Dirty Haz Share this post Link to post Share on other sites
alleycat 28 Posted May 17, 2014 Thanks, exitwith fixed the problem Share this post Link to post Share on other sites
k0rd 3 Posted May 17, 2014 as an alternative to naming the slots, you can iterate though an array returned by playableUnits see https://community.bistudio.com/wiki/playableUnits Share this post Link to post Share on other sites
alleycat 28 Posted May 17, 2014 Is it possible to check what slot/object the LOCAL player is? I think the solution above only checks for wether an object exists. Share this post Link to post Share on other sites
SilentSpike 84 Posted May 17, 2014 Just use "player": if (player == b1) then { }; Since player only refers to the local player. Share this post Link to post Share on other sites
k0rd 3 Posted May 17, 2014 if (isServer) then{ { if (isPlayer _x) then { //do something - _x refers to a player }; }forEach playableUnits; }; Share this post Link to post Share on other sites
SilentSpike 84 Posted May 17, 2014 That won't check for the local player though Share this post Link to post Share on other sites
k0rd 3 Posted May 17, 2014 That won't check for the local player though if you are checking for a local player: { if (player == _x) then { //_x is the local player - add what to do to _x here }; }foreach playableUnits; Share this post Link to post Share on other sites
alleycat 28 Posted May 17, 2014 Thanks, but I still cant get the part to work that checks for what player slot a player selected. Share this post Link to post Share on other sites
Belbo 462 Posted May 17, 2014 Thanks, but I still cant get the part to work that checks for what player slot a player selected. You still need to name your units for that and check for if (!isNil "p1") then { if (player == p1) then { yourcode }; }; otherwise you have no option to check for the player being in a specific slot/playing a specific unit. 1 Share this post Link to post Share on other sites
alleycat 28 Posted May 17, 2014 yay thanks, I think that should work Share this post Link to post Share on other sites
k0rd 3 Posted May 17, 2014 if you would have listed all these criteria in the first post, this would have been a much faster exercise - just sayin 1 Share this post Link to post Share on other sites
thy_ 164 Posted February 5, 2022 On 5/17/2014 at 3:56 PM, Belbo said: You still need to name your units for that and check for if (!isNil "p1") then { if (player == p1) then { yourcode }; }; otherwise you have no option to check for the player being in a specific slot/playing a specific unit. Thanks, @Belbo Finally something that works here! if (!isNil "playerName") then // if the string (unit player name) exist, so... { if (player == playerName) then // if the player in initPlayerLocal.sqf is playerName, so... { //code }; }; Share this post Link to post Share on other sites