Jump to content
Sign in to follow this  
xgamer224

addaction depending on PlayerID

Recommended Posts

i want to make a script that will spawn a vehicle depending on the user's PlayerID

Right now, all i have is a vehicle spawner that can be used for all players...

spawner:

position[]={4132.4795,339.01843,10911.304};
		azimut=145;
		special="NONE";
		id=14;
		side="EMPTY";
		vehicle="Base_WarfareBContructionSite";
		leader=1;
		skill=0.60000002;
		init="0 = [] execVm ""Spawner.SQF""; _spawner = this addAction [""Spawn HMWV"",""Spawner.sqf"",[""_Marker"",""HMMWV_MK19""]]; _spawner = this addAction [""Spawn M1A2_TUSK_MG"",""Spawner.sqf"",[""_Marker"",""M1A2_TUSK_MG""]]; _spawner = this addAction [""Spawn Towing Tractor"",""Spawner.sqf"",[""_Marker"",""TowingTractor""]]; _spawner = this addAction [""Spawn Vodnik"",""Spawner.sqf"",[""_Marker"",""GAZ_Vodnik_HMG""]];";

Spawner.sqf:

// 0 = [] execVm "Spawner.SQF"; \\
_marker = _this select 3 select 0;
_class = _this select 3 select 1;
_azimut = _this select 3 select 2;

_class createVehicle getMarkerPos _marker;

what i want to do is make it so that only certain users can spawn vehicles. like if playerid=""1234567" init="0 = [] execVm ""Spawner.SQF"";

can someone help me out?

Share this post


Link to post
Share on other sites

There's been a bunch of "based on playerID" questions recently. Search for forum and you'll see the examples. The command you're looking for is getPlayerUID

Share this post


Link to post
Share on other sites

//assignActions.sqf
_object = _this select 0;
_marker = _this select 1;
_availableVehicles = switch (getPlayerUID player) do
{
  case "111222": //Player with UID 111222
  {
      ["HMMWV_MK19", "M1A2_TUSK_MG", "TowingTractor", "GAZ_Vodnik_HMG"]
  };
  case "222333": //Player with UID 222333
  {
      ["HMMWV_MK19", "TowingTractor", "GAZ_Vodnik_HMG"]
  };
  default //Everyone else
  {
      ["TowingTractor"]
  };
};

{
  _object addAction [format ["Spawn %1", getText(configFile >> "CfgVehicles" >> _x >> "displayName")], //Fetch the vehicle name from the config
     "spawner.sqf",
     [_marker, _x]];
} forEach _availableVehicles;

Then add this to the buildings init field:

0 = [this, "MARKERNAME"] execVM "assignActions.sqf"

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  

×