类型 事件 版本 发布 2024.3703 关键字 steam、steamworks、排行榜、setHighScore 另请参阅 steamworks.requestSetHighScore() steamworks.*
事件,指示对 steamworks.requestSetHighScore() 函数的调用是成功还是失败的。此外,还指示分数是否更改了,如果更改了,用户在排行榜上的新全球排名为多少。
该事件只能被传递给了 steamworks.requestSetHighScore() 函数的 函数 监听器接收。
local steamworks = require( "plugin.steamworks" )
-- Called by the "steamworks.requestSetHighScore()" function with the result
local function onReceivedSetHighScoreResult( event )
if ( event.isError ) then
-- Request failed; typically happens when there is no Internet access
-- Note that an error will not occur if the given score is less than the highest
print( "Failed to access the leaderboard." )
else
-- Print the result of this request to the log
print( "Leaderboard Name: " .. event.leaderboardName )
print( "Was Score Changed: " .. tostring(event.scoreChanged) )
if ( event.scoreChanged ) then
print( "Current Rank: " .. tostring(event.currentGlobalRank) )
print( "Previous Rank: " .. tostring(event.previousGlobalRank) )
end
end
end
-- Attempt to set a new high score for the current user
-- Requires an active Internet connection to succeed
-- Will provide the requested result to the given function
local requestSettings =
{
leaderboardName = "My Leaderboard Name",
value = 9000,
listener = onReceivedSetHighScoreResult
}
steamworks.requestSetHighScore( requestSettings )