fix 1
This commit is contained in:
@@ -17,18 +17,27 @@ function gatherState() {
|
|||||||
const total_points = uw.Game?.player_points ?? 0;
|
const total_points = uw.Game?.player_points ?? 0;
|
||||||
const world = uw.Game?.world_id || '';
|
const world = uw.Game?.world_id || '';
|
||||||
|
|
||||||
let battle_points = { att: 0, def: 0, available: 0, used: 0 };
|
let battle_points = { available: 0, used: 0 };
|
||||||
try {
|
try {
|
||||||
const pk = uw.MM?.getModels?.()?.PlayerKillpoints;
|
const pkModels = uw.MM?.getModels?.()?.PlayerKillpoints;
|
||||||
if (pk) {
|
if (pkModels && pkModels[player_id]) {
|
||||||
const m = pk[player_id] || Object.values(pk)[0];
|
const pk = pkModels[player_id];
|
||||||
if (m && m.attributes) {
|
battle_points.used = pk.attributes?.used || 0;
|
||||||
battle_points = {
|
if (typeof pk.getUnusedPoints === 'function') {
|
||||||
att: m.attributes.att || 0,
|
battle_points.available = pk.getUnusedPoints();
|
||||||
def: m.attributes.def || 0,
|
} else if (pk.attributes?.available !== undefined) {
|
||||||
available: m.attributes.available || 0,
|
battle_points.available = pk.attributes.available;
|
||||||
used: m.attributes.used || 0
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
// Force sync with the exact UI number if available (e.g. 1986)
|
||||||
|
if (uw.$) {
|
||||||
|
const uiText = uw.$('.nui_battlepoints_container .points').text();
|
||||||
|
if (uiText) {
|
||||||
|
const parsed = parseInt(uiText.replace(/[^\d]/g, ''), 10);
|
||||||
|
if (!isNaN(parsed)) {
|
||||||
|
battle_points.available = parsed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) { log(`Failed to extract battle_points: ${e}`); }
|
} catch (e) { log(`Failed to extract battle_points: ${e}`); }
|
||||||
|
|||||||
Reference in New Issue
Block a user