Skip to content

Commit

Permalink
Merge pull request #38 from ole1986/2ndDetails
Browse files Browse the repository at this point in the history
2nd details
  • Loading branch information
ole1986 authored Nov 4, 2017
2 parents 5827a42 + e97d0be commit 9a498a7
Show file tree
Hide file tree
Showing 46 changed files with 411 additions and 408 deletions.
6 changes: 6 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
"isBuildCommand": true,
"args": [ "-Build"]
},
{
"suppressTaskName": true,
"taskName": "Build All, Install and Run",
"isBuildCommand": true,
"args": [ "-Build", "-Install", "-Run"]
},
{
"suppressTaskName": true,
"taskName": "Install and Run Client (Arma 3)",
Expand Down
Binary file modified @AdminToolkit/addons/admintoolkit.pbo
Binary file not shown.
Binary file modified @AdminToolkit/addons/admintoolkit.pbo.admintoolkit.bisign
Binary file not shown.
Binary file modified @AdminToolkitServer/addons/admintoolkit_server.pbo
Binary file not shown.
Binary file modified @AdminToolkitServer/addons/admintoolkit_servercfg.pbo
Binary file not shown.
Binary file modified @MissionFile/Exile.Tanoa.pbo
Binary file not shown.
39 changes: 0 additions & 39 deletions README.MissionFile.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,45 +81,6 @@ Extensions[] = {

- Once the menu is selected, it searches for the sqf file "MyExtension.sqf" in `atk\extension\MyExtension.sqf`. So, lets create this now:

```
// atk\extension\MyExtension.sqf (located in MissionFile)
private['_result'];
disableSerialization;
// add action command 'myext_hellotomyself' with the title 'Hello To Myself'
// the third parameter "false" skips the permission check - so admin AND moderator is allowed to execute
// NOTE: every action will be passed to the server with the command as unique identifier
['Hello To Myself', 'myext_hellotomyself', false] call AdminToolkit_addAction;
// add action to send something to server (REQUIRES SERVER SQF - Read more below!!! )
['Hello Server', 'myext_helloserver', false] call AdminToolkit_addAction;
// the callback, when "Run action" has been pressed
MyExtensionCallback = {
// AdminToolkit_Action is the current selected action
// AdminToolkit_Selection is the current selection from the list (either "Item 1" or "Item 2" - defined below)
// AdminToolkit_Params is the textbox where admin/moderator can enter addtional "parameters"
if(AdminToolkit_Action == "myext_hellotomyself") then {
// when myext_hellotomyself is the action, show a message to myself
[format["Hello %1", name player]] call AdminToolkit_showMessage;
};
if(AdminToolkit_Action == "myext_helloserver") then {
// REQUIRES SERVER SQF - Read more below!!!
['myext_helloserver', 'some secret text to the server'] call AdminToolkit_doAction;
};
};
// when admin/moderator pressed the "Run action" button call the "MyExtensionCallback" code
["MyExtensionCallback"] call AdminToolkit_onExecute;
// show two list items when menu is selected
_result = ["Item 1", "Item 2"];
_result;
```

As you can see, we have added to actions- The first (myext_hellotomyself) is a local call to showMessage only.
The second (and more interesting) action is passed to the server.

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## AdminToolkit for Arma 3
[![Version](https://img.shields.io/badge/Version-2.1.3-green.svg)](https://github.com/ole1986/a3-admintoolkit/releases)
[![Version](https://img.shields.io/badge/Version-2.2.0-green.svg)](https://github.com/ole1986/a3-admintoolkit/releases)
[![Author](https://img.shields.io/badge/Author-ole1986-green.svg)](https://github.com/ole1986)
[![Exile 1.0.3 Lemon](https://img.shields.io/badge/Exile-1.0.3%20Lemon-C72651.svg)](http://www.exilemod.com/devblog/103-update-lemon-r34/)
[![Arma 1.76](https://img.shields.io/badge/Arma-1.76-blue.svg)](https://dev.arma3.com/post/sitrep-00203)
Expand Down
3 changes: 2 additions & 1 deletion setup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ if($Install) {
Write-Host -ForegroundColor Green "DONE"
if($Run) {
Write-Host -NoNewline "Running Arma 3..."
& "$GameFolder/arma3battleye.exe" 2 1 0 -exe arma3_x64.exe -nosplash -world=empty -skipIntro
Start-Process "$GameFolder/arma3battleye.exe" -ArgumentList '2','1','0','-exe arma3_x64.exe', '-mod="@Exile;@AdminToolkit"', '-nosplash', '-world empty', '-skipIntro'
#& "$GameFolder/arma3battleye.exe" 2 1 0 -exe arma3_x64.exe -mod="@Exile;@AdminToolkit" -nosplash -world=empty -skipIntro
Write-Host -ForegroundColor Green "DONE"
}
}
Expand Down
14 changes: 6 additions & 8 deletions source/admintoolkit/bootstrap/fn_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,15 @@
* This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.
*/

private['_name'];

missionNamespace setVariable ['AdminToolkit_MainMenu', ['Players', 'Vehicles', 'Weapons', 'Buildings', 'Other', 'Items']];
missionNamespace setVariable ['AdminToolkit_MainMenu', ['Players', 'Weapons', 'Vehicles', 'Buildings', 'Items']];
// The current Menu selection
missionNamespace setVariable ['AdminToolkit_MenuIndex', nil];
// take the selection from list
missionNamespace setVariable ['AdminToolkit_Selection', nil];
// The current selected action
missionNamespace setVariable ['AdminToolkit_Action', nil];
// The current detail view
missionNamespace setVariable ['AdminToolkit_Detail', nil];
// the current parameters being executed (dependent on the action)
missionNamespace setVariable ['AdminToolkit_Params', nil];
missionNamespace setVariable ['AdminToolkit_Params', []];
// The current selected player (also used in spectator mode)
missionNamespace setVariable ['AdminToolkit_Player', nil];
// all player netIds received from server
Expand All @@ -34,7 +32,7 @@ missionNamespace setVariable ['AdminToolkit_permissionSet', []];
{
// make all IDC number easily accessible
// example "RscAdminToolkitTitle_IDC" returns the IDC of the Title of the dialog (which is 1900)
_name = format["%1_IDC", configName _x];
private _name = format["%1_IDC", configName _x];
missionNamespace setVariable [_name , getNumber(_x >> "IDC")];
} forEach ("true" configClasses (configFile >> "AdminToolkitMenu"));

Expand All @@ -51,7 +49,7 @@ missionNamespace setVariable ['AdminToolkit_permissionSet', []];
(findDisplay 46) displayAddEventHandler ["KeyDown","call AdminToolkit_bindKeyEvents;"];

systemChat "Logging into AdminToolkit...";
['login'] call AdminToolkit_doAction;
['login', "someRandomStuff1231"] call AdminToolkit_doAction;
};

diag_log "AdminToolkit postInit";
Expand Down
10 changes: 5 additions & 5 deletions source/admintoolkit/bootstrap/fn_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@
* This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.
*/

private ['_code', '_function', '_file'];

{
_code = '';
_function = _x select 0;
_file = _x select 1;
private _code = '';
private _function = _x select 0;
private _file = _x select 1;

_code = compileFinal preprocessFileLineNumbers _file;

Expand All @@ -26,8 +24,10 @@ forEach
['AdminToolkit_loadActions', 'admintoolkit\code\AdminToolkit_loadActions.sqf'],
['AdminToolkit_loadDetails', 'admintoolkit\code\AdminToolkit_loadDetails.sqf'],
['AdminToolkit_addMenu', 'admintoolkit\code\AdminToolkit_addMenu.sqf'],
['AdminToolkit_addParam', 'admintoolkit\code\AdminToolkit_addParam.sqf'],
['AdminToolkit_doAction', 'admintoolkit\code\AdminToolkit_doAction.sqf'],
['AdminToolkit_onActionChanged', 'admintoolkit\code\AdminToolkit_onActionChanged.sqf'],
['AdminToolkit_onDetailChanged', 'admintoolkit\code\AdminToolkit_onDetailChanged.sqf'],
['AdminToolkit_uiList', 'admintoolkit\code\AdminToolkit_uiList.sqf'],
['AdminToolkit_addAction', 'admintoolkit\code\AdminToolkit_addAction.sqf'],
['AdminToolkit_hasPermission', 'admintoolkit\code\AdminToolkit_hasPermission.sqf'],
Expand Down
7 changes: 3 additions & 4 deletions source/admintoolkit/code/AdminToolkit_addAction.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
* This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.
*/

private['_title', '_command', '_check', '_hasPerm', '_index'];
params['_title', '_command', '_check'];
disableSerialization;

_title = _this select 0;
_command = _this select 1;
_check = _this select 2;
private _hasPerm = false;
private _index = 0;

if(!(isNil "_check")) then {
// skip the permission check
Expand Down
5 changes: 3 additions & 2 deletions source/admintoolkit/code/AdminToolkit_addMenu.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
* This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.
*/

private['_title', '_ext', '_index', '_code', '_size'];
params['_title', '_ext'];
disableSerialization;

_title = _this select 0;
private _index = 0;
private _code = {};

_index = lbAdd [RscAdminToolkitMainMenu_IDC, _title];
// if extension parameter is set, load the file!
Expand Down
20 changes: 20 additions & 0 deletions source/admintoolkit/code/AdminToolkit_addParam.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
params ['_value', '_pos'];

if(!isNil "_pos") then {
_pos = parseNumber (_pos);
};

if(typeName AdminToolkit_Params != "ARRAY") then {
AdminToolkit_Params = [];
};

_size = (count AdminToolkit_Params);

if(_size > 0 && !isNil "_pos") then {
if((_pos + 1) <= _size) then {
AdminToolkit_Params set [_pos, _value];
};
} else {
AdminToolkit_Params pushBack _value;
};

9 changes: 5 additions & 4 deletions source/admintoolkit/code/AdminToolkit_bindKeyEvents.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
*
* This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.
*/

private['_handled'];
_handled = false;

switch (_this select 1) do
params['_control','_keydown'];

private _handled = false;

switch (_keydown) do
{
// Function Key 2 (F2)
case 0x3C:
Expand Down
125 changes: 39 additions & 86 deletions source/admintoolkit/code/AdminToolkit_doAction.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -7,100 +7,53 @@
* This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.
*/

private['_action', '_selection', '_tmp', '_tmp2', '_IDC'];
/**
* _action STRING what action
* _params ARRAY array of parameters for the action
*
*/
params['_action', '_params'];

private _tmp = '';

try {
if(count _this > 0) then {
_action = _this select 0;
} else {
_action = AdminToolkit_Action;
if(count _this < 1) then {
throw 'AdminToolkit_doAction requires at least one parameter';
};

if(isNil "_action") throw "NO ACTION SELECTED";

_IDC = RscAdminToolkitDetailList_IDC;

if((count _this) > 1) then {
_selection = _this select 1;
} else {
switch (_action) do
{
case 'login':
{
_selection = '';
};
case 'message':
{
_tmp = lbData [_IDC, lbCurSel _IDC];
_selection = [_tmp, AdminToolkit_Params];
};
case 'messageall': {
_selection = AdminToolkit_Params;
};
case 'givevehicle':
{
if(isNil "AdminToolkit_Player") then { throw "No player selected"; };

_selection = [lbData [_IDC, lbCurSel _IDC], netId AdminToolkit_Player];
};
case 'removevehicle': {
_selection = [lbData [_IDC, lbCurSel _IDC]];
};
case 'getweapon': {
_tmp = lbData [_IDC, lbCurSel _IDC];
_tmp2 = [_tmp] call AdminToolkit_weaponMagazine;

// parameter 1: weapon class name or empty when already in inventory
// parameter 2: compatible magazine
_selection = [_tmp, _tmp2];
};
case 'getammo': {
_tmp = lbData [_IDC, lbCurSel _IDC];
_tmp2 = [_tmp] call AdminToolkit_weaponMagazine;

// parameter 1: compatible magazine
_selection = [_tmp2];
};
case 'giveammo': {
_tmp = lbData [_IDC, lbCurSel _IDC];
switch(_action) do {
case 'message': {
_tmp = ctrlText RscAdminToolkitParam_IDC;
_params pushBack _tmp;
};
case 'messageall': {
_tmp = ctrlText RscAdminToolkitParam_IDC;
_params pushBack _tmp;
};
case 'spawn': {
_tmp = player modelToWorld [0,2, (position player) select 2];
_params pushBack _tmp;
};
case 'getweapon': {
_tmp = _params select 0;
_tmp = [_tmp] call AdminToolkit_weaponMagazine;

_params pushBack _tmp;
};
case 'getammo': {
_tmp = _params select 0;
_tmp = [_tmp] call AdminToolkit_weaponMagazine;

systemChat format["Giving ammo to %1", _tmp];
_selection = _tmp;
};
case 'spawn': {
_tmp = lbData [_IDC, lbCurSel _IDC];
_tmp2 = player modelToWorld [0,2, (position player) select 2];

systemChat format["spawn: %1 %2", _tmp, str _tmp2];
_selection = [_tmp, _tmp2];
};
case 'build': {
_selection = lbData [_IDC, lbCurSel _IDC];
};
case 'buildpers': {
AdminToolkitIsBuildingPersistent = true;
_selection = lbData [_IDC, lbCurSel _IDC];
};
case 'buildremove': {
_tmp = cursorObject;
if !(isNull _tmp) then {
_selection = [netId _tmp, getPosASL _tmp];
} else {
systemChat "No building found";
_selection = nil;
};
};
default
{
_selection = lbData [_IDC, lbCurSel _IDC];
};
};
_params = [_tmp];
};
};

if !(isNil "_selection") then {
[player, _action, _selection] remoteExecCall ['AdminToolkit_network_receiveRequest', 2];
if (!isNil "_params") then {
[player, _action, _params] remoteExecCall ['AdminToolkit_network_receiveRequest', 2];
systemChat format["Command '%1' executed", _action];
AdminToolkit_LastAction = [_action, _selection];
AdminToolkit_LastAction = [_action, _params];
} else {
systemChat format["ERROR: No parameters for '%1'", _action];
};
} catch {
systemChat format['EXCEPTION: %1', _exception];
Expand Down
7 changes: 3 additions & 4 deletions source/admintoolkit/code/AdminToolkit_hasPermission.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
* This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.
*/

private['_action', '_permissionSet', '_result'];
_action = _this select 0;
params['_action'];

_result = true;
_permissionSet = missionNamespace getVariable ['AdminToolkit_permissionSet', []];
private _result = true;
private _permissionSet = missionNamespace getVariable ['AdminToolkit_permissionSet', []];

if((count _permissionSet > 0) && !(_action in _permissionSet)) then {
_result = false;
Expand Down
Loading

0 comments on commit 9a498a7

Please sign in to comment.