Jump to content
Sign in to follow this  
xJordannx

What's wrong with this script?

Recommended Posts

Init.sqf:

masterUIDArray = ["########"];

if (getPlayerUID player in masterUIDArray) then {
   player addAction ["Spawn f35b", "Spawnf35b.sqf"];
};

Spawnf35b.sqf

_vehicle = createVehicle ["F35B", getPos player, [], 20, "CAN_COLLIDE"]; 

Basically, I want it so the person with the UID has an option to spawn an F35B, and this won't show the "Spawn f35b" option.

Edited by xJordannx

Share this post


Link to post
Share on other sites

What did you put in the masterUIDArray? ###### isn't a valid UID.

Share this post


Link to post
Share on other sites
What did you put in the masterUIDArray? ###### isn't a valid UID.

I put my UID of course :P, I'm not THAT stupid haha XD

I also tried:

if nameOfPlayer == "xJordannx" then {
   player addAction ["Spawn f35b", "Spawnf35b.sqf"];
};

And the option for "Spawn f35b" still wouldn't show up, however I tried just:

player addAction ["Spawn f35b", "Spawnf35b.sqf"];

And that worked, but I need it so only I can use it.

Edited by xJordannx

Share this post


Link to post
Share on other sites
if (player == unit1) then { unit1 addAction ["Spawn f35b", "Spawnf35b.sqf"] };

Share this post


Link to post
Share on other sites

getPlayerUID only returns something in MP.

Share this post


Link to post
Share on other sites

if nameOfPlayer == "xJordannx" then {
   player addAction ["Spawn f35b", "Spawnf35b.sqf"];
};

should be

if (name player == "xJordannx") then {
   player addAction ["Spawn f35b", "Spawnf35b.sqf"];
};

Share this post


Link to post
Share on other sites
if nameOfPlayer == "xJordannx" then {
   player addAction ["Spawn f35b", "Spawnf35b.sqf"];
};

should be

if (name player == "xJordannx") then {
   player addAction ["Spawn f35b", "Spawnf35b.sqf"];
};

Works, thanks! But is there any way to make it so it's the UID instead of the name?

Edited by xJordannx

Share this post


Link to post
Share on other sites
if (!isDedicated) then {
 if (!isMultiplayer) exitWith {player sidechat "Can only check whitelist in multiplayer"};
 waitUntil {!isNull player};
 waitUntil {getPlayerUID player != ""};
 _whitelist = ["123456","654321"]; // notice string format

 if ((getPlayerUID player) in _whitelist) then 
 {
   player addAction ["Spawn f35b", "Spawnf35b.sqf"];
 };
};

Share this post


Link to post
Share on other sites
if (!isDedicated) then {
 if (!isMultiplayer) exitWith {player sidechat "Can only check whitelist in multiplayer"};
 waitUntil {!isNull player};
 waitUntil {getPlayerUID player != ""};
 _whitelist = ["123456","654321"]; // notice string format

 if ((getPlayerUID player) in _whitelist) then 
 {
   player addAction ["Spawn f35b", "Spawnf35b.sqf"];
 };
};

Thanks, that works, but for some reason, when I respawn/die the option to spawn the f35b disappears, any idea why?

Share this post


Link to post
Share on other sites

You need to add a MPKilled or MPRespawn eventhandler and then add the action again.

Share this post


Link to post
Share on other sites
You need to add a MPKilled or MPRespawn eventhandler and then add the action again.

Could you explain how?

Share this post


Link to post
Share on other sites

I've never had the need to do this, so I couldn't off the top of my head. I could try.

init.sqf

{ _x addMPEventHandler ["MPKilled", { _handle=[] execVM "cuelScript.sqf" }]} forEach playableUnits;

or

{ _x addMPEventHandler ["MPRespawn", { _handle=[] execVM "cuelScript.sqf" }]} forEach playableUnits;

---------- Post added at 12:04 ---------- Previous post was at 11:54 ----------

You may also want to look into rADDACTION. I'm not sure, but it may even persist through death.

Share this post


Link to post
Share on other sites

Yes re-adding it after respawn is a good approach :) Hopefully this works, so you don't have to add event handlers for all units.

if (!isDedicated) then {
 if (!isMultiplayer) exitWith {player sidechat "Can only check whitelist in multiplayer"};
 waitUntil {!isNull player};
 waitUntil {getPlayerUID player != ""};
 _whitelist = ["123456","654321"]; // notice string format

 if ((getPlayerUID player) in _whitelist) then 
 {
   player addAction ["Spawn f35b", "Spawnf35b.sqf"];
   player addEventHandler ["Respawn",{player addAction ["Spawn f35b", "Spawnf35b.sqf"];}];
 };
};

Share this post


Link to post
Share on other sites
Yes re-adding it after respawn is a good approach :) Hopefully this works, so you don't have to add event handlers for all units.

if (!isDedicated) then {
 if (!isMultiplayer) exitWith {player sidechat "Can only check whitelist in multiplayer"};
 waitUntil {!isNull player};
 waitUntil {getPlayerUID player != ""};
 _whitelist = ["123456","654321"]; // notice string format

 if ((getPlayerUID player) in _whitelist) then 
 {
   player addAction ["Spawn f35b", "Spawnf35b.sqf"];
   player addEventHandler ["Respawn",{player addAction ["Spawn f35b", "Spawnf35b.sqf"];}];
 };
};

Doesn't seem to work

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×