ต้องการความช่วยเหลือ? อย่าเปิดปัญหา - ถามในห้อง Gitter
ปลั๊กอิน Node-Steam สำหรับ Counter-Strike: Global Offensive
ขึ้นอยู่กับ Node-DOTA2 โดย RJACKSONM1
รายการนี้ใช้เวลานานเกินไป อยากอยู่กับมันไหม ส่งข้อความถึงฉันเกี่ยวกับ Gitter แล้วเราจะคุยกัน - Joshuaferrara
พารามิเตอร์:
steamUser
- ผ่านอินสแตนซ์ของ Steamuser เพื่อเปลี่ยนสถานะปัจจุบันของคุณ (ในเกม/ไม่)steamGC
- ผ่านอินสแตนซ์ Steamgamecoordinator เพื่อใช้ในการส่งและรับข้อความ GCdebug
- บูลีนสังเกตว่าจะพิมพ์ข้อมูลเกี่ยวกับการดำเนินการเพื่อคอนโซลหรือไม่ var Steam = require ( 'steam' ) ,
steamClient = new Steam . SteamClient ( ) ,
steamUser = new Steam . SteamUser ( steamClient ) ,
steamGC = new Steam . SteamGameCoordinator ( steamClient , 730 ) ,
csgo = require ( 'csgo' ) ,
CSGO = new csgo . CSGOClient ( steamUser , steamGC , false ) ;
วิธีการทั้งหมดต้องใช้อินสแตนซ์ของ Steamclient ที่จะเข้าสู่ระบบ
launch()
รายงานถึง Steam ว่าคุณกำลังเล่น Counter-Strike: Global Offensive จากนั้นเริ่มการสื่อสารกับผู้ประสานงานเกม
exit()
บอกกับ Steam ว่าคุณไม่ได้เล่น CS: ไป
ToAccountID(steamId)
แปลงรหัสไอน้ำ 64 บิตเป็นรหัสบัญชี
ToSteamID(accountId)
แปลงรหัสบัญชีเป็นรหัสไอน้ำ 64 บิต
Rank.getString(int rank_id)
แปลงจำนวนเต็ม RANK_ID เป็นสตริง ตัวอย่าง: CSGO.Rank.getString(1) = "Silver I"
Level.getString(int player_level)
แปลงผู้เล่นจำนวนเต็ม _level เป็นสตริง ตัวอย่าง: CSGO.Level.getString(1) = "Recruit"
matchmakingStatsRequest()
ส่งข้อความไปยังผู้ประสานงานเกมเพื่อขอสถิติการจับคู่ ฟังกิจกรรม matchmakingStatsData
สำหรับการตอบสนองของผู้ประสานงานเกม ต้องการให้ GC พร้อม (ฟังเหตุการณ์ ready
ก่อนโทร)
requestRecentGames()
ร้องขอรายการเกมล่าสุดสำหรับบัญชีที่เข้าสู่ระบบในปัจจุบัน ฟังเหตุการณ์ matchList
สำหรับการตอบสนองของผู้ประสานงานเกม
requestLiveGameForUser(accountId)
ขอข้อมูลเกมสดในปัจจุบันสำหรับผู้ใช้ที่ได้รับ ฟังเหตุการณ์ matchList
สำหรับการตอบสนองของผู้ประสานงานเกม
requestGame(string matchid, string outcomeid, int token)
ข้อมูลการร้องขอเกี่ยวกับเกมที่ได้รับการจับคู่ผลลัพธ์และโทเค็นสำหรับเกม (เคล็ดลับ: สิ่งเหล่านี้สามารถพบได้ด้วยตัวถอดรหัส ShareCode) ฟังเหตุการณ์ matchList
สำหรับการตอบสนองของผู้ประสานงานเกม
requestWatchInfoFriends(arguments)
ขอข้อมูลที่สามารถดูได้สำหรับเกม ข้อโต้แย้ง:
int request_id ; //Not enough tests yet
account_ids [ array_of_csgo_accounts ] ; //Not enough tests yet
long serverid ; //ServerID of match.
long matchid ; //MatchID of match.
ตัวอย่าง:
CSGO . requestWatchInfoFriends ( {
serverid : new Long ( - 569600767 , - 2130640678 , true ) . toString ( ) ,
matchid : new Long ( 39 , 719230023 , true ) . toString ( )
} ) ;
ข้อกำหนด: เกมควรมีชีวิตอยู่
ฟังเหตุการณ์ watchList
สำหรับการตอบสนองของผู้ประสานงานเกม
requestCurrentLiveGames()
ขอรายชื่อเกมสดในปัจจุบัน ฟังเหตุการณ์ matchList
สำหรับการตอบสนองของผู้ประสานงานเกม
playerProfileRequest(accountId)
accountId
เป็นรหัสบัญชีของผู้เล่น (สามารถแปลง ISTID64 ของผู้เล่นเป็นรหัสบัญชีด้วย CSGO.ToAccountID(steamid)
)
ร้องขอโปรไฟล์ของผู้เล่นจากผู้ประสานงานเกม ผู้เล่นจะต้องออนไลน์และเล่น CS: ไป ฟังกิจกรรม playerProfile
สำหรับการตอบสนองของผู้ประสานงานเกม
หมายเหตุ: คุณไม่สามารถตั้งค่าสถานะที่หลากหลายของคุณเป็นสตริงโดยพลการอีกต่อไป แต่ตอนนี้เกมกำหนดรายการค่าสถานะที่สมบูรณ์สูงสุด 20 ค่าที่สามารถแสดงได้ ดูวิธี
SetRichPresence
ในเอกสารนี้สำหรับข้อมูลเพิ่มเติม
richPresenceUpload(richPresenceObject)
ตั้งค่าวัตถุ Rich Present สำหรับผู้ใช้ที่เข้าสู่ระบบในปัจจุบัน Rich Presence เป็นทางออกของ Valve ในการให้ข้อมูลเพื่อนเกี่ยวกับสิ่งที่คุณทำในเกม ตัวอย่างเช่นเมื่อคุณเห็นข้อมูลเกี่ยวกับเกมการจับคู่เพื่อนคนอื่น (เช่นในแผนที่และคะแนน) สิ่งนี้ถูกตั้งค่าโดยใช้การแสดงตนที่หลากหลาย ตัวอย่างของวิธีการใช้วิธีนี้สามารถพบได้ใน example.js
itemDataRequest(string s, string a, string d, string m)
คำขอข้อมูลรายการสำหรับพารามิเตอร์การเชื่อมโยงรายการ CSGO ที่ระบุ พารามิเตอร์ s
มีค่าเมื่อลิงค์ตรวจสอบมาจากสินค้าคงคลัง ในทำนองเดียวกันพารามิเตอร์ m
มีค่าเมื่อลิงค์ตรวจสอบมาจากตลาด หากไม่มีค่าสำหรับพารามิเตอร์ที่กำหนดจากลิงก์ตรวจสอบให้ตั้งค่าเป็น "0"
ฟังเหตุการณ์ itemData
สำหรับการตอบสนองของผู้ประสานงานเกม
ตัวอย่างสำหรับลิงค์ตรวจสอบสินค้าคงคลังสำหรับรายการ CSGO
// steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20S76561198084749846A6768147729D12557175561287951743
CSGO . itemDataRequest ( "76561198084749846" , "6768147729" , "12557175561287951743" , "0" ) ;
ตัวอย่างสำหรับลิงค์ตรวจสอบตลาดสำหรับรายการ CSGO
// steam://rungame/730/76561202255233023/+csgo_econ_action_preview%20M563330426657599553A6710760926D9406593057029549017
CSGO . itemDataRequest ( "0" , "6710760926" , "9406593057029549017" , "563330426657599553" ) ;
new CSGO.SharecodeDecoder(string code);
อินสแตนซ์คลาส Sharecodedecoder เพื่อถอดรหัส ShareCodes
การเรียกใช้วิธี decode()
ของ SharecodeDecoder
จะส่งคืนวัตถุด้วยข้อมูลที่ถอดรหัส
console . log ( new CSGO . SharecodeDecoder ( "CSGO-U6MWi-hYFWJ-opPwD-JciHm-qOijD" ) . decode ( ) )
{ matchId : '3106049990460440633' ,
outcomeId : '3106056003414655216' ,
tokenId : '11842' }
ready
ปล่อยออกมาเมื่อ GC พร้อมที่จะรับข้อความ ระวังอย่าประกาศฟังก์ชั่นที่ไม่ระบุชื่อเป็นตัวจัดการเหตุการณ์ที่นี่เนื่องจากคุณจะต้องสามารถทำให้ตัวจัดการเหตุการณ์เป็นโมฆะในเหตุการณ์ unready
unready
ปล่อยออกมาเมื่อสถานะการเชื่อมต่อกับการเปลี่ยนแปลง GC และทำให้ห้องสมุดไม่สามารถโต้ตอบได้ คุณควรล้างตัวจัดการเหตุการณ์ใด ๆ ที่ตั้งอยู่ในเหตุการณ์ ready
ที่นี่มิฉะนั้นคุณจะมีตัวจัดการหลายตัวสำหรับทุกข้อความทุกครั้งที่มีการส่งเหตุการณ์ ready
ใหม่
exited
ปล่อยออกมาเมื่อ .exit()
เรียกว่าเป็นความสะดวกในการล้างตัวจัดการเมื่อออกโดยเจตนา
itemData
( itemDataResponse
) {
"iteminfo" :
{
"accountid" : null ,
"itemid" : Long { "low" : - 1821786863 , "high" : 1 , "unsigned" : true } ,
"defindex" : 7 ,
"paintindex" : 474 ,
"rarity" : 6 ,
"quality" : 4 ,
"paintwear" : 1054492909 ,
"paintseed" : 183 ,
"killeaterscoretype" : null ,
"killeatervalue" : null ,
"customname" : null ,
"stickers" : [ ] ,
"inventory" : 3221225475 ,
"origin" : 8 ,
"questid" : null ,
"dropreason" : null ,
"floatvalue" : 0.4263376295566559
}
}
ปล่อยออกมาเมื่อผู้ประสานงานเกมตอบสนองต่อวิธี itemDataRequest
matchmakingStatsData
( matchmakingStatsResponse
)matchmakingStatsResponse
- วัตถุตอบสนองดิบ ตัวอย่างการตอบกลับด้านล่าง {
"account_id" : 137013074 ,
"ongoingmatch" : { // Only populated when logged in user is in a match
"serverid" : 90112014586923017 ,
"direct_udp_ip" : 2734604850 ,
"direct_udp_port" : 27035 ,
"reservationid" : 18374688715512210549 ,
"reservation" : {
"game_type" : 520 ,
"match_id" : 3245263802660290728 ,
"tournament_event" : null ,
"pre_match_data" : null
} ,
"map" : "de_dust2" ,
"server_address" : "=[A:1:153428969:9318]:0"
} ,
"global_stats" : {
"players_online" : 423480 ,
"servers_online" : 132472 ,
"players_searching" : 4212 ,
"servers_available" : 65497 ,
"ongoing_matches" : 17016 ,
"search_time_avg" : 46530 ,
"search_statistics" : [
{
"game_type" : 264 ,
"search_time_avg" : 128555 ,
"players_searching" : 148
} ,
{
"game_type" : 520 ,
"search_time_avg" : 31962 ,
"players_searching" : 1768
} ,
{
"game_type" : 1032 ,
"search_time_avg" : 122353 ,
"players_searching" : 426
} ,
{
"game_type" : 2056 ,
"search_time_avg" : 136133 ,
"players_searching" : 160
} ,
{
"game_type" : 4104 ,
"search_time_avg" : 62643 ,
"players_searching" : 1069
} ,
{
"game_type" : 8200 ,
"search_time_avg" : 70380 ,
"players_searching" : 563
} ,
{
"game_type" : 16392 ,
"search_time_avg" : 115923 ,
"players_searching" : 132
} ,
{
"game_type" : 32776 ,
"search_time_avg" : 54906 ,
"players_searching" : 1248
} ,
{
"game_type" : 65544 ,
"search_time_avg" : 116871 ,
"players_searching" : 183
} ,
{
"game_type" : 131080 ,
"search_time_avg" : 82308 ,
"players_searching" : 145
} ,
{
"game_type" : 262152 ,
"search_time_avg" : 209331 ,
"players_searching" : 105
} ,
{
"game_type" : 524296 ,
"search_time_avg" : 270376 ,
"players_searching" : 110
} ,
{
"game_type" : 1048584 ,
"search_time_avg" : 64499 ,
"players_searching" : 1020
} ,
{
"game_type" : 268435464 ,
"search_time_avg" : 84615 ,
"players_searching" : 642
} ,
{
"game_type" : 536870920 ,
"search_time_avg" : 104965 ,
"players_searching" : 478
} ,
{
"game_type" : 2097160 ,
"search_time_avg" : 198734 ,
"players_searching" : 228
} ,
{
"game_type" : 134217736 ,
"search_time_avg" : 147703 ,
"players_searching" : 203
} ,
{
"game_type" : 8388616 ,
"search_time_avg" : 538828 ,
"players_searching" : 138
} ,
{
"game_type" : 16777224 ,
"search_time_avg" : 232350 ,
"players_searching" : 192
} ,
{
"game_type" : 4194312 ,
"search_time_avg" : 237269 ,
"players_searching" : 151
} ,
{
"game_type" : 33554440 ,
"search_time_avg" : 203183 ,
"players_searching" : 181
}
] ,
"main_post_url" : "" ,
"required_appid_version" : 13494 ,
"pricesheet_version" : 1438240620 ,
"twitch_streams_version" : 2 ,
"active_tournament_eventid" : 6 ,
"active_survey_id" : 0
} ,
"penalty_seconds" : null , // Contains amount of time logged in account has an MM cooldown
"penalty_reason" : null , // Integer representing reason for MM cooldown
"vac_banned" : 0 ,
"ranking" : {
"account_id" : 137013074 ,
"rank_id" : 11 ,
"wins" : 192 ,
"rank_change" : null
} ,
"commendation" : {
"cmd_friendly" : 3 ,
"cmd_teaching" : 3 ,
"cmd_leader" : 3
} ,
"medals" : {
"medal_team" : 0 ,
"medal_combat" : 0 ,
"medal_weapon" : 0 ,
"medal_global" : 0 ,
"medal_arms" : 0 ,
"display_items_defidx" : [ ] ,
"featured_display_item_defidx" : null
} ,
"my_current_event" : null ,
"my_current_event_teams" : [ ] ,
"my_current_team" : null ,
"my_current_event_stages" : [ ] ,
"survey_vote" : null ,
"activity" : null ,
"player_level" : 3 ,
"player_cur_xp" : 327684342 ,
"player_xp_bonus_flags" : null
}
ปล่อยออกมาเมื่อผู้ประสานงานเกมตอบสนองต่อวิธี matchmakingStatsRequest
playerProfile
(การตอบสนองต่อ playerProfileRequest
) {
"request_id" : null ,
"account_profiles" : [
{
"account_id" : 137013074 ,
"ongoingmatch" : null ,
"global_stats" : null ,
"penalty_seconds" : null ,
"penalty_reason" : null ,
"vac_banned" : null ,
"ranking" : {
"account_id" : 137013074 ,
"rank_id" : 11 ,
"wins" : 192 ,
"rank_change" : null
},
"commendation" : {
"cmd_friendly" : 3 ,
"cmd_teaching" : 3 ,
"cmd_leader" : 3
},
"medals" : {
"medal_team" : 0 ,
"medal_combat" : 0 ,
"medal_weapon" : 0 ,
"medal_global" : 0 ,
"medal_arms" : 0 ,
"display_items_defidx" : [],
"featured_display_item_defidx" : null
},
"my_current_event" : null ,
"my_current_event_teams" : [],
"my_current_team" : null ,
"my_current_event_stages" : [],
"survey_vote" : null ,
"activity" : null ,
"player_level" : 3 ,
"player_cur_xp" : 327684342 ,
"player_xp_bonus_flags" : null
}
]
}
ปล่อยออกมาเมื่อผู้ประสานงานเกมตอบสนองต่อวิธี playerProfileRequest
matchList
(การตอบสนองต่อ requestRecentGames
)การตอบสนองทั้งหมดจบลงด้วยการใหญ่เกินไปสำหรับผู้อ่านและทำให้เบราว์เซอร์ผิดพลาด ด้วยเหตุนี้ฉันจึงรวมข้อความที่ตัดตอนมาเป็นสิ่งที่กลับมา
{
"reservationid" : {
"low" : 65 ,
"high" : 715485165 ,
"unsigned" : true
},
"reservation" : {
"account_ids" : [
2879081 ,
182261908 ,
225695551 ,
30039512 ,
90132590 ,
94815387 ,
37671978 ,
31906737 ,
137013074 ,
61347894
],
"game_type" : 1032 ,
"match_id" : null ,
"server_version" : null ,
"rankings" : [],
"encryption_key" : null ,
"encryption_key_pub" : null ,
"party_ids" : [],
"whitelist" : [],
"tv_master_steamid" : null ,
"tournament_event" : null ,
"tournament_teams" : [],
"tournament_casters_account_ids" : [],
"tv_relay_steamid" : null ,
"pre_match_data" : null
},
"map" : " http://replay124.valve.net/730/003072985384448163905_0699089210.dem.bz2 " ,
"round" : null ,
"kills" : [
21 ,
22 ,
15 ,
15 ,
12 ,
37 ,
20 ,
23 ,
17 ,
15
],
"assists" : [
5 ,
5 ,
1 ,
3 ,
4 ,
2 ,
3 ,
2 ,
6 ,
7
],
"deaths" : [
22 ,
22 ,
24 ,
23 ,
21 ,
13 ,
13 ,
19 ,
20 ,
20
],
"scores" : [
55 ,
54 ,
40 ,
39 ,
37 ,
79 ,
65 ,
59 ,
41 ,
37
],
"pings" : [],
"round_result" : null ,
"match_result" : 2 ,
"team_scores" : [
11 ,
16
],
"confirm" : null ,
"reservation_stage" : null ,
"match_duration" : 2332 ,
"enemy_kills" : [
21 ,
22 ,
15 ,
15 ,
12 ,
37 ,
20 ,
23 ,
17 ,
15
],
"enemy_headshots" : [
12 ,
11 ,
4 ,
2 ,
3 ,
9 ,
6 ,
9 ,
3 ,
12
],
"enemy_3ks" : [],
"enemy_4ks" : [],
"enemy_5ks" : [],
"mvps" : [
4 ,
3 ,
1 ,
1 ,
2 ,
4 ,
5 ,
2 ,
3 ,
2
],
"spectators_count" : null ,
"spectators_count_tv" : null ,
"spectators_count_lnk" : null ,
"enemy_kills_agg" : []
}
ปล่อยออกมาเมื่อ requestRecentGames
, requestGame
, requestLiveGameForUser
, requestCurrentLiveGames
ถูกตอบไป
watchList
(การตอบสนองต่อ requestWatchInfoFriends
)ตัวอย่าง:
{
"request_id" : 0 ,
"account_ids" : [],
"watchable_match_infos" : [
{
"server_ip" : 2453839835 ,
"tv_port" : 28056 ,
"tv_spectators" : 1 ,
"tv_time" : 417 ,
"tv_watch_password" : {
"buffer" : {
"type" : " Buffer " ,
"data" : [ ]
},
"offset" : 21 ,
"markedOffset" : -1 ,
"limit" : 53 ,
"littleEndian" : true ,
"noAssert" : false
},
"cl_decryptdata_key" : null ,
"cl_decryptdata_key_pub" : {
"low" : -249571153 ,
"high" : 1941167002 ,
"unsigned" : true
},
"game_type" : 32776 ,
"game_mapgroup" : " mg_de_mirage " ,
"game_map" : " de_mirage " ,
"server_id" : {
"low" : 2054631424 ,
"high" : 20977258 ,
"unsigned" : true
},
"match_id" : {
"low" : 32 ,
"high" : 719254593 ,
"unsigned" : true
},
"reservation_id" : null
}
],
"extended_timeout" : null
}