Jump to content
Anjan-Riot

Need help with UID script

Recommended Posts

Hi all,

i need help with this script, it worked before but not now i don't get an error so i don't know what the problem is.

Here is the script rslots.sqf:

private ["_reserved_units", "_reserved_uids", "_uid"];

waitUntil {!isNull player};
waitUntil {(vehicle player) == player};
waitUntil {(getPlayerUID player) != ""};

_reserved_units = ["unit_0","unit_1"];
_reserved_uids = ["1234567890"];
_uid = getPlayerUID player;

if ((player in _reserved_units)&& !(_uid in _reserved_uids)) then {
  sleep 20;
  hint "You are in a member slot, kicking to lobby in 10 seconds";
  sleep 10;
  failMission "end1";
};

i call the sript via the units init field like that:

nul = this execVM "scripts\rslots.sqf";

Share this post


Link to post
Share on other sites

try to put it in init.sqf without the "this"

[] execVM ....

Share this post


Link to post
Share on other sites

thanks but same thing just don't work.

I made test hints and they show up but no id check.

Share this post


Link to post
Share on other sites

couple of things - have you check both unit_0 and unit_1 are still in the editor? or named correctly?

I assume this is hosted mutliplayer - could try and to remove the player usage but if its not working with one player in game there is something else wrong -

kick = [this] execVM "scripts\rslots.sqf";  

private ["_reserved_units", "_reserved_uids", "_uid"];
_playerHuman = _this select 0;

waitUntil {!isNull _playerHuman };
waitUntil {(vehicle _playerHuman ) == _playerHuman };
waitUntil {(getPlayerUID _playerHuman ) != ""};


_reserved_units = ["unit_0","unit_1"];
_reserved_uids = ["1234567890"];
_uid = getPlayerUID _playerHuman ;
Hint format ["Player: %1, UID: %2", _playerHuman, _uid];
sleep 3;


if ((_playerHuman in _reserved_units)&& !(_uid in _reserved_uids)) then {
  sleep 20;
  hint "You are in a member slot, kicking to lobby in 10 seconds";
  sleep 10;
  failMission "end1";
};  

Share this post


Link to post
Share on other sites
couple of things - have you check both unit_0 and unit_1 are still in the editor? or named correctly?

Yes i checked both they are in the editor and named correctly.

I know there is no id check in the editor but it kept kicking me out when the script was working.

Share this post


Link to post
Share on other sites

ok I think it's the fact that your reserved units array is string, and player is an object. It will never find it.

remove quote around unit_0 and unit_1 and try again?

Share this post


Link to post
Share on other sites

Well it works half,

for just one player and I get an error:

error.png

I try it with this:

private ["_reserved_units", "_reserved_uids", "_uid", "_u0", "_u1"];

waitUntil {!isNull player};
waitUntil {(vehicle player) == player};
waitUntil {(getPlayerUID player) != ""};

_u0 = [unit0];
_u1 = [unit1];
_reserved_units = _u0 + _u1;
_reserved_uids = ["1234567890"];
_uid = getPlayerUID player;

if ((player in _reserved_units)&& !(_uid in _reserved_uids)) then {
  sleep 20;
  hint "You are in a member slot, kicking to lobby in 10 seconds";
  sleep 10;
  failMission "end1";
};  

but no luck:

error1.png

The strange thing is that both slots working but if you connect with two player then it only works for the first one that connects.

Edited by Anjan-Riot

Share this post


Link to post
Share on other sites

unit0 or unit_0 - have you changed it? have you removed the player part totally - error shows player still present

Edited by Mikie boy

Share this post


Link to post
Share on other sites

yes i change it in the script and on the units in the editor

sorry wrong code I updated it

Edited by Anjan-Riot

Share this post


Link to post
Share on other sites

I modified your script slightly (added while true so it will persist after respawn) and tried it out, works perfect. Nice and simple reserved slot script. I have a unit placed down called Reserved01 and the script is called in the init line of it.

while {true} do 
{

private ["_reserved_units", "_reserved_uids", "_uid"];

waitUntil {!isNull player};
waitUntil {(vehicle player) == player};
waitUntil {(getPlayerUID player) != ""};

_reserved_units = [Reserved01];
_reserved_uids = ["123456780"];
_uid = getPlayerUID player;

if ((player in _reserved_units)&& !(_uid in _reserved_uids)) then 
 {
  hint "You are in a reserved slot! You will be kicked to the lobby in 15 seconds!";
  sleep 5;
  hint "You are in a reserved slot! You will be kicked to the lobby in 10 seconds!";
  sleep 5;
  hint "You are in a reserved slot! You will be kicked to the lobby in 5 seconds!";
  sleep 5;
  failMission "end1";
 };  

};

