bumyplum 10 Posted August 21, 2019 I'm attempting to create a custom leader board with points i assign to players, how ever it just returns <null>. private _arr = []; _pScore = { _playerPoints = _x getVariable "Players_Points"; _playerName = name _x; _points = format["%1 - %2", _playerPoints, _playerName]; _arr pushBack _points; }forEach playableUnits; { _Leaderboard_GUI_LB lbAdd _x; } forEach _arr; how ever it adds them to the listbox and their names work fine just it doesn't seem to get the variable "Players_Points" and returns null. _getStats = player getVariable "Players_Points"; _updateStats = _getStats + 10; player setVariable["Players_Points", _updateStats]; (locally this is how the points are applied to a player) Share this post Link to post Share on other sites
Grumpy Old Man 3549 Posted August 22, 2019 3 hours ago, bumyplum said: I'm attempting to create a custom leader board with points i assign to players, how ever it just returns <null>. private _arr = []; _pScore = { _playerPoints = _x getVariable "Players_Points"; _playerName = name _x; _points = format["%1 - %2", _playerPoints, _playerName]; _arr pushBack _points; }forEach playableUnits; { _Leaderboard_GUI_LB lbAdd _x; } forEach _arr; how ever it adds them to the listbox and their names work fine just it doesn't seem to get the variable "Players_Points" and returns null. _getStats = player getVariable "Players_Points"; _updateStats = _getStats + 10; player setVariable["Players_Points", _updateStats]; (locally this is how the points are applied to a player) That's because your "Players_Points" is undefined, most likely, try this: _playerPoints = _x getVariable ["Players_Points",0]; Will return 0 if the player doesn't have the variable set, otherwise it will return the proper points. Cheers Share this post Link to post Share on other sites
engima 328 Posted August 22, 2019 In SP or MP? If MP, then you should use the alternative syntax of setVariable to broadcast the variable to all other machines. unit setVariable [var, value, true]; https://community.bistudio.com/wiki/setVariable Share this post Link to post Share on other sites
bumyplum 10 Posted August 22, 2019 1 minute ago, engima said: In SP or MP? If MP, then you should use the alternative syntax of setVariable to broadcast the variable to all other machines. unit setVariable [var, value, true]; https://community.bistudio.com/wiki/setVariable MP sandbox Share this post Link to post Share on other sites
bumyplum 10 Posted August 22, 2019 18 minutes ago, Grumpy Old Man said: That's because your "Players_Points" is undefined, most likely, try this: _playerPoints = _x getVariable ["Players_Points",0]; Will return 0 if the player doesn't have the variable set, otherwise it will return the proper points. Cheers I've attempted this and even if they do have points then it just adds 0 for them Share this post Link to post Share on other sites
stanhope 412 Posted August 22, 2019 Is the machine on which you're doing the servariable the same as the one you're doing the getvariable on? If not add "true" as a 3rd param to setVariable to make it global. Share this post Link to post Share on other sites
Grumpy Old Man 3549 Posted August 22, 2019 3 hours ago, stanhope said: Is the machine on which you're doing the servariable the same as the one you're doing the getvariable on? If not add "true" as a 3rd param to setVariable to make it global. Alternatively one could handle stuff like this entirely on server and only broadcast points when needed. Cheers Share this post Link to post Share on other sites
bumyplum 10 Posted August 22, 2019 6 hours ago, stanhope said: Is the machine on which you're doing the servariable the same as the one you're doing the getvariable on? If not add "true" as a 3rd param to setVariable to make it global. The player gets points by capturing a flag and ever x amount of time the player gets x amount of points, i've changed how the points are added to the player to // player setVariable["Players_Points", 0, "true"]; which is executed locally on them self, how ever when trying to make a scoreboard it just adds my points as 0 as well as other players I've also attempted _namePlayer = format["%1_points", name player]; missionNamespace setVariable [_namePlayer , 100, "true"]; // for giving points private _arr = []; _pScore = { _namePlayer = format["%1_points", name _x]; _getVarPoints = missionNamespace getVariable [_namePlayer, 0]; _playerName = name _x; _points = format["%1 - %2", _getVarPoints, _playerName]; _arr pushBack _points; }forEach playableUnits; { _Leaderboard_GUI_LB lbAdd _x; } forEach _arr; // for adding to the list box how ever it shows my points correctly just doesn't display other players it just displays 0 even if they have points Share this post Link to post Share on other sites
stanhope 412 Posted August 22, 2019 1 hour ago, bumyplum said: missionNamespace setVariable [_namePlayer , 100, "true"]; true as in the boolean true, not the string true. https://community.bistudio.com/wiki/setVariable Share this post Link to post Share on other sites
bumyplum 10 Posted August 22, 2019 1 minute ago, stanhope said: true as in the boolean true, not the string true. https://community.bistudio.com/wiki/setVariable i tried both and neither worked i believe Share this post Link to post Share on other sites