Jump to content
BradApex

Getting players in a Listbox.

Recommended Posts

Hello,

 

I have a Messaging system I am making and I can't seem to get the _data part to display the Players name when the message is shown.

 

// Playerlist.sqf

// playerList.sqf

params["_disp","_list","_units","_type","_dialog","_ListBox","_data"];

// get the listbox
_list = _disp displayCtrl 5690; // <--- listbox IDC here its always 1500 xd

{
    if (alive _x && isPlayer _x) then 
	{
        _type = switch (side _x) do 
		{
            case independent: {"PMC"};
        };
        _temp = _list lbAdd format ["%1 - %2",_x getVariable ["realname",name _x],_type];
        _temp lbSetData [-1,str(_x)];
    };
} forEach playableUnits;

 

Players list file does what it says and It works fine the next two files that are having issues.

 

// reciveMessage.sqf

params ["_sender","_text"];

[format["NEW SMS<br/>"], format["NEW SMS:<br/>%1. <br/><br/>SENT FROM: %3 <br/><br/>FROM: %2",_text, name _sender, mapGridPosition player], [0,1,0,1]] call APX_fnc_showNotification;
playSound "newSMS";
// sendMessage.sqf

private _text = ctrlText 1400;
private _datagetsender = lbdata [5690,(lbCurSel 5690)]; // get selected row invisible data

[format["SMS<br/>"], format["SMS PREVIEW:<br/>%1. <br/><br/>SENT FROM: %3 <br/><br/>SENT TO: %2",_text, _datagetsender, mapGridPosition player], [1,0,0,1]] call APX_fnc_showNotification;
[profileName,_text] remoteExec ["APX_fnc_recieveMessage",_datagetsender];

// This is the main message that they get a preview off when they send the message. so the SENT TO: %2 is ment to be thier profile name. and with the recivemessage only the var is _sender

 

  • Like 1

Share this post


Link to post
Share on other sites

try this

 

_datagetsender = missionNamespace getVariable ( _datagetsender );

//or
  
_datagetsender = missionNamespace getVariable ( lbData [ 5690, lbCurSel 5690 ] );

 

Share this post


Link to post
Share on other sites
9 minutes ago, DÄZ said:

try this

 


_datagetsender = missionNamespace getVariable ( _datagetsender );

//or
  
_datagetsender = missionNamespace getVariable ( lbData [ 5690, lbCurSel 5690 ] );

 

 

Hey, @DÄZ may seem a stupid question but wich file both files? or just one?

Share this post


Link to post
Share on other sites
// sendMessage.sqf

private _text = ctrlText 1400;
private _datagetsender = lbdata [5690,(lbCurSel 5690)]; // get selected row invisible data

_datagetsender = missionNamespace getVariable ( _datagetsender );

[format["SMS<br/>"], format["SMS PREVIEW:<br/>%1. <br/><br/>SENT FROM: %3 <br/><br/>SENT TO: %2",_text, _datagetsender, mapGridPosition player], [1,0,0,1]] call APX_fnc_showNotification;
[profileName,_text] remoteExec ["APX_fnc_recieveMessage",_datagetsender];

 

example of how I use it:

_index = lbCurSel 2100;
_uid = lbData [2100, _index];
_code = ctrlText 1400;

_text_admin_Err = format ["<t color='#F68617'  >ERREUR: vous n'avez pas rentrer de code </t><br />"];
_text_admin_Err_joueur = format ["<t color='#F68617'  >Erreur: Aucun Joueur sélectionnée </t><br />"];	

	if (_uid == "") exitWith {hint parseText (_text_admin_Err_joueur);};
	if (_code == "") exitWith {hint parseText (_text_admin_Err); };
	
_uid = missionNamespace getVariable ( _uid );

_text_admin = format ["<t color='#495CFF'  >Code exécuté: sur %1</t><br />",name _uid];

	hint parseText (_text_admin);

				_code remoteExec ["DAZ_BCM_ADMIN_fnc_Execute", _uid];
				
	sleep 2;

hint "";

 

  • Like 1

Share this post


Link to post
Share on other sites
2 hours ago, DÄZ said:

// sendMessage.sqf

private _text = ctrlText 1400;
private _datagetsender = lbdata [5690,(lbCurSel 5690)]; // get selected row invisible data

_datagetsender = missionNamespace getVariable ( _datagetsender );

[format["SMS<br/>"], format["SMS PREVIEW:<br/>%1. <br/><br/>SENT FROM: %3 <br/><br/>SENT TO: %2",_text, _datagetsender, mapGridPosition player], [1,0,0,1]] call APX_fnc_showNotification;
[profileName,_text] remoteExec ["APX_fnc_recieveMessage",_datagetsender];

 

example of how I use it:


_index = lbCurSel 2100;
_uid = lbData [2100, _index];
_code = ctrlText 1400;

_text_admin_Err = format ["<t color='#F68617'  >ERREUR: vous n'avez pas rentrer de code </t><br />"];
_text_admin_Err_joueur = format ["<t color='#F68617'  >Erreur: Aucun Joueur sélectionnée </t><br />"];	

	if (_uid == "") exitWith {hint parseText (_text_admin_Err_joueur);};
	if (_code == "") exitWith {hint parseText (_text_admin_Err); };
	
_uid = missionNamespace getVariable ( _uid );

_text_admin = format ["<t color='#495CFF'  >Code exécuté: sur %1</t><br />",name _uid];

	hint parseText (_text_admin);

				_code remoteExec ["DAZ_BCM_ADMIN_fnc_Execute", _uid];
				
	sleep 2;

hint "";

Thanks Daz ill give that a go and get back to you. 

 

Share this post


Link to post
Share on other sites
_player = str player; _player = call compile _player; // Doesn't work and _player won't be usable in script
_player = "player"; _player = call compile _player; // Works and _player is usable in script
// Same deal with "playableUnits select 0" or (str playableUnits select 0)

// If unit has a variable assigned in editor
_player = str player; // Returns player's assigned variable in string form
_player = _player call compile _player; // Will return the players assigned variable and is usable in script
// Works with "playableUnits select 0" or (str playableUnits select 0)

If you wish to use str command(https://community.bistudio.com/wiki/str) on a player or playable unit. And then you wish to use call compile you must have a variable assigned to that specific player in editor/mission.sqm.

The compile command does compile the string that has been created with str but you still cant call the compiled code. Example:

_player = str _player; _player = compile _player; // Returns {B Alpha 1-1:1([AG] KillerAussie)} - Will be different for everyone.

// Now trying to call our newly compiled code.
call _player; // Returns Nada.

Call command: https://community.bistudio.com/wiki/call

Compile command: https://community.bistudio.com/wiki/compile

  • Like 1
  • Thanks 1

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

×