Share this post


Link to post
Share on other sites

Thanks a lot I have to test it with two slots and another client, tomorrow.

Share this post


Link to post
Share on other sites

After some testing it also works only with one slot/player even if i use the script twice like unit0/rslot0.sqf and unit1/rslot1.sqf. The 2nd player always get kicked to the lobby.

I have no idea.

Share this post


Link to post
Share on other sites

maybe the failMission "end1" is for something? maybe it kills something since it is supposed to be thrown only if the mission ends for a unit.

do you have respawn in your mission?

where is it called from now? is it in the init of the unit or in the init.sqf?

something is not rigning well in my head with this script ;-)

using 'player' does not sound like a good idea.

assuming init line of unit, if you were passing 'this' to the script and doing a waituntil isPlayer _this ( and /or _this ==player) , then doing your verification stuff. and adding an event "respawn" to _this that would put back your loop in case of player respawning...

there is some black area where I can't tell how it will react.

hope this is inspiring you for some more tries...

Edited by holo89

Share this post


Link to post
Share on other sites

Ok made this from your code guys

name this file reserved_unit_check.sqf

// *Put that code in the init of reserved units, that will tag it as *Reserved*
//this setVariable ["reserved_unit","Yes it is",true]; this addEventHandler ["respawn", {(_this select 0) setVariable ["reserved_unit","Yes it is",true];}];

//in init.sqf call this script with:
// execVM "reserved_unit_check.sqf";
private ["_reserved_uids", "_uid", "_isReserved"];

if (!isServer) then // must be run by players only
{  //will not run on Host since host is the server and should be able to use reserved slot anyway?? (otherwise use !isDedicated)
   waitUntil {!isNull player};
   _isReserved = player getVariable "reserved_unit";
   if (!isNil "_isReserved") then  //if variable is set for the player, he is using a reserved unit
   {
       waitUntil {_uid = getPlayerUID player; _uid != ""};

       _reserved_uids = ["123456780", "09876543"]; //put your clans or whatever UID here to be able to use reserved units

       if (!(_uid in _reserved_uids)) then 
       {
           hint "You are in a reserved slot! You will be kicked to the lobby in 15 seconds!";
           sleep 5;
           hint "You are in a reserved slot! You will be kicked to the lobby in 10 seconds!";
           sleep 5;
           hint "You are in a reserved slot! You will be kicked to the lobby in 5 seconds!";
           sleep 5;
           failMission "end1";
       } else 
       {
           hint "You have been verified and allowed to this reserved slot";
       };

   };
};

This way you can have as much reserved units as you want to, no unit naming needed

I tested it quick with a hosted game and worked (using !isDedicated as mentioned). But it does need more intensive testing with dedicated server using more than one player.

Feel free to modify to your needs.

edit1:

just to make sure it's clear

In init of unit you put: this setVariable ["reserved_unit","Yes it is",true]; this addEventHandler ["respawn", {(_this select 0) setVariable ["reserved_unit","Yes it is",true];}];

copy all the code in the PHP window above to a file called reserved_unit_check.sqf in the root of your mission (with init.sqf)

In init.sqf you put: execVM "reserved_unit_check.sqf";

Edited by holo89
precision

Share this post


Link to post
Share on other sites

Does this still work, how do i make this work for 3 slots ? i don't see any part of the code where i put the ai player name

Share this post


Link to post
Share on other sites

I dont see why it shouldnt. you cant use a players name in it u have to use the players User ID (UID). Its all descdribed in the comments of the code:

 

 

// *Put that code in the init of reserved units, that will tag it as *Reserved*

this setVariable ["reserved_unit","Yes it is",true]; 
this addEventHandler ["respawn", {(_this select 0) setVariable ["reserved_unit","Yes it is",true];}];
 _reserved_uids = ["123456780", "09876543"];  
//put your clans or whatever UID here to be able to use reserved units

but finally u should substitue this line:

failMission "end1";

with this

"end1" call BIS_fnc_endMission;

because of this comment:

 

To maintain Arma 3 visual style, it's recommended to use BIS_fnc_endMission instead.

in this BIKI entry:

failMission

 

 

I feel like on a Groundhog Day

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

×