75 lines
2.6 KiB
Plaintext
75 lines
2.6 KiB
Plaintext
global function GetStatsFromToneAPI
|
|
global function getWeaponKillsFromToneApi
|
|
global function getNemesisWeaponFromToneAPI
|
|
global function getDWEFromToneAPI
|
|
|
|
global table globalToneAPIKillData = {}
|
|
global table globalToneAPIDeathData = {}
|
|
global table globalToneAPIDWEData = {}
|
|
|
|
void function GetStatsFromToneAPI()
|
|
{
|
|
thread GetStatsFromToneAPI_threaded()
|
|
}
|
|
|
|
void function GetStatsFromToneAPI_threaded(){
|
|
|
|
while(true){
|
|
if(NSIsMasterServerAuthenticated()) break
|
|
WaitFrame()
|
|
}
|
|
//SetConVarString("ToneURL", "https://toneapi.sleepycat.date/v2_test")
|
|
print("[PULSE] Loaded, getting data...")
|
|
HttpRequest getStats
|
|
getStats.method = HttpRequestMethod.GET
|
|
getStats.url = "https://tone.sleepycat.date/v2/client/weapons"
|
|
getStats.queryParameters["player"] <- [NSGetLocalPlayerUID()]
|
|
void functionref(HttpRequestResponse) onSuccess = void function(HttpRequestResponse response)
|
|
{
|
|
print("[PULSE] Kill data received, processing...")
|
|
table JSONForConversion = DecodeJSON(response.body)
|
|
foreach (var key, var value in JSONForConversion) {
|
|
table test = expect table(value)
|
|
globalToneAPIKillData[string(key)] <- test.kills
|
|
globalToneAPIDeathData[string(key)] <- test.deaths
|
|
globalToneAPIDWEData[string(key)] <- test.deaths_while_equipped
|
|
print("[PULSE] " + key + " has been added.")
|
|
}
|
|
print("[PULSE] Kill data has been processed.")
|
|
}
|
|
|
|
void functionref(HttpRequestFailure) onFailure = void function(HttpRequestFailure failure)
|
|
{
|
|
print("[PULSE] Encountered an error getting kill data...")
|
|
}
|
|
|
|
bool result = NSHttpRequest(getStats, onSuccess, onFailure)
|
|
print("[PULSE] result is " + result)
|
|
}
|
|
|
|
int function getWeaponKillsFromToneApi(string weaponRef){
|
|
|
|
if(weaponRef in globalToneAPIKillData){
|
|
print("[PULSE] Found matching weapon : " + weaponRef + " with " + globalToneAPIKillData[weaponRef] + " kills")
|
|
return expect int(globalToneAPIKillData[weaponRef])
|
|
}
|
|
return 0
|
|
}
|
|
|
|
int function getNemesisWeaponFromToneAPI(string weaponRef){
|
|
|
|
if(weaponRef in globalToneAPIDeathData){
|
|
print("[PULSE] Found matching weapon : " + weaponRef + " with " + globalToneAPIDeathData[weaponRef] + " nemesis weapon kills")
|
|
return expect int(globalToneAPIDeathData[weaponRef])
|
|
}
|
|
return 0
|
|
}
|
|
|
|
int function getDWEFromToneAPI(string weaponRef){
|
|
|
|
if(weaponRef in globalToneAPIDWEData){
|
|
print("[PULSE] Found matching weapon : " + weaponRef + " with " + globalToneAPIDeathData[weaponRef] + " deaths while equipped")
|
|
return expect int(globalToneAPIDWEData[weaponRef])
|
|
}
|
|
return 0
|
|
} |