Jump to content
Sign in to follow this  
AdirB

Check if player name

Recommended Posts

Hello,

I'm trying to create a script that only works if the player name is equal to the player name caught before.

if ((typeOf player) isEqualTo 'uns_US_1ID_PL' || (typeOf player) isEqualTo 'uns_US_1ID_RTO' || (typeOf player) isEqualTo 'uns_US_1ID_SL') then{ deleteVehicle intel1; deleteVehicle intel2; deleteVehicle intel3; table addAction ["Place Intel", "mission_scripts\intel\placeIntel.sqf"]; activatedPlayer = _this select 1; hint format ["%1 took the intel",name activatedPlayer]; }else{ hint "Only commanders or radio operators can take the intel!" };

if ((typeOf player) isEqualTo 'uns_US_1ID_PL' || (typeOf player) isEqualTo 'uns_US_1ID_RTO' || (typeOf player) isEqualTo 'uns_US_1ID_SL') then{

deleteVehicle intel1; deleteVehicle intel2; deleteVehicle intel3;

table addAction ["Place Intel", "mission_scripts\intel\placeIntel.sqf"];
activatedPlayer = _this select 1;
hint format ["%1 took the intel",name activatedPlayer];

}else{

hint "Only commanders or radio operators can take the intel!"
};

placeIntel.sqf

if (activatedPlayer isEqualTo name activatedPlayer) then{

_newObject = createVehicle ['Intel_File1_F', [4972.57,2999.52,2.71797e-005], [], 0, 'CAN_COLLIDE'];
_newObject setPosASL [4972.58,2999.51,2.58749];
_newObject setVectorDirAndUp [[0,0.999988,0.00497941], [-0.00248975,-0.0049794,0.999985]];
_newObject enableSimulation false;
 
_newObject = createVehicle ['Land_Map_F', [4972.75,2999.56,0.0118964], [], 0, 'CAN_COLLIDE'];
_newObject setPosASL [4972.75,2999.56,2.60002];
_newObject setVectorDirAndUp [[0,1,0], [0,0,1]];
_newObject enableSimulation false;

_newObject = createVehicle ['Land_Document_01_F', [4972.9,2999.43,-0.000119925], [], 0, 'CAN_COLLIDE'];
_newObject setPosASL [4972.9,2999.43,2.58774];
_newObject setVectorDirAndUp [[0.441818,0.897088,0.00556706], [-0.00248975,-0.0049794,0.999985]];
_newObject enableSimulation false;

hint "Intel is given to the HQ"

}else{

hint "Move back and let the person who took the intel to place it"
};

When activating the placeIntel.sqf script it returns me the else.

What have I done wrong?

Share this post


Link to post
Share on other sites

hint format ["%1 took the intel",name activatedPlayer];

 

What do you get in hint as "name activatedPlayer"? That is a key I guess, do u call this via trigger?

Share this post


Link to post
Share on other sites
2 minutes ago, riten said:

hint format ["%1 took the intel",name activatedPlayer];

 

What do you get in hint as "name activatedPlayer"? That is a key I guess, do u call this via trigger?

I get "Adir took the intel", Adir is my name.

I call the script via another script that adds the addActions, and this script is executed from the init.sqf.

Share this post


Link to post
Share on other sites

and what about variable "activatedPlayer", you get your ID right? If so you're getting false in your if codnition, because you're asking if your ID is equal to your player name which is false.

 

You could fix it by adding another variable for example:

 

if ((typeOf player) isEqualTo 'uns_US_1ID_PL' || (typeOf player) isEqualTo 'uns_US_1ID_RTO' || (typeOf player) isEqualTo 'uns_US_1ID_SL') then
{ 

deleteVehicle intel1; 
deleteVehicle intel2; 
deleteVehicle intel3; 

table addAction ["Place Intel", "mission_scripts\intel\placeIntel.sqf"]; 

ActivatedBy=[];
activatedPlayer = _this select 1; 
ActivatedBy=ActivatedBy+activatedPlayer;

hint format ["%1 took the intel",name activatedPlayer];

} else { hint "Only commanders or radio operators can take the intel!" };

 

then in your second script

 

if (activatedPlayer in ActivatedBy) then {...}

Share this post


Link to post
Share on other sites
9 minutes ago, riten said:

and what about variable "activatedPlayer", you get your ID right? If so you're getting false in your if codnition, because you're asking if your ID is equal to your player name which is false.

Right, then how can I check if activatedPlayer is equal to the players that activating placeIntel.sqf ?

Share this post


Link to post
Share on other sites
29 minutes ago, riten said:

and what about variable "activatedPlayer", you get your ID right? If so you're getting false in your if codnition, because you're asking if your ID is equal to your player name which is false.

 

You could fix it by adding another variable for example:

 


if ((typeOf player) isEqualTo 'uns_US_1ID_PL' || (typeOf player) isEqualTo 'uns_US_1ID_RTO' || (typeOf player) isEqualTo 'uns_US_1ID_SL') then
{ 

deleteVehicle intel1; 
deleteVehicle intel2; 
deleteVehicle intel3; 

table addAction ["Place Intel", "mission_scripts\intel\placeIntel.sqf"]; 

ActivatedBy=[];
activatedPlayer = _this select 1; 
ActivatedBy=ActivatedBy+activatedPlayer;

hint format ["%1 took the intel",name activatedPlayer];

} else { hint "Only commanders or radio operators can take the intel!" };

 

then in your second script

 

if (activatedPlayer in ActivatedBy) then {...}

Quote

15:26:56 Error in expression <_this select 1; 
ActivatedBy=ActivatedBy+activatedPlayer;

hint format ["%1 took>
15:26:56   Error position: <+activatedPlayer;

hint format ["%1 took>
15:26:56   Error +: Type Object, expected Number,Array,String,Not a Number
15:26:56 File C:\Users\me\Documents\Arma 3 - Other Profiles\Adir\missions\In Progress\Vietnam.RungSat\mission_scripts\intel\takeIntel.sqf, line 8

 

if ((typeOf player) isEqualTo 'uns_US_1ID_PL' || (typeOf player) isEqualTo 'uns_US_1ID_RTO' || (typeOf player) isEqualTo 'uns_US_1ID_SL') then{

deleteVehicle intel1; deleteVehicle intel2; deleteVehicle intel3;
table addAction ["Place Intel", "mission_scripts\intel\placeIntel.sqf"];

ActivatedBy=[];
activatedPlayer = _this select 1; 
ActivatedBy = ActivatedBy + activatedPlayer;

hint format ["%1 took the intel",name activatedPlayer];

}else{

hint "Only commanders or radio operators can take the intel!"
};

 

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  

×