Update pulse.gnut
This commit is contained in:
@@ -6,28 +6,28 @@ table globalToneAPIKillData = {}
|
|||||||
void function GetStatsFromToneAPI()
|
void function GetStatsFromToneAPI()
|
||||||
{
|
{
|
||||||
//SetConVarString("ToneURL", "https://toneapi.sleepycat.date/v1")
|
//SetConVarString("ToneURL", "https://toneapi.sleepycat.date/v1")
|
||||||
print("[PULSE] Pulse Loaded")
|
print("[PULSE] Loaded, getting data...")
|
||||||
HttpRequest getStats
|
HttpRequest getStats
|
||||||
getStats.method = HttpRequestMethod.GET
|
getStats.method = HttpRequestMethod.GET
|
||||||
getStats.url = "https://tone.sleepycat.date/v1/client/weapons"
|
getStats.url = "https://tone.sleepycat.date/v1/client/weapons"
|
||||||
getStats.queryParameters["player"] <- [NSGetLocalPlayerUID().tostring()]
|
getStats.queryParameters["player"] <- [NSGetLocalPlayerUID().tostring()]
|
||||||
void functionref(HttpRequestResponse) onSuccess = void function(HttpRequestResponse response)
|
void functionref(HttpRequestResponse) onSuccess = void function(HttpRequestResponse response)
|
||||||
{
|
{
|
||||||
print("[PULSE] Recieved kill data")
|
print("[PULSE] Kill data received, processing...")
|
||||||
table JSONForConversion = DecodeJSON(response.body)
|
table JSONForConversion = DecodeJSON(response.body)
|
||||||
foreach (var key, var value in JSONForConversion) {
|
foreach (var key, var value in JSONForConversion) {
|
||||||
table test = expect table(value)
|
table test = expect table(value)
|
||||||
//this won't work on v2 since kills will be an integer already
|
//this won't work on v2 since kills will be an integer already
|
||||||
string kills = expect string(test.kills)
|
string kills = expect string(test.kills)
|
||||||
globalToneAPIKillData[string(key)] <- kills.tointeger()
|
globalToneAPIKillData[string(key)] <- kills.tointeger()
|
||||||
print("[PULSE] " + key + " added")
|
print("[PULSE] " + key + " has been added.")
|
||||||
}
|
}
|
||||||
print("[PULSE] kill data processed")
|
print("[PULSE] Kill data has been processed.")
|
||||||
}
|
}
|
||||||
|
|
||||||
void functionref(HttpRequestFailure) onFailure = void function(HttpRequestFailure failure)
|
void functionref(HttpRequestFailure) onFailure = void function(HttpRequestFailure failure)
|
||||||
{
|
{
|
||||||
print("[PULSE] Encountered some error getting kill data...")
|
print("[PULSE] Encountered an error getting kill data...")
|
||||||
}
|
}
|
||||||
|
|
||||||
bool result = NSHttpRequest(getStats, onSuccess, onFailure)
|
bool result = NSHttpRequest(getStats, onSuccess, onFailure)
|
||||||
|
|||||||
Reference in New Issue
Block a user