Jump to content
Sign in to follow this  
Big_Daddy

Help getting Unit Name using Player Name

Recommended Posts

Ok, here is a question I'm throwing out to the group...

I'm trying to get a unit name (name from the editor)

I'm assuming it will include:

String = vehicleVarName objectName

I just don't know how to make the syntax.

_name = vehicleVarName (name player == "Big Daddy");

Something like that..

Thanks

Edit:

I'm trying to run this from the server. Keeping it off local boxes.

Edited by Big_Daddy

Share this post


Link to post
Share on other sites

There probably is a clever way without the loop but (until I learn that) I'd probably try:

{if (Name _x == "Big Daddy") exitwith {_name = VehicleVarName _x;);} foreach AllUnits;

Share this post


Link to post
Share on other sites

I'm confused as to what your goal is. Could you elaborate?

Do you want the unit's editor name (e.g. "mySpecialTank"), the unit's human name (e.g. "John Citizen" for AI, "1337d00d" for players) or the classname?

For what purpose do you want this name?

I'm guessing you want the editor name, but you must be wanting it for some complex reason, as there's no point getting the name of something you reference by name (vehicleVarName mySpecialTank == "mySpecialTank" seems kindof pointless to me).

Share this post


Link to post
Share on other sites

{if (Name _x == "Big Daddy") exitwith {_name = VehicleVarName _x;);} foreach AllUnits;

Becomes

private "_name";
{
if (Name _x == "Big Daddy") exitwith {
	_name = VehicleVarName _x;
}
} foreach AllUnits;

Fixed syntax, fixed scope issue.

Share this post


Link to post
Share on other sites

Here's what I'm trying to do...

I have a script that switch/cases the persons' name. Then runs a rearm script on the person. Now, that's not so tricky... right? I'm running the script outside the .pbo.. from the root of the server.

[] execvm "\rearm.sqf";

Now, it's working great, if the .sqf is in the game root of my local machine. (or the other guys).. But, I don't want to have to send them updated scripts everytime. So I want to run it from the dedicated server. Which will be my machine while testing and the leased dedicated server.

if (isserver) then {execvm "\rearm.sqf"};

That way, it runs from the dedi server, and not try to run locally. hence my guys will not need updated scripts locally.

Now the script I had before just called player and if player wasn't local it exited. but now player won't be local. so I need the name of the unit.

Now I know the easiest way would be to lock down units. Big Daddy uses unit BigD.. or something like that. But we have medic's, engineers, etc..

Here's what I have for running it local. I've started to update it with the mp framework so it works from the server. but don't know how to finish it..

Edit:

Seems to be working after doing some testing.. Just need to put it on the dedicated server..

if (isnil "RE") then {[] execVM "\ca\Modules\MP\data\scripts\MPframework.sqf"};
private "_name";
{if (Name _x == "Big Daddy") exitwith {_name = VehicleVarName _x;}} foreach AllUnits;

_name = call compile _name;
_playername = toLower (name _name);

switch(_playername)do 
{ 
case "big daddy":
{
	_nic = [_name, nil, rremoveAllWeapons, ""] call RE;
	{_nic = [_name, _name, "loc" + "per",raddmagazine, "100Rnd_556x45_BetaCMag"] call RE;} forEach [1,2,3];
	_nic = [_name, _name, "loc" + "per",raddWeapon, "m8_sharpshooter"] call RE;
	{_nic = [_name, _name, "loc" + "per",raddmagazine, "10Rnd_127x99_m107"] call RE;} forEach [1,2,3,4,5,6,7,8];
	_nic = [_name, _name, "loc" + "per",raddWeapon, "m107"] call RE;
	{_nic = [_name, _name, "loc" + "per",raddmagazine, "SMAW_HEAA"] call RE;} forEach [1,2,3,4];
	_nic = [_name, _name, "loc" + "per",raddWeapon, "SMAW"] call RE;
	{_nic = [_name, _name, "loc" + "per",raddmagazine, "pipebomb"] call RE;} forEach [1,2];
	_nic = [_name, _name, "loc" + "per",raddweapons, "binocular"] call RE;
	_nic = [_name, _name, "loc" + "per",raddweapons, "NVGoggles"] call RE;
};
case "saint blitz":
{
	_nic = [_name, nil, rremoveAllWeapons, ""] call RE;
	{_nic = [_name, _name, "loc" + "per",raddmagazine, "100Rnd_556x45_BetaCMag"] call RE;} forEach [1,2,3];
	_nic = [_name, _name, "loc" + "per",raddWeapon, "m8_sharpshooter"] call RE;
	{_nic = [_name, _name, "loc" + "per",raddmagazine, "10Rnd_127x99_m107"] call RE;} forEach [1,2,3,4,5,6,7,8];
	_nic = [_name, _name, "loc" + "per",raddWeapon, "m107"] call RE;
	{_nic = [_name, _name, "loc" + "per",raddmagazine, "SMAW_HEAA"] call RE;} forEach [1,2,3,4];
	_nic = [_name, _name, "loc" + "per",raddWeapon, "SMAW"] call RE;
	{_nic = [_name, _name, "loc" + "per",raddmagazine, "pipebomb"] call RE;} forEach [1,2];
	_nic = [_name, _name, "loc" + "per",raddweapons, "binocular"] call RE;
	_nic = [_name, _name, "loc" + "per",raddweapons, "NVGoggles"] call RE;
};
default
{
	_nic = [_name, nil, rremoveAllWeapons, ""] call RE;
	{_nic = [_name, _name, "loc" + "per",raddmagazine, "100Rnd_556x45_BetaCMag"] call RE;} forEach [1,2,3];
	_nic = [_name, _name, "loc" + "per",raddWeapon, "m8_sharpshooter"] call RE;
	{_nic = [_name, _name, "loc" + "per",raddmagazine, "10Rnd_127x99_m107"] call RE;} forEach [1,2,3,4,5,6,7,8];
	_nic = [_name, _name, "loc" + "per",raddWeapon, "m107"] call RE;
	{_nic = [_name, _name, "loc" + "per",raddmagazine, "SMAW_HEAA"] call RE;} forEach [1,2,3,4];
	_nic = [_name, _name, "loc" + "per",raddWeapon, "SMAW"] call RE;
	{_nic = [_name, _name, "loc" + "per",raddmagazine, "pipebomb"] call RE;} forEach [1,2];
	_nic = [_name, _name, "loc" + "per",raddweapons, "binocular"] call RE;
	_nic = [_name, _name, "loc" + "per",raddweapons, "NVGoggles"] call RE;
};
};

Edited by Big_Daddy
Added Rommel's code:

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  

×