Skip to content

Commit

Permalink
Merge pull request #9 from KillahPotatoes/v2.0.1
Browse files Browse the repository at this point in the history
V2.0.1
  • Loading branch information
Wyqer authored Aug 2, 2018
2 parents 8f23afe + 1e7388a commit 55d63f9
Show file tree
Hide file tree
Showing 18 changed files with 301 additions and 32 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,19 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

## Changelog
### v2.0.1
* Added: Getter/Setter and helpful functions, so content/mission creators can easily access the KP Ranks data.
* [KPR_fnc_getRank](https://github.com/KillahPotatoes/KP-Ranks/blob/master/addons/KP_Ranks/fnc/fn_getRank.sqf)
* [KPR_fnc_setRank](https://github.com/KillahPotatoes/KP-Ranks/blob/master/addons/KP_Ranks/fnc/fn_setRank.sqf)
* [KPR_fnc_hasRank](https://github.com/KillahPotatoes/KP-Ranks/blob/master/addons/KP_Ranks/fnc/fn_hasRank.sqf)
* [KPR_fnc_getScore](https://github.com/KillahPotatoes/KP-Ranks/blob/master/addons/KP_Ranks/fnc/fn_getScore.sqf)
* [KPR_fnc_setScore](https://github.com/KillahPotatoes/KP-Ranks/blob/master/addons/KP_Ranks/fnc/fn_setScore.sqf)
* [KPR_fnc_addScore](https://github.com/KillahPotatoes/KP-Ranks/blob/master/addons/KP_Ranks/fnc/fn_addScore.sqf)
* Added: If all players are deleted from the player list, the server will reinitialize the list with all connected players.
* Updated: Polish localization. Thanks to [veteran29](https://github.com/veteran29)
* Fixed: Small uncritical script error on map screen, when there is no player registered on the server.
* Fixed: Needed restart of the server/mission, if all players were deleted via the player management dialog.

### v2.0.0
* Added: New codebase.
* Added: Usage of CfgFunctions.
Expand Down
18 changes: 9 additions & 9 deletions addons/KP_Ranks/KP_uiDefines.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
File: KP_uiDefines.hpp
Author: Wyqer - https://github.com/KillahPotatoes
Date: 2018-07-10
Last Update: 2018-07-18
Last Update: 2018-07-27
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
Description:
Expand Down Expand Up @@ -282,7 +282,7 @@ class KP_DialogButtonL: KP_Button {
#define KP_X_VAL_C 0.035
#define KP_Y_VAL_C 0.05

#define KP_WIDTH_VAL_C 0.25
#define KP_WIDTH_VAL_C 0.2
#define KP_HEIGHT_VAL_C (0.75 - KP_HEIGTH_TITLE - KP_HEIGTH_BUTTON - 2 * KP_SPACING_Y)

// Title bar
Expand All @@ -293,22 +293,22 @@ class KP_DialogTitleC: KP_Title {
};

// Cross symbol
class KP_DialogCrossL: KP_CloseCross {
x = KP_GETX_CROSS(KP_X_VAL_C);
class KP_DialogCrossC: KP_CloseCross {
x = safeZoneX + safeZoneW * (KP_X_VAL_C + KP_WIDTH_VAL_C - 0.02)
y = KP_GETY_CROSS(KP_Y_VAL_C);
};

// Background
class KP_DialogBackgroundL: KP_Background {
class KP_DialogBackgroundC: KP_Background {
x = KP_GETX(KP_X_VAL_C,KP_WIDTH_VAL_C,0,1);
y = KP_GETY_AREA(KP_Y_VAL_C);
w = KP_GETWPLAIN(KP_WIDTH_VAL_C,1);
h = safeZoneH * KP_HEIGHT_VAL_C;
};

// Button pos 1 in 2 button row
class KP_DialogButtonL: KP_Button {
x = KP_GETX(KP_X_VAL_C,KP_WIDTH_VAL_C,0,2);
// Button
class KP_DialogButtonC: KP_Button {
x = KP_GETX(KP_X_VAL_C,KP_WIDTH_VAL_C,0,1);
y = KP_GETY_BELOW(KP_Y_VAL_C,KP_HEIGHT_VAL_C);
w = KP_GETWPLAIN(KP_WIDTH_VAL_C,2);
w = KP_GETWPLAIN(KP_WIDTH_VAL_C,1);
};
30 changes: 24 additions & 6 deletions addons/KP_Ranks/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
File: config.cpp
Author: Wyqer - https://github.com/KillahPotatoes
Date: 2018-07-09
Last Update: 2018-07-19
Last Update: 2018-07-23
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
Description:
Expand All @@ -19,7 +19,7 @@ class CfgPatches {
class KP_Ranks {
author = "Wyqer";
name = "KP Ranks";
url = "https://www.killahpotatoes.de";
url = "https://github.com/KillahPotatoes/KP-Ranks";
units[] = {"KPR_force"};
weapons[] = {};
requiredVersion = 1.82;
Expand All @@ -28,9 +28,9 @@ class CfgPatches {
"cba_main"
};
versionDesc = "KP Ranks";
version = 2.0.0;
versionStr = "2.0.0";
versionAr[] = {2,0,0};
version = 2.0.1;
versionStr = "2.0.1";
versionAr[] = {2,0,1};
authors[] = {"Wyqer"};
};
};
Expand Down Expand Up @@ -113,7 +113,7 @@ class CfgVehicles {
is3DEN = 0;

class Attributes: AttributesBase {
class ModuleDescription: ModuleDescription{};
class ModuleDescription: ModuleDescription {};
};

class ModuleDescription: ModuleDescription {
Expand Down Expand Up @@ -144,6 +144,9 @@ class CfgFunctions {
// Adds a new player to the player list
class addPlayer {};

// Adds value (positive or negative) to a player score
class addScore {};

// Applies rank insignia to player
class applyRank {};

Expand All @@ -159,6 +162,15 @@ class CfgFunctions {
// Request ACE ace_medical_lastDamageSource variable from unit owner
class getAceKiller {};

// Get the rank of a player
class getRank {};

// Get the score of a player
class getScore {};

// Check if player has at least given rank
class hasRank {};

// Inizialize ACE self interaction entries
class initACE {};

Expand Down Expand Up @@ -213,6 +225,12 @@ class CfgFunctions {
// Apply the default values for the uniform list
class setDefaultUniforms {};

// Sets the rank of a player to given value
class setRank {};

// Sets the score of a player to given value
class setScore {};

// Shows a hint for 3 seconds
class showHint {};

Expand Down
34 changes: 34 additions & 0 deletions addons/KP_Ranks/fnc/fn_addScore.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
KPR_fnc_addScore
File: fn_addScore.sqf
Author: Wyqer - https://github.com/KillahPotatoes
Date: 2018-07-23
Last Update: 2018-07-23
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
Description:
Changes the score of a given player. Returns true on success and false if the player wasn't found.
Parameter(s):
0: STRING - Steam UID of the player
1: NUMBER - Amount of points to add to the player score. Can be negative to substract. (default: 0)
Returns:
BOOL
*/

if (!isServer) exitWith {false};

params ["_uid", ["_change", 0]];

private _index = KPR_players findIf {_x select 1 == _uid};

// Return false, if uid wasn't found in the players array
if (_index == -1) exitWith {false};

// Adjust score and save
KPR_players select _index set [5, (KPR_players select _index select 5) + _change];
[KPR_players] call KPR_fnc_savePlayers;

true
5 changes: 4 additions & 1 deletion addons/KP_Ranks/fnc/fn_applyRank.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
File: fn_applyRank.sqf
Author: Wyqer - https://github.com/KillahPotatoes
Date: 2018-07-09
Last Update: 2018-07-19
Last Update: 2018-07-22
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
Description:
Expand All @@ -20,6 +20,9 @@

params [["_showHint", false]];

// Exit, if KPR_players list is empty.
if (KPR_players isEqualTo []) exitWith {};

// Get current player list index
private _indexP = KPR_players findIf {_x select 1 == getPlayerUID player};

Expand Down
29 changes: 29 additions & 0 deletions addons/KP_Ranks/fnc/fn_getRank.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
KPR_fnc_getRank
File: fn_getRank.sqf
Author: Wyqer - https://github.com/KillahPotatoes
Date: 2018-07-23
Last Update: 2018-07-23
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
Description:
Gets the current rank of a given player. Identified by the Steam UID.
Returns the current rank as number. If the Steam UID wasn't found it returns -1.
Parameter(s):
0: STRING - Steam UID of the player
Returns:
NUMBER
*/

params ["_uid"];

private _index = KPR_players findIf {_x select 1 == _uid};

// Return -1, if uid wasn't found in the players array
if (_index == -1) exitWith {_index};

// Return rank, if player was found
KPR_players select _index select 2
29 changes: 29 additions & 0 deletions addons/KP_Ranks/fnc/fn_getScore.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
KPR_fnc_getScore
File: fn_getScore.sqf
Author: Wyqer - https://github.com/KillahPotatoes
Date: 2018-07-23
Last Update: 2018-07-23
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
Description:
Gets the current score of a given player. Identified by the Steam UID.
Returns the current score as number. If the Steam UID wasn't found it returns -1.
Parameter(s):
0: STRING - Steam UID of the player
Returns:
NUMBER
*/

params ["_uid"];

private _index = KPR_players findIf {_x select 1 == _uid};

// Return -1, if uid wasn't found in the players array
if (_index == -1) exitWith {_index};

// Return score, if player was found
KPR_players select _index select 5
29 changes: 29 additions & 0 deletions addons/KP_Ranks/fnc/fn_hasRank.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
KPR_fnc_hasRank
File: fn_hasRank.sqf
Author: Wyqer - https://github.com/KillahPotatoes
Date: 2018-07-23
Last Update: 2018-07-23
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
Description:
Checks if the given player has at least the given rank.
Returns true if he has and false if the player hasn't or wasn't found.
Parameter(s):
0: STRING - Steam UID of the player
1: NUMBER - Rank to check (default: 0)
Returns:
BOOL
*/

params ["_uid", ["_rank", 0]];

private _index = KPR_players findIf {_x select 1 == _uid};

// Return false, if uid wasn't found in the players array
if (_index == -1) exitWith {false};

(KPR_players select _index select 2 >= _rank)
5 changes: 2 additions & 3 deletions addons/KP_Ranks/fnc/fn_initRanks.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
File: fn_initRanks.sqf
Author: Wyqer - https://github.com/KillahPotatoes
Date: 2018-07-09
Last Update: 2018-07-19
Last Update: 2018-08-02
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
Description:
Expand Down Expand Up @@ -132,8 +132,7 @@ if (hasInterface) then {
} else {
// Add vanilla actions and respawn EH
player addEventHandler ["Respawn", {
params ["_unit", "_corpse"];
[_corpse] call KPR_fnc_addActions;
[_this select 1] call KPR_fnc_addActions;
}];
call KPR_fnc_addActions;
};
Expand Down
19 changes: 12 additions & 7 deletions addons/KP_Ranks/fnc/fn_savePlayers.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
File: fn_savePlayers.sqf
Author: Wyqer - https://github.com/KillahPotatoes
Date: 2018-07-10
Last Update: 2018-07-19
Last Update: 2018-07-23
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
Description:
Expand All @@ -21,12 +21,17 @@ if (!isServer) exitWith {};

params [["_newList", []]];

if !(_newList isEqualTo []) then {
KPR_players = +_newList;
KPR_players sort true;
profileNamespace setVariable ["KPR_players", KPR_players];
saveProfileNamespace;
publicVariable "KPR_players";
// Reinitialize with all current players, if list gets fully deleted
if (_newList isEqualTo []) then {
{
_newList pushBack [name _x, getPlayerUID _x, 0, 3, 0, 0, 0];
} forEach (allPlayers - entities "HeadlessClient_F");
};

KPR_players = +_newList;
KPR_players sort true;
profileNamespace setVariable ["KPR_players", KPR_players];
saveProfileNamespace;
publicVariable "KPR_players";

true
3 changes: 2 additions & 1 deletion addons/KP_Ranks/fnc/fn_scoreUpdate.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
File: fn_scoreUpdate.sqf
Author: Wyqer - https://github.com/KillahPotatoes
Date: 2018-07-19
Last Update: 2018-07-19
Last Update: 2018-08-02
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
Description:
Expand All @@ -31,6 +31,7 @@ private _score = 0;
private _rank = 0;
private _newPlaytime = 0;
private _neededPoints = 99999;
private _keepPoints = 0;

{
// Player UID and array index in KPR_players for current player
Expand Down
34 changes: 34 additions & 0 deletions addons/KP_Ranks/fnc/fn_setRank.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
KPR_fnc_setRank
File: fn_setRank.sqf
Author: Wyqer - https://github.com/KillahPotatoes
Date: 2018-07-23
Last Update: 2018-07-23
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
Description:
Sets the rank of a given player to a given rank. Returns true on success and false if the player wasn't found.
Parameter(s):
0: STRING - Steam UID of the player
1: NUMBER - Rank to set (default: 0)
Returns:
BOOL
*/

if (!isServer) exitWith {false};

params ["_uid", ["_rank", 0]];

private _index = KPR_players findIf {_x select 1 == _uid};

// Return false, if uid wasn't found in the players array
if (_index == -1) exitWith {false};

// Set rank and save
KPR_players select _index set [2, _rank];
[KPR_players] call KPR_fnc_savePlayers;

true
Loading

0 comments on commit 55d63f9

Please sign in to comment.