From ad9e7303575ed17596f03415bcbb6d0229195e5f Mon Sep 17 00:00:00 2001 From: tbox1911 Date: Fri, 19 Jul 2024 12:47:57 +0200 Subject: [PATCH] fix set perm player (keep score) --- .../scripts/client/misc/welcome.sqf | 1 + .../server/game/apply_saved_scores.sqf | 8 +--- .../scripts/server/game/manage_score.sqf | 45 ++++++++++--------- 3 files changed, 26 insertions(+), 28 deletions(-) diff --git a/core.liberation/scripts/client/misc/welcome.sqf b/core.liberation/scripts/client/misc/welcome.sqf index 30a909994..d8bd46fe7 100644 --- a/core.liberation/scripts/client/misc/welcome.sqf +++ b/core.liberation/scripts/client/misc/welcome.sqf @@ -2,6 +2,7 @@ Say hello, and set Rank/Insigna */ waitUntil {sleep 1; GRLIB_player_spawned}; +waitUntil {sleep 1; (player getVariable ["GRLIB_Rank", "init"] != "init")}; private _score = [player] call F_getScore; private _rank = player getVariable ["GRLIB_Rank", "Private"]; diff --git a/core.liberation/scripts/server/game/apply_saved_scores.sqf b/core.liberation/scripts/server/game/apply_saved_scores.sqf index 09aebe01e..47a4ec2db 100644 --- a/core.liberation/scripts/server/game/apply_saved_scores.sqf +++ b/core.liberation/scripts/server/game/apply_saved_scores.sqf @@ -32,12 +32,8 @@ while { true } do { _nextplayer setVariable ["GREUH_reput_count", 0, true]; }; - // set player rank - _score = _nextplayer getVariable ["GREUH_score_count",0]; - _rank = [_score] call get_rank; - _nextplayer setVariable ["GRLIB_Rank", _rank, true]; - [] remoteExec ["set_rank", owner _nextplayer]; - + _nextplayer setVariable ["GRLIB_Rank", "init", true]; + _nextplayer setVariable ["GREUH_score_last", 0, true]; _nextplayer setVariable ["GRLIB_score_set", 1, true]; }; diff --git a/core.liberation/scripts/server/game/manage_score.sqf b/core.liberation/scripts/server/game/manage_score.sqf index c676fd5ae..f6a09fd4e 100644 --- a/core.liberation/scripts/server/game/manage_score.sqf +++ b/core.liberation/scripts/server/game/manage_score.sqf @@ -80,34 +80,35 @@ while { true } do { }; }; - if (_x getVariable ["GRLIB_player_last_notif", 0] < time) then { - _msg = format ["Congratulation %1 !!
You have been promoted to : %2.

%3", name _x, _new_rank, _msg2]; - [_msg, 0, 0, 5, 0, 0, 90] remoteExec ["BIS_fnc_dynamicText", owner _x]; - ["FD_Finish_F"] remoteExec ["playSoundNow", owner _x]; - } else { - _msg = format ["You have been promoted to %1.", _new_rank]; - [gamelogic, _msg] remoteExec ["globalChat", owner _x]; - _firework = false; + if (_rank != "init") then { + if (_x getVariable ["GRLIB_player_last_notif", 0] < time) then { + _msg = format ["Congratulation %1 !!
You have been promoted to : %2.

%3", name _x, _new_rank, _msg2]; + [_msg, 0, 0, 5, 0, 0, 90] remoteExec ["BIS_fnc_dynamicText", owner _x]; + ["FD_Finish_F"] remoteExec ["playSoundNow", owner _x]; + } else { + _msg = format ["You have been promoted to %1.", _new_rank]; + [gamelogic, _msg] remoteExec ["globalChat", owner _x]; + _firework = false; + }; + _x setVariable ["GRLIB_player_last_notif", round (time + 5*60)]; + // if rank colonel global greet + if (_new_rank == "Colonel") then { + ["FD_Finish_F"] remoteExec ["playSoundNow", 0]; + _text = "Good news soldiers..."; + [gamelogic, _text] remoteExec ["globalChat", 0]; + _text = "We have a new Colonel !!"; + [gamelogic, _text] remoteExec ["globalChat", 0]; + _text = format ["Congratulation to %1 for his fight !!", name _x]; + [gamelogic, _text] remoteExec ["globalChat", 0]; + _text = "Over."; + [gamelogic, _text] remoteExec ["globalChat", 0]; + }; }; - _x setVariable ["GRLIB_player_last_notif", round (time + 5*60)]; // set player rank [] remoteExec ["set_rank", owner _x]; _x setVariable ["GRLIB_Rank", _new_rank, true]; - // if rank colonel global greet - if (_new_rank == "Colonel") then { - ["FD_Finish_F"] remoteExec ["playSoundNow", 0]; - _text = "Good news soldiers..."; - [gamelogic, _text] remoteExec ["globalChat", 0]; - _text = "We have a new Colonel !!"; - [gamelogic, _text] remoteExec ["globalChat", 0]; - _text = format ["Congratulation to %1 for his fight !!", name _x]; - [gamelogic, _text] remoteExec ["globalChat", 0]; - _text = "Over."; - [gamelogic, _text] remoteExec ["globalChat", 0]; - }; - // fireworks !! if (_firework) then { [getPosATL _x, _rounds] remoteExec ["remote_call_fireworks", 0